[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [gnugo-devel] twogtp.py patch
From: |
Gunnar Farneback |
Subject: |
Re: [gnugo-devel] twogtp.py patch |
Date: |
Tue, 11 Mar 2003 00:14:22 +0100 |
User-agent: |
EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode) |
Paul wrote:
> - twogtp.py revised to support gtp version 2, improved and bugfixed
>
> full list of changes:
>
> - twogtp.py now uses gtp v2 commands if engine expects them (by
> Gunnar)
If anyone wonders I passed an unfinished patch to Paul who integrated
it with further changes he was planning to do. Another thing I added,
which was missing in the list of changes:
- new option --free-handicap <n> for free placement handicap
+ def swap_players(self):
+ temp = self.whiteplayer
+ self.whiteplayer = self.blackplayer
+ self.blackplayer = self.whiteplayer
This looks like a trivial bug.
+ if result[0][0] == last_color:
+ last_streak += 1
+ if last_streak == self.streak_length:
+ if last_color == "W":
+ self.handicap += 1
+ if self.handicap == 1:
+ self.handicap = 2
+ print "White wins too often. Increasing handicap to %d"
\
+ % (self.handicap)
+ else:
+ if self.handicap > 0:
+ self.handicap -= 1
+ if self.handicap == 1:
+ self.handicap = 0
+ print "Black wins too often. Decreasing handicap to
%d" \
+ % (self.handicap)
+ else:
+ self.handicap = 2
+ game.swap_players()
+ print "Black looks stronger than white. Swapping
colors and setting handicap to 2"
+ game.set_handicap(self.handicap)
+ last_color = ""
+ last_streak = 0
+ else:
+ last_color = result[0][0]
+ last_streak = 1
This doesn't work when streak_length is 1. Rewriting it as
if result[0][0] == last_color:
last_streak += 1
else:
last_color = result[0][0]
last_streak = 1
if last_streak == self.streak_length:
...
should solve the problem.
/Gunnar