Пример #1
0
def test_is_fenced_edge():
    """Check that the function correctly classifies a fenced bloom at the edge
    of the board.
    """
    board = Board()

    # Add a bloom
    bloom = [(6, 3), (5, 4)]
    for position in bloom:
        board.place_stone(position, colour=1)

    # Fence the bloom
    for position in bloom:
        neighbours = board.get_neighbours(position)
        for neighbour in neighbours:
            if board.is_empty_space(neighbour):
                board.place_stone(neighbour, colour=2)

    assert board.is_fenced(bloom)
Пример #2
0
def test_is_fenced_false():
    """Check that the function correctly classifies a non-fenced bloom.
    """
    board = Board()

    # Add a bloom
    bloom = [(3, 2), (3, 3), (3, 4), (4, 3)]
    for position in bloom:
        board.place_stone(position, colour=1)

    # Fence the bloom
    for position in bloom:
        neighbours = board.get_neighbours(position)
        for neighbour in neighbours:
            if board.is_empty_space(neighbour):
                board.place_stone(neighbour, colour=2)

    # Remove one of the stones fencing in the bloom
    board.remove_stone(position=(4, 4))

    assert not board.is_fenced(bloom)