Skip to content

Instantly share code, notes, and snippets.

@obviyus
Created September 18, 2019 13:41
Show Gist options
  • Save obviyus/41950ab1075e6297d4f27c188efeb9f7 to your computer and use it in GitHub Desktop.
Save obviyus/41950ab1075e6297d4f27c188efeb9f7 to your computer and use it in GitHub Desktop.
random maze generation
import numpy as np
import random
def buildMaze (n):
emptyMaze = [[0 for x in range(n)] for y in range(n)]
for i in range(int(n/1.15)):
col = random.randrange(0, n, 1)
for j in range(int(n/1.15)):
row = random.randrange(0, n, 1)
if emptyMaze[col][row] == 0:
emptyMaze[col][row] = 1
return emptyMaze
if __name__ == "__main__":
n = int(input("Enter size of maze: "))
print(np.matrix(buildMaze(n)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment