Exemple #1
0
def random_maze(n=25):
    G = models.my_grid_graph([n,n])

    T = nx.minimum_spanning_tree(G)
    P = models.my_path_graph(nx.shortest_path(T, (0,0), (n-1, n-1)))

    D = models.dual_grid(G, T)
    views.add_maze_boundary(D, [n, n])
    views.make_entry_and_exit(D, [n, n])
    pos = views.layout_maze(D, fast=True)
    views.plot_maze(D, pos, P, G.pos)
Exemple #2
0
def random_maze(n=25):
    G = models.my_grid_graph([n, n])

    T = nx.minimum_spanning_tree(G)
    P = models.my_path_graph(nx.shortest_path(T, (0, 0), (n - 1, n - 1)))

    D = models.dual_grid(G, T)
    views.add_maze_boundary(D, [n, n])
    views.make_entry_and_exit(D, [n, n])
    pos = views.layout_maze(D, fast=True)
    views.plot_maze(D, pos, P, G.pos)
Exemple #3
0
def ld_maze(n=25):
    """ having many low-degree vertices makes for hard mazes

    unfortunately, finding them is slow"""

    # start with an nxn square grid
    G = models.my_grid_graph([n,n])

    # make a pymc model of a low-degree spanning tree on this
    T = models.LDST(G, beta=10)
    mod_mc = mc.MCMC([T])
    mod_mc.use_step_method(models.STMetropolis, T)
    mod_mc.sample(100, burn=99)
    T = T.value

    P = models.my_path_graph(nx.shortest_path(T, (0,0), (n-1, n-1)))

    D = models.dual_grid(G, T)
    views.add_maze_boundary(D, [n,n])
    views.make_entry_and_exit(D, [n,n])
    D = views.split_edges(D)
    D = views.split_edges(D)
    D_pos = views.layout_maze(D, fast=False)
    views.plot_maze(D, D_pos, P, G.pos)
Exemple #4
0
def ld_maze(n=25):
    """ having many low-degree vertices makes for hard mazes

    unfortunately, finding them is slow"""

    # start with an nxn square grid
    G = models.my_grid_graph([n, n])

    # make a pymc model of a low-degree spanning tree on this
    T = models.LDST(G, beta=10)
    mod_mc = mc.MCMC([T])
    mod_mc.use_step_method(models.STMetropolis, T)
    mod_mc.sample(100, burn=99)
    T = T.value

    P = models.my_path_graph(nx.shortest_path(T, (0, 0), (n - 1, n - 1)))

    D = models.dual_grid(G, T)
    views.add_maze_boundary(D, [n, n])
    views.make_entry_and_exit(D, [n, n])
    D = views.split_edges(D)
    D = views.split_edges(D)
    D_pos = views.layout_maze(D, fast=False)
    views.plot_maze(D, D_pos, P, G.pos)
Exemple #5
0
 def setup(self):
     self.G = model.my_grid_graph([5, 5])
Exemple #6
0
 def setup(self):
     self.G = model.my_grid_graph([5, 5])