Beispiel #1
0
 def test_picks_the_first_pot_with_most_stones_from_legal_moves_available(
         self):
     mancala_mock = mock.Mock()
     mancala_mock.game_board_log = [[[0, 13, 21, 0, 5, 5],
                                     [0, 0, 0, 0, 0, 0], [14, 6]]]
     mancala_mock.get_legal_moves.return_value = [2, 3, 5, 6]
     player = Player(1, "potwithmost", mancala_mock)
     player.play()
     mancala_mock.play.assert_called_with(1, 3)
Beispiel #2
0
 def test_picks_the_first_pot_with_most_stones_from_legal_moves_available_when_game_has_not_ended(
         self):
     mancala_mock = mock.Mock()
     mancala_mock.game_board_log = [[[5, 4, 4, 0, 5, 5], [5, 4, 4, 0, 5, 5],
                                     [1, 1]]]
     mancala_mock.get_legal_moves.return_value = [1, 2, 3, 5, 6]
     player = Player(1, "potwithmost", mancala_mock)
     player.play()
     mancala_mock.play.assert_called_with(1, 1)
Beispiel #3
0
 def test_picks_random_pot_if_all_legal_moves_give_extra_turn_(
         self, choice_mock):
     mancala_mock = mock.Mock()
     mancala_mock.game_board_log = [[[0, 5, 4, 3, 2, 1],
                                     [4, 0, 3, 0, 16, 0], [3, 16]]]
     mancala_mock.get_legal_moves.return_value = [2, 3, 5, 6]
     player = Player(1, "avoidanotherturn", mancala_mock)
     player.play()
     mancala_mock.play.assert_called_with(1, 1)
Beispiel #4
0
 def test_picks_the_pot_which_does_not_give_an_extra_turn_from_legal_moves_available(
         self):
     mancala_mock = mock.Mock()
     mancala_mock.game_board_log = [[[0, 5, 19, 3, 2, 1],
                                     [0, 0, 3, 5, 1, 0], [3, 16]]]
     mancala_mock.get_legal_moves.return_value = [2, 3, 4, 5, 6]
     player = Player(1, "avoidanotherturn", mancala_mock)
     player.play()
     mancala_mock.play.assert_called_with(1, 3)
Beispiel #5
0
    def test_move_is_made_in_mancala(self, choice_mock):
        mancala_mock = mock.Mock()
        mancala_mock.get_legal_moves.return_value = [3, 4, 5, 6]
        mancala_mock.play.return_value = True
        player = Player(1, "random", mancala_mock)

        assert player.play() == True
        mancala_mock.play.assert_called_with(1, 5)
Beispiel #6
0
    def test_monte_carlo_tree_search(self):
        # mcts_mock.play.return_value = 4

        with mock.patch('mancala.mcts.MCTS.play') as mocked_mcts_play:
            mancala_mock = mock.Mock()
            mancala_mock.game_board_log = [[[4, 5, 4, 3, 2, 1],
                                            [4, 0, 3, 0, 16, 0], [3, 16]]]
            mancala_mock.get_legal_moves.return_value = [1, 2, 3, 4, 5, 6]

            player = Player(1, "mcts", mancala_mock)
            assert player.play() == 4
Beispiel #7
0
 def test_picks_the_leftmost_pot_from_legal_moves_available(self):
     mancala_mock = mock.Mock()
     mancala_mock.get_legal_moves.return_value = [1, 4, 6]
     player = Player(1, "leftpot", mancala_mock)
     player.play()
     mancala_mock.play.assert_called_with(1, 1)
Beispiel #8
0
 def test_picks_a_random_pot_from_legal_moves_available(self, choice_mock):
     mancala_mock = mock.Mock()
     mancala_mock.get_legal_moves.return_value = [1, 6]
     player = Player(1, "random", mancala_mock)
     player.play()
     choice_mock.assert_called_with([1, 6])
Beispiel #9
0
 def test_creates_a_new_mancala_instance_with_correct_params(
         self, choice_mock):
     mancala_mock = mock.Mock()
     player = Player(1, "random", mancala_mock)
     player.play()
     mancala_mock.get_legal_moves.assert_called_with(1)