Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- import time
- width = int(input("State the width of the grid: "))
- height = int(input("State the height of the grid: "))
- symbols = ["A"]
- grid = {}
- direction_way="T","B","L","R"
- for y in range(height):
- for x in range(width):
- coordinate = (x, y)
- grid[coordinate] = " "
- for element in range(1):
- place, ant_one_place = random.choice(list(grid.items()))
- ant_one_direction = random.choice(symbols)
- grid[place] = ant_one_direction
- def print_grid():
- for y in range(height):
- for i in range(width):
- print("+---", end="")
- print("+")
- for x in range(width):
- if x == 0:
- print("|", end="")
- coordinate = (x, y)
- print("", grid[coordinate], end=" |")
- if y != height:
- print("")
- for i in range(width):
- print("+---", end="")
- print("+")
- print_grid()
- time.sleep(1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement