Advertisement
Guest User

やってみたこと

a guest
Dec 14th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. import random
  2. import time
  3.  
  4. width = int(input("State the width of the grid: "))
  5. height = int(input("State the height of the grid: "))
  6.  
  7. symbols = ["A"]
  8. grid = {}
  9. direction_way="T","B","L","R"
  10.  
  11. for y in range(height):
  12.     for x in range(width):
  13.         coordinate = (x, y)
  14.         grid[coordinate] = " "
  15.  
  16. for element in range(1):
  17.     place, ant_one_place = random.choice(list(grid.items()))
  18.     ant_one_direction = random.choice(symbols)
  19.     grid[place] = ant_one_direction
  20.  
  21. def print_grid():
  22.     for y in range(height):
  23.         for i in range(width):
  24.             print("+---", end="")
  25.         print("+")
  26.         for x in range(width):
  27.             if x == 0:
  28.                 print("|", end="")
  29.             coordinate = (x, y)
  30.             print("", grid[coordinate], end=" |")
  31.         if y != height:
  32.             print("")
  33.     for i in range(width):
  34.         print("+---", end="")
  35.     print("+")
  36.  
  37.  
  38. print_grid()
  39. time.sleep(1)
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement