def test_empty_spaces_empty():
    """Check that the correct number of empty spaces are returned for an empty
    board.
    """
    n = 4
    board = Board(size=n)

    empty_spaces = board.get_empty_spaces()
    assert len(empty_spaces) == 3 * n**2 - 3 * n + 1
def test_empty_spaces_full():
    """Check that the correct number of empty spaces are returned for a
    full board.
    """
    n = 4
    board = Board(size=n)

    board.board_2d = np.ones(board.board_2d.shape)

    empty_spaces = board.get_empty_spaces()
    assert len(empty_spaces) == 0
def test_empty_spaces_partial():
    """Check that the correct number of empty spaces are returned for a
    partially filled board.
    """
    n = 4
    board = Board(size=n)

    board.board_2d[3, 3] = 1

    empty_spaces = board.get_empty_spaces()
    assert len(empty_spaces) == 3 * n**2 - 3 * n
def test_get_legal_moves():
    """Check that the function generates all possible moves when the board is
    empty.
    """
    board = Board()

    empty_spaces = board.get_empty_spaces()
    legal_moves = board.get_legal_moves(player=0)

    for space in empty_spaces:
        q, r = space
        assert ((q, r, 1), ()) in legal_moves
        assert ((q, r, 2), ()) in legal_moves

    for (space1, space2) in permutations(empty_spaces, r=2):
        assert ((space1[0], space1[1], 1), (space2[0], space2[1],
                                            2)) in legal_moves