def db_reset_mazes(): db = get_db() # generate entrance db["mazes"].remove({}) db["mazes_id"].remove({}) maze = generator.generate_maze(21, 21, {}) print("Maze generated") for y in range(0, maze["y"]): string = [] for x in range(0, maze["x"]): if x == maze["start_x"] and y == maze["start_y"]: string.append("@") elif is_passable(maze["structure"][x][y]): string.append(" ") else : string.append("#") print("".join(string)) print("StartX: " + str(maze["start_x"])) print("StartY: " + str(maze["start_y"])) db_add_maze(maze, "entrance")
passable = mazedef.get_passable_direction(maze, traverser["x"], traverser["y"], mazedef.can_pass_through) stack.append( { "node" : new_node, "N" : passable[NORTH], "S" : passable[SOUTH], "E" : passable[EAST], "W" : passable[WEST] }) return nodes if __name__ == "__main__" : if len(sys.argv) > 1: if sys.argv[1] == "?" : seedValue = random.randint(0, 1000000) print("".join(["Seed : ", str(seedValue)])) else: seedValue = int(sys.argv[1]) random.seed(seedValue) maze = generator.generate_maze(7, 7) for y in range(0, maze["y"]): string = [] for x in range(0, maze["x"]): if x == maze["start_x"] and y == maze["start_y"]: string.append("@") elif mazedef.is_wall(maze["structure"][x][y]): string.append("#") else : string.append(" ") print("".join(string)) print("StartX: " + str(maze["start_x"])) print("StartY: " + str(maze["start_y"])) # graph = generate_graph(maze)
import sys from mazehack.mazedef import is_wall from mazehack.generator import generate_maze, get_random_variable_position from mazehack.navigator import run_instructions from mazehack.navigator import compile import json import random if __name__ == "__main__": if len(sys.argv) < 4: print("print_maze width height seed") print("Enter ? for random seed") else: width = int(sys.argv[1]) height = int(sys.argv[2]) seed = random.randint(0, 1000000) if sys.argv[3] == "?" else int(sys.argv[3]) loop = int(sys.argv[4]) if len(sys.argv) > 4 else 0 random.seed(seed) maze = generate_maze(width, height, {"loop" : loop}) for y in range(0, maze["y"]): string = [] for x in range(0, maze["x"]): if is_wall(maze["structure"][x][y]): string.append("#") else : string.append(" ") print("".join(string))
import json import random if __name__ == "__main__": if len(sys.argv) < 3: print "python test.py <seed> <instructions>" print "enter ? for seed to get a random seed" else: try: if sys.argv[1] == "?" : seedValue = random.randint(0, 1000000) print("".join(["Seed : ", str(seedValue)])) else: seedValue = int(sys.argv[1]) random.seed(seedValue) # d = generate_maze(31, 31) d = generate_maze(21, 21, {"holes" : 30}) e = json.dumps(d) maze = json.loads(e) if len(sys.argv) > 3 and sys.argv[3] == "DEBUG": for y in range(0, maze["y"]): string = [] for x in range(0, maze["x"]): if x == maze["start_x"] and y == maze["start_y"]: string.append("@") elif is_wall(maze["structure"][x][y]): string.append("#") else : string.append(" ") print("".join(string)) print("StartX: " + str(maze["start_x"])) print("StartY: " + str(maze["start_y"]))