diff --git a/templates/cwa/gogame.html.j2 b/templates/cwa/gogame.html.j2
index 21539a9..42895d0 100644
--- a/templates/cwa/gogame.html.j2
+++ b/templates/cwa/gogame.html.j2
@@ -48,8 +48,14 @@
{% elif field[row][col] == 1 %}
+ {% if lastplaced[0] == row and lastplaced[1] == col and score is none %}
+
+ {% endif %}
{% elif field[row][col] == 2 %}
+ {% if lastplaced[0] == row and lastplaced[1] == col and score is none %}
+
+ {% endif %}
{% elif field[row][col] == 5 %}
{% elif field[row][col] == 6 %}
@@ -91,8 +97,8 @@
{% endif %}
- {% if game.is_completed %}
- Return to lobby
+ {% if abandoned or score is not none %}
+ Return to lobby
{% else %}
Refresh
{% endif %}
diff --git a/webgames/go.py b/webgames/go.py
index ca5b521..e1b4983 100644
--- a/webgames/go.py
+++ b/webgames/go.py
@@ -53,6 +53,7 @@ class GoPuzzle(Puzzle):
self._timer = None
self._tlock = Lock()
self._captures = [0, 0]
+ self._lastplaced = [-1, -1]
self._urlbase = '/'
def _gtp(self, command):
@@ -189,6 +190,7 @@ Press Play! to play against GNU Go or invite a second player.
self._timer.start()
move = action['go-input-submit']
if move == 'Pass':
+ self._lastplaced = [-1, -1]
if self.current_player == FieldState.BLACK:
self.black_passed = True
else:
@@ -205,12 +207,14 @@ Press Play! to play against GNU Go or invite a second player.
ret = self._gtp(f'play {player} {self.colnames[col]}{row+1}')
except RuntimeError:
return
+ self._lastplaced = [row, col]
if self.ai is None:
self.current_player = FieldState(3 - self.current_player.value)
elif self.gnugo is not None:
ai_color = self.colormap[self.ai.uuid].name.lower()
ai_resp = self._gtp(f'genmove_{ai_color}')
if 'pass' in ai_resp.lower():
+ self._lastplaced = [-1, -1]
if self.colormap[self.ai.uuid] == FieldState.BLACK:
self.black_passed = True
else:
@@ -220,6 +224,19 @@ Press Play! to play against GNU Go or invite a second player.
else:
self.black_passed = False
self.white_passed = False
+ move = ai_resp.split()[1]
+ x = move[0]
+ y = move[1:]
+ print(x, y)
+ try:
+ row = int(y) - 1
+ col = self.colnames.index(x.upper())
+ if col is None:
+ self._lastplaced = [-1, -1]
+ else:
+ self._lastplaced = [row, col]
+ except:
+ self._lastplaced = [-1, -1]
self.update_field()
def update_field(self):
@@ -271,6 +288,7 @@ Press Play! to play against GNU Go or invite a second player.
field=ser['field'],
territory=ser['territory'],
captures=ser['captures'],
+ lastplaced=self._lastplaced,
passed=[self.white_passed, self.black_passed],
boardsize=self.size.value,
colormap=self.colormap,