import time
import random
import os
def disp(WIDTH, HEIGHT, x, y):
os.system("clear")
for row in range(HEIGHT):
for col in range(WIDTH):
if row == y and col == x:
print("@",end='')
elif row == HEIGHT // 2 and col == WIDTH // 2:
print("+",end='')
else:
print(".",end='')
print()
return
def main():
WIDTH = 60
HEIGHT = 20
x = WIDTH // 2
y = HEIGHT // 2
turn = 0
for step in range(1000):
direction = random.randrange(4)
if direction == 0:
x = x + 1
elif direction == 1:
y = y + 1
elif direction == 2:
x = x - 1
else:
y = y - 1
turn = turn + 1
# disp(WIDTH, HEIGHT, x, y)
print(x, y, turn)
time.sleep(0.1)
if x == WIDTH // 2 and y == HEIGHT // 2:
break
print("Done after " , turn, "steps!")
main()