Beispiel #1
0
    def test_valid_moves_considers_player_turn(self):
        game = Game()
        game.turn = "black"

        # Remove existing black pieces
        game._board._board[:, :2] = EmptyPiece()
        game._board._board[0, 3] = Piece("black", None)

        assert game.valid_moves() == ["2-6", "2-7"]
Beispiel #2
0
    def test_other_play_wins_if_no_valid_moves(self):
        game = Game()
        game.reset()
        game.valid_moves = mock.Mock(return_value=[])

        assert game.game_over()
        assert game.result == "black"

        game.turn = "black"
        assert game.game_over()
        assert game.result == "white"
Beispiel #3
0
    def test_that_reset_resets_game(self):
        game = Game()
        game._board._board[5, 4] = Piece("white", None)
        game._move_list = [1, 2, 3, 4]
        game.turn = "black"
        game._pieces_remaining = {"white": 5, "black": 6}

        game.reset()

        assert np.array_equal(game._board._board, new_board)
        assert game._move_list == []
        assert game.turn == "white"
        assert game._pieces_remaining == {"white": 8, "black": 8}