Add lastplaced
This commit is contained in:
parent
c6cf6db756
commit
a1373bafbf
2 changed files with 26 additions and 2 deletions
|
@ -48,8 +48,14 @@
|
||||||
<circle id="go-stone-{{ row }}-{{ col }}-empty" class="go-stone go-stone-empty go-stone-{{ colormap[player.uuid].name.lower() }}" data-row="{{ row }}" data-col="{{ col }}" cx="{{ col * 50 + 25 }}" cy="{{ row * 50 + 25 }}" r="20" />
|
<circle id="go-stone-{{ row }}-{{ col }}-empty" class="go-stone go-stone-empty go-stone-{{ colormap[player.uuid].name.lower() }}" data-row="{{ row }}" data-col="{{ col }}" cx="{{ col * 50 + 25 }}" cy="{{ row * 50 + 25 }}" r="20" />
|
||||||
{% elif field[row][col] == 1 %}
|
{% elif field[row][col] == 1 %}
|
||||||
<circle id="go-stone-{{ row }}-{{ col }}-white" class="go-stone go-stone-white" cx="{{ col * 50 + 25 }}" cy="{{ row * 50 + 25 }}" r="20" />
|
<circle id="go-stone-{{ row }}-{{ col }}-white" class="go-stone go-stone-white" cx="{{ col * 50 + 25 }}" cy="{{ row * 50 + 25 }}" r="20" />
|
||||||
|
{% if lastplaced[0] == row and lastplaced[1] == col and score is none %}
|
||||||
|
<rect class="go-territory go-territory-black" x="{{ col * 50 + 20 }}" y="{{ row * 50 + 20 }}" width="10" height="10" />
|
||||||
|
{% endif %}
|
||||||
{% elif field[row][col] == 2 %}
|
{% elif field[row][col] == 2 %}
|
||||||
<circle id="go-stone-{{ row }}-{{ col }}-black" class="go-stone go-stone-black" cx="{{ col * 50 + 25 }}" cy="{{ row * 50 + 25 }}" r="20" />
|
<circle id="go-stone-{{ row }}-{{ col }}-black" class="go-stone go-stone-black" cx="{{ col * 50 + 25 }}" cy="{{ row * 50 + 25 }}" r="20" />
|
||||||
|
{% if lastplaced[0] == row and lastplaced[1] == col and score is none %}
|
||||||
|
<rect class="go-territory go-territory-white" x="{{ col * 50 + 20 }}" y="{{ row * 50 + 20 }}" width="10" height="10" />
|
||||||
|
{% endif %}
|
||||||
{% elif field[row][col] == 5 %}
|
{% elif field[row][col] == 5 %}
|
||||||
<circle id="go-stone-{{ row }}-{{ col }}-white-dead" class="go-stone go-stone-dead go-stone-white" cx="{{ col * 50 + 25 }}" cy="{{ row * 50 + 25 }}" r="20" />
|
<circle id="go-stone-{{ row }}-{{ col }}-white-dead" class="go-stone go-stone-dead go-stone-white" cx="{{ col * 50 + 25 }}" cy="{{ row * 50 + 25 }}" r="20" />
|
||||||
{% elif field[row][col] == 6 %}
|
{% elif field[row][col] == 6 %}
|
||||||
|
@ -91,8 +97,8 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if game.is_completed %}
|
{% if abandoned or score is not none %}
|
||||||
<a href="{{ baseurl }}/{{ me.uuid }}">Return to lobby</a>
|
<a href="{{ baseurl }}/{{ player.uuid }}">Return to lobby</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
<a href="{{ baseurl }}/{{ player.uuid }}/{{ game.uuid }}/play">Refresh</a>
|
<a href="{{ baseurl }}/{{ player.uuid }}/{{ game.uuid }}/play">Refresh</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
|
@ -53,6 +53,7 @@ class GoPuzzle(Puzzle):
|
||||||
self._timer = None
|
self._timer = None
|
||||||
self._tlock = Lock()
|
self._tlock = Lock()
|
||||||
self._captures = [0, 0]
|
self._captures = [0, 0]
|
||||||
|
self._lastplaced = [-1, -1]
|
||||||
self._urlbase = '/'
|
self._urlbase = '/'
|
||||||
|
|
||||||
def _gtp(self, command):
|
def _gtp(self, command):
|
||||||
|
@ -189,6 +190,7 @@ Press Play! to play against GNU Go or invite a second player.
|
||||||
self._timer.start()
|
self._timer.start()
|
||||||
move = action['go-input-submit']
|
move = action['go-input-submit']
|
||||||
if move == 'Pass':
|
if move == 'Pass':
|
||||||
|
self._lastplaced = [-1, -1]
|
||||||
if self.current_player == FieldState.BLACK:
|
if self.current_player == FieldState.BLACK:
|
||||||
self.black_passed = True
|
self.black_passed = True
|
||||||
else:
|
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}')
|
ret = self._gtp(f'play {player} {self.colnames[col]}{row+1}')
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
return
|
return
|
||||||
|
self._lastplaced = [row, col]
|
||||||
if self.ai is None:
|
if self.ai is None:
|
||||||
self.current_player = FieldState(3 - self.current_player.value)
|
self.current_player = FieldState(3 - self.current_player.value)
|
||||||
elif self.gnugo is not None:
|
elif self.gnugo is not None:
|
||||||
ai_color = self.colormap[self.ai.uuid].name.lower()
|
ai_color = self.colormap[self.ai.uuid].name.lower()
|
||||||
ai_resp = self._gtp(f'genmove_{ai_color}')
|
ai_resp = self._gtp(f'genmove_{ai_color}')
|
||||||
if 'pass' in ai_resp.lower():
|
if 'pass' in ai_resp.lower():
|
||||||
|
self._lastplaced = [-1, -1]
|
||||||
if self.colormap[self.ai.uuid] == FieldState.BLACK:
|
if self.colormap[self.ai.uuid] == FieldState.BLACK:
|
||||||
self.black_passed = True
|
self.black_passed = True
|
||||||
else:
|
else:
|
||||||
|
@ -220,6 +224,19 @@ Press Play! to play against GNU Go or invite a second player.
|
||||||
else:
|
else:
|
||||||
self.black_passed = False
|
self.black_passed = False
|
||||||
self.white_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()
|
self.update_field()
|
||||||
|
|
||||||
def update_field(self):
|
def update_field(self):
|
||||||
|
@ -271,6 +288,7 @@ Press Play! to play against GNU Go or invite a second player.
|
||||||
field=ser['field'],
|
field=ser['field'],
|
||||||
territory=ser['territory'],
|
territory=ser['territory'],
|
||||||
captures=ser['captures'],
|
captures=ser['captures'],
|
||||||
|
lastplaced=self._lastplaced,
|
||||||
passed=[self.white_passed, self.black_passed],
|
passed=[self.white_passed, self.black_passed],
|
||||||
boardsize=self.size.value,
|
boardsize=self.size.value,
|
||||||
colormap=self.colormap,
|
colormap=self.colormap,
|
||||||
|
|
Loading…
Reference in a new issue