Player position is always a valid move.
authorJeremy Thurgood <firxen@gmail.com>
Thu, 15 May 2014 07:33:17 +0000 (09:33 +0200)
committerJeremy Thurgood <firxen@gmail.com>
Thu, 15 May 2014 07:33:17 +0000 (09:33 +0200)
naja/player.py
naja/tests/test_actions.py
naja/tests/test_player.py

index 2156a3665c8f64e21452f5e8bffd6b1750bc8146..00e6133ed720486bd19d878136abcdcd5087b86a 100644 (file)
@@ -93,7 +93,7 @@ class Player(object):
         return False
 
     def legal_moves(self):
-        positions = []
+        positions = [self.position]
         for direction in [BITS.NORTH, BITS.SOUTH, BITS.EAST, BITS.WEST]:
             position = self.get_adjacent_position(direction)
             if position is not None and self.bits.check_bit(direction):
index d903648cc626914e96aab9940ae7cbf57441e892..02c07964342df9f4d06ee6c7cca4427d49e62edd 100644 (file)
@@ -129,7 +129,7 @@ class TestActions(TestCase):
 
     def test_AcquireWinToken(self):
         board = self.make_board(
-            player_bits=[BITS.CYAN, BITS.MAGENTA, BITS.YELLOW, BITS.MSB])
+            player_bits=[BITS.CYAN, BITS.MAGENTA, BITS.YELLOW])
         state_before = board.export()
         actions.AcquireWinToken(set()).perform_action(board, None)
         state_after = board.export()
index cbae8cc23c03580a14f26f9f9043a90ba124b680..31cc8173395b53d7ae9a6147d06938a0e20cb6a9 100644 (file)
@@ -161,9 +161,9 @@ class TestPlayer(TestCase):
     def test_legal_moves_all_available(self):
         player = Player(0x0f, (2, 2))
         self.assertEqual(
-            player.legal_moves(), [(2, 1), (2, 3), (3, 2), (1, 2)])
+            player.legal_moves(), [(2, 2), (2, 1), (2, 3), (3, 2), (1, 2)])
 
     def test_legal_moves_some_unavailable(self):
         player = Player(0x0f, (0, 2))
         player.bits.clear_bit(BITS.NORTH)
-        self.assertEqual(player.legal_moves(), [(0, 3), (1, 2)])
+        self.assertEqual(player.legal_moves(), [(0, 2), (0, 3), (1, 2)])