Esempio n. 1
0
 def setUpClass(self):
     #       # 0 1 2 3 4 5 6 7 #  #
     grid = (' . . . . . . . . '  # 0
             ' . . . . . . . . '  # 1
             ' . . . . . . . . '  # 2
             ' . . . ● ○ . . . '  # 3
             ' . . . ○ ● . . . '  # 4
             ' . . . . . . . . '  # 5
             ' . . . . . . . . '  # 6
             ' . . . . . . . . ')  #7
     self.grid_dark = Reversi(hash_grid(to_grid(grid), player=0))
     self.grid_light = Reversi(hash_grid(to_grid(grid), player=1))
Esempio n. 2
0
 def test_move_on_occupied_cell(self):
     #       # 0 1 2 3 4 5 6 7 #  #
     grid = (
         " . . . . . . . . "  # 0
         " . . . . . . . . "  # 1
         " . . . . . . . . "  # 2
         " . . . ○ ● . . . "  # 3
         " . . . ● ○ . . . "  # 4
         " . . . . . . . . "  # 5
         " . . . . . . . . "  # 6
         " . . . . . . . . "
     )  # 7
     #      #  0 1 2 3 4 5 6 7    #
     player, move = 1, (3, 3)
     game_state = Reversi(hash_grid(to_grid(grid), player))
     self.assertRaises(IndexError, game_state.result, move)
Esempio n. 3
0
 def assertIdentical(self, expected, grid_str):
     grid = to_grid(grid_str)
     self.assertHashes(expected, grid)
     self.assertReverseHashes(expected, grid)
Esempio n. 4
0
 def assertLight(self, expected, grid_str, player=1):
     game_state = Reversi(hash_grid(to_grid(grid_str), player))
     self.assertEqual(expected, game_state.find_actions())
Esempio n. 5
0
 def assertValue(self, expected, grid_str):
     game_state = Reversi(hash_grid(to_grid(grid_str)))
     self.assertEqual(expected, game_state.utility())
Esempio n. 6
0
 def assertResultsIn(self, expd_str, expd_player, grid_str, player, move):
     game_state_before = Reversi(hash_grid(to_grid(grid_str), player))
     game_state_after = Reversi(hash_grid(to_grid(expd_str), expd_player))
     result_state = Reversi(game_state_before.result(move))
     self.assertEqual(result_state.grid, game_state_after.grid)
     self.assertEqual(result_state.player, expd_player)