Permalink
Browse files

[game] Fixed game over condition. It was totally freaking wrong

  • Loading branch information...
Yaroslav Shirokov Yaroslav Shirokov
Yaroslav Shirokov authored and Yaroslav Shirokov committed Nov 15, 2010
1 parent d3aaaa7 commit 394f3c079bce1c766368303fd2b9e2ec3b053a5a
Showing with 5 additions and 1 deletion.
  1. +1 −1 gogogo/__init__.py
  2. +4 −0 tests.py
View
@@ -270,7 +270,7 @@ def move(self, *args, **kwargs):
@property
def game_over(self):
if len(self.moves) >= 2:
- return reduce(lambda acc, i: acc and i.passing, self.moves[:-2], True)
+ return reduce(lambda acc, i: acc and i.passing, self.moves[-2:], True)
return False
def sign(self):
View
@@ -256,6 +256,10 @@ def test_turn_must_not_recreate_prior_state(self):
def test_game_ends_after_two_consecutive_passes(self):
+ self.assertFalse(self.board.game_over, "Game should not be over before it starts")
+ self.board.move(1, 1)
+ self.board.move(2, 2)
+ self.assertFalse(self.board.game_over, "Game should not be over before after some moves")
m = self.board.move(None)
self.assertTrue(m, "Black can pass")
m = self.board.move(None)

0 comments on commit 394f3c0

Please sign in to comment.