Ejemplo n.º 1
0
from Algorithms.AldousBroder import AldousBroder
from Algorithms.Wilsons import Wilsons
from Algorithms.HuntAndKill import HuntAndKill

algorithms = [BinaryTree, Sidewinder, AldousBroder, Wilsons, HuntAndKill]

tries = 100
size = 20

averages = {}
for alg in algorithms:
    print("Running:  " + str(alg))
    dead_counts = []
    for i in range(0, tries):
        thing = alg()
        grid = thing.on(Grid(size, size))
        dead_counts.append(grid.deadends())
    total_dead = 0
    for i in range(0, len(dead_counts)-1):
        total_dead += dead_counts[i]
    averages[alg] = round(total_dead/grid.size)

total_cells = size*size
print()
print("Average dead-ends per " + str(size) + "x" + str(size) + " maze")
print()

#sorted_algs = sorted(algorithms)

for alg in algorithms:
    percentage = (averages[alg]*100.0)/total_cells
Ejemplo n.º 2
0
from Algorithms.HuntAndKill import HuntAndKill as hk
from Foundations.Grid import Grid

jeremy = hk()

grid = jeremy.on(Grid(20, 20))

img = grid.to_png()

img.save("Output\hk1.png")
Ejemplo n.º 3
0
from Foundations.Grid import Grid
from Algorithms.AldousBroder import AldousBroder

lester = AldousBroder()
grid = lester.on(Grid(10, 10))

# print(grid)

img = grid.to_png()
img.save("Output\mazeimage.png")
Ejemplo n.º 4
0
from Foundations.Grid import Grid
from Algorithms.Sidewinder import Sidewinder
import random

larry = Sidewinder()

grid = larry.on(Grid(5, 5))

print(grid)
Ejemplo n.º 5
0
from Foundations.Grid import Grid
from Algorithms.BinaryTree import BinaryTree
import random

larry = BinaryTree()

grid = larry.on(Grid(5, 8))

print(grid)
Ejemplo n.º 6
0
from Algorithms.RecursiveBacktracker import RecursiveBacktracker
from Foundations.Grid import Grid

sylvester = RecursiveBacktracker()

grid = sylvester.on(Grid(20, 20))

img = grid.to_png()
img.save('Output\\recursive.png')
Ejemplo n.º 7
0
from Algorithms.Wilsons import Wilsons
from Foundations.Grid import Grid

wilson = Wilsons()

grid = wilson.on(Grid(20, 20))

img = grid.to_png()

img.save("Output\wilson.png")