Skip to content

Instantly share code, notes, and snippets.

@iGhost
Last active April 15, 2020 08:07
Show Gist options
  • Save iGhost/a6d2be237fcef9bf8359323e8bef3ecb to your computer and use it in GitHub Desktop.
Save iGhost/a6d2be237fcef9bf8359323e8bef3ecb to your computer and use it in GitHub Desktop.
from random import randint
MAP_WIDTH = 80
MAP_HEIGH = 24
def show_map(map):
for w in range(len(map)):
for h in range(len(map[0])):
print("{}".format(map[w][h]), end='')
print('')
def fill_map(map):
for h in range(len(map)):
for w in range(len(map[0])):
roll = randint(1, 100)
cell = ' '
if roll > 60: # Wall
cell = '▩'
elif roll == 1: # Quest
cell = '!'
elif roll < 7: # Enemy
cell = '@'
else:
cell = ' '
map[h][w] = cell
map[0][0] = '%' # Entrance
map[MAP_HEIGH-1][MAP_WIDTH-1] = '*' # Exit
return map
if __name__ == "__main__":
map = [[' ' for w in range(MAP_WIDTH)] for h in range(MAP_HEIGH)]
fill_map(map)
show_map(map)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment