Fixed a few bugs - stones can now be placed, but captures aren't working right

This commit is contained in:
Anna Rose 2012-04-13 16:59:05 -04:00
parent 1474af0e5f
commit 7652ddd596

View File

@ -50,8 +50,6 @@ class Goban:
if not self._valid_move(rpos): if not self._valid_move(rpos):
return return
# fixme - update the GRAY status of affected squares
self.board[rpos] = self.to_move self.board[rpos] = self.to_move
self._capture(rpos) self._capture(rpos)
@ -81,8 +79,8 @@ class Goban:
return False return False
# Can't play atop another stone # Can't play atop another stone
if self.board[pos] == Goban.EMPTY: if self.board[pos] != Goban.EMPTY:
return True return False
# Temporarily place the stone # Temporarily place the stone
self.board[pos] = self.to_move self.board[pos] = self.to_move
@ -113,7 +111,7 @@ class Goban:
return 0 return 0
if checked is None: if checked is None:
bs = board_size * board_size bs = self.board_size * self.board_size
checked = [False] * bs checked = [False] * bs
if checked[pos]: if checked[pos]:
@ -156,7 +154,6 @@ class Goban:
self.board[x][y].state = Goban.EMPTY self.board[x][y].state = Goban.EMPTY
# fixme - needs to be evaluated with new data model
def _delete_group_r(self, pos, who): def _delete_group_r(self, pos, who):
if not self._on_board(pos): if not self._on_board(pos):
return return
@ -187,9 +184,9 @@ class Goban:
if point == Goban.EMPTY: if point == Goban.EMPTY:
s = img_res[self.def_draw_codes[pos]] s = img_res[self.def_draw_codes[pos]]
elif point == Goban.BLACK: elif point == Goban.BLACK:
s = img_res('b') s = img_res['b']
elif point == Goban.WHITE: elif point == Goban.WHITE:
s = img_res('w') s = img_res['w']
s = pygame.transform.scale(s, (inc, inc)) s = pygame.transform.scale(s, (inc, inc))
ret.blit(s, ((pos % self.board_size) *inc, (pos / self.board_size) *inc)) ret.blit(s, ((pos % self.board_size) *inc, (pos / self.board_size) *inc))
@ -263,7 +260,7 @@ class Goban:
def _on_board(self, pos): def _on_board(self, pos):
return pos < 0 or pos > self.board_size * self.board_size - 1 return pos >= 0 or pos < self.board_size * self.board_size
def _other_color(self, color): def _other_color(self, color):