Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrés Ambrois <andresambrois@gmail.com>2008-08-29 03:07:11 (GMT)
committer Andrés Ambrois <andresambrois@gmail.com>2008-08-29 03:07:11 (GMT)
commita3cc3acb713e16a644c5bd60d8491f99c4b2a7c1 (patch)
tree3bbc66befa8e95815ca8197f663b8970cc81b42e
parentd0b9290d7905f5b4e5acde8433fd8a393157270f (diff)
Fixed passing with AI
-rw-r--r--activity.py8
-rw-r--r--gtp.py9
2 files changed, 14 insertions, 3 deletions
diff --git a/activity.py b/activity.py
index 21dc578..99d70a1 100644
--- a/activity.py
+++ b/activity.py
@@ -155,16 +155,17 @@ class PlayGo(Activity):
self.board.draw_stone(x, y, self.get_currentcolor(), widget)
# Player passed
else:
- self.infopanel.show(_('Opponent passed'))
self.pass_count += 1
# Announce the local play
if self.get_shared() and announce:
self.collaboration.Play(x, y)
+ self.change_turn()
+ if x == -1:
+ self.infopanel.show(_('Opponent passed'))
# If this is the second consecutive pass, the game ends
if self.pass_count == 2:
self.game_end()
return
- self.change_turn()
# If we are playing a local game with AI turned off, change the color
if not self.get_shared() and not self.ai_activated:
self.change_player_color()
@@ -202,6 +203,9 @@ class PlayGo(Activity):
self.change_turn()
if self.pass_count == 2:
self.game_end()
+ if self.ai_activated:
+ self.ai.pass_move(self.get_currentcolor())
+ self.play_ai()
def write_file(self, file_path):
logger.debug('Writing file: %s', file_path)
diff --git a/gtp.py b/gtp.py
index 7484658..a394cda 100644
--- a/gtp.py
+++ b/gtp.py
@@ -77,7 +77,7 @@ class gnugo:
def get_move(self, color):
color = self.short_to_long_colors(color)
- self.stdin.write('genmove %s\n' % color)
+ self.stdin.write('kgs-genmove_cleanup %s\n' % color)
self.stdin.flush()
output = self.stdout.readline()
self.stdout.readline()
@@ -89,6 +89,13 @@ class gnugo:
logger.debug('Generated move %s', output[2:])
return self._coords_to_xy(output[2:])
+ def pass_move(self, color):
+ color = self.short_to_long_colors(color)
+ self.stdin.write('%s pass\n' % color)
+ self.stdin.flush()
+ self.stdout.readline()
+ self.stdout.readline()
+
def undo(self):
self.stdin.write('undo\n')
self.stdin.flush()