コード例 #1
0
ファイル: test_graph.py プロジェクト: kkris/wheatley
def test_split_extended_islands():

    board = graph.Board.from_string(g_sub)
    g = graph.Graph.from_board(board)

    walkable = graph.make_walkable(g)

    extended_islands = graph.split_into_extended_islands(walkable)


    assert len(extended_islands) == 3
    for island in extended_islands:
        if island.get_node(0, 0) is not None:
            assert len(island.nodes) == 3
        elif island.get_node(4, 0) is not None:
            island2 = island
            assert len(island.nodes) == 3
        elif island.get_node(4, 2) is not None:
            island3 = island
            assert len(island.nodes) == 7


    assert island2.get_node(4, 1) is not None
    assert island3.get_node(4, 1) is not None

    assert island2.get_node(3, 1) is None
    assert island3.get_node(3, 1) is not None
コード例 #2
0
ファイル: test_graph.py プロジェクト: kkris/wheatley
def test_split_extended_islands_big():

    board = graph.Board.from_string(g_big_cluttered)
    g = graph.Graph.from_board(board)

    walkable = graph.make_walkable(g)

    extended_islands = graph.split_into_extended_islands(walkable)

    assert len(extended_islands) == len(graph.split_into_subgraphs(graph.make_dry(g)))

    for island in extended_islands:
        if island.get_node(18, 6) is not None:
            assert len(island.nodes) == 5
            assert island.get_node(19, 6) is not None
            assert island.get_node(19, 5) is not None
            assert island.get_node(19, 4) is not None
            assert island.get_node(20, 4) is not None

        if island.get_node(5, 9) is not None:
            node = island.get_node(5, 9)
            assert node.distance_to_land == 3

        if island.get_node(8, 9) is not None:
            assert island.get_node(5, 9) is not None
        if island.get_node(5, 13) is not None:
            assert island.get_node(5, 9) is not None

        if island.get_node(17, 2) is not None:
            assert island.get_node(18, 2) is not None
        if island.get_node(18, 1) is not None:
            assert island.get_node(18, 2) is not None
        if island.get_node(19, 2) is not None:
            assert island.get_node(18, 2) is not None


        if island.get_node(30, 3)  is not None:
            assert island.get_node(4, 1) is None
        if island.get_node(4, 1) is not None:
            assert island.get_node(30, 3) is None

        assert island.get_node(31, 0) is None
コード例 #3
0
ファイル: strategies.py プロジェクト: kkris/wheatley
    def split_graph_into_extended_islands(self, graph):

        self.extended_islands = split_into_extended_islands(graph)