コード例 #1
0
    def test_get_state(self):
        goban = Goban((2, 2))
        state = GameState(goban)

        self.assertEqual(state.get_state((1, 1)), GameState.FREE)

        state._state[(1, 1)] = GameState.WHITE
        self.assertEqual(state.get_state((1, 1)), GameState.WHITE)
コード例 #2
0
    def test_move(self):
        goban = Goban((2, 2))
        state = GameState(goban)

        state.make_move((1, 1))
        self.assertEqual(state.get_state((1, 1)), GameState.BLACK)
        self.assertEqual(state._turn, GameState.GREY)

        for point in ((2, 3), (1, 1)):
            with self.assertRaises(ValueError):
                state.make_move(point)
コード例 #3
0
    def test_catch_group(self):
        goban = Goban((5, 5))
        state = GameState(goban)

        state._state[(1, 1)] = GameState.BLACK
        self.assertEqual(state.catch_group((1, 1)), 1)
        self.assertEqual(state.get_state((1, 1)), GameState.FREE)

        string = '''
        XXX..
        XXX..
        .....
        .....
        .....
        '''
        state = GameState.convert_string_to_state(string, '\n        ')
        self.assertEqual(state.catch_group((1, 1)), 6)

        for x in range(0, 3):
            for y in range(0, 2):
                self.assertEqual(state.get_state((x, y)), GameState.FREE)