Exemplo n.º 1
0
    def test_go_for_win(self):

        gameState = [
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 1, 0, 0, 0, 0,-1],
            [ 0, 1, 0, 0, 0, 0,-1],
            [ 0, 1, 0, 0, 0,-1,-1]
        ]
        move = connect4.bestMove(gameState, self.player, self.opponent)
        self.assertEqual(move, 1)
Exemplo n.º 2
0
    def test_prevent_defeat(self):

        gameState = [
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0, 0],
            [ 0, 0, 0, 0, 0, 0,-1],
            [ 1, 0, 0, 0, 0, 0,-1],
            [ 1, 0, 0, 0, 0, 0,-1]
        ]
        move = connect4.bestMove(gameState, self.player, self.opponent)
        self.assertEqual(move, 6)