Created
September 18, 2019 13:41
-
-
Save obviyus/41950ab1075e6297d4f27c188efeb9f7 to your computer and use it in GitHub Desktop.
random maze generation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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