Skip to content

Instantly share code, notes, and snippets.

@yvan
Created November 5, 2017 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yvan/815963d237ad204e90c886a178f3adf8 to your computer and use it in GitHub Desktop.
Save yvan/815963d237ad204e90c886a178f3adf8 to your computer and use it in GitHub Desktop.
shape = (42,42)
WALL = 0
FLOOR = 1
# set the probability of filling
# a wall at 40% not 50%
fill_prob = 0.4
new_map = np.ones(shape)
for i in range(shape[0]):
for j in range(shape[1]):
choice = random.uniform(0, 1)
# replace 0.5 with fill_prob
new_map[i][j] = WALL if choice < fill_prob else FLOOR
display_cave(new_map)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment