예제 #1
0
    def test_SwapMany(self):
        gameState = GameState()

        gameState.board = self.InitilizeGameStateBoard()
        gameState.stoneGroups = self.InitializeGameStateStoneGroups()
        gameState.turn = 'W'

        newGameState = gameState.Result((2, 4))
        expectedBoardAfterMove = [
            ['B', None, 'W', 'B', 'W'],
            ['W', 'W', 'B', None, None],
            [None, None, None, None, 'W'],
            ['W', 'W', 'W', 'W', 'W'],
            ['B', 'W', 'W', 'W', 'W']
        ]

        expectedGroupAfterMove = {(2, 4), (3, 0), (3, 1), (3, 2), (3, 3), (3, 4), (4, 1), (4, 2), (4, 3), (4, 4)}

        for rowIndex, row in enumerate(newGameState.board):
            for colIndex, stone in enumerate(row):
                assert(stone == expectedBoardAfterMove[rowIndex][colIndex])

        for stone in newGameState.stoneGroups[(4, 1)]:
            assert((stone in expectedGroupAfterMove) == True)
        for stone in expectedGroupAfterMove:
            assert((stone in newGameState.stoneGroups[(4, 1)]) == True)

        for stone in newGameState.stoneGroups[(2, 4)]:
            assert((stone in expectedGroupAfterMove) == True)
        for stone in expectedGroupAfterMove:
            assert((stone in newGameState.stoneGroups[(2, 4)]) == True)
예제 #2
0
    def test_UpdateStoneCount(self):
        gameState = GameState()

        gameState.board = self.InitilizeGameStateBoard()
        gameState.stoneGroups = self.InitializeGameStateStoneGroups()
        gameState.UpdateGameStateVariables()
        assert(gameState.Utility() == (8-9))
        assert(gameState.turn == 'W')
예제 #3
0
    def test_GetActions(self):
        gameState = GameState()

        gameState.board = self.InitilizeGameStateBoard()
        gameState.stoneGroups = self.InitializeGameStateStoneGroups()
        actions = gameState.GetActions()

        expected = {(1, 3), (1, 4), (2, 0), (2, 1), (2, 2), (2, 3), (2, 4), "pass"}
        assert(((0, 1) in actions) == False)
        assert(((1, 3) in actions) == True)

        for e in expected:
            assert((e in actions) == True)
        for k in actions:
            assert ((k in expected) == True)