MioxLovePython / python_games_Miox

0 stars 1 forks source link

Add base screen for maze game 10x10 #1

Open zaebee opened 3 months ago

zaebee commented 3 months ago

Create list of list with walls (without enter/exit]. Like this:

| _ _ _ | | _ | | _
_ _ | _ _ | | | _ |
0 _ | _ _ | | | | |
_ | _ _ _ | | | | |
_ | _ | _ | _ | | |
_ | | | _ | | | | |
_ _ _ _ | | | _ _ _
| _ | _ | | | | _ |
| | | | | | | _ | _
_ _ | | _ | _ | _ _
zaebee commented 3 months ago

@MioxLovePython could you please assign this task to you?

zaebee commented 3 months ago

Simple example

"""Maze generator.
"""
import random

WIDTH = 10
HEIGHT = 10

def generate():
    start_map = ['|', '_'] #, '0']

    map = []
    for _ in range(HEIGHT):
        row = [random.choice(start_map) for _ in range(WIDTH)]
        map.append(row)

    return map
    # '\n'.join(' '.join(row) for row in map)

map = generate()

indexes = [
    [0, random.randint(0, 9)],
    [9, random.randint(0, 9)],
    [random.randint(0, 9), 0],
    [random.randint(0, 9), 9]
]

enter_index = random.choice(indexes)
row, col = enter_index
map[row][col] = '0'
print('\n'.join(' '.join(row) for row in map))