import turtle import random t = turtle.Turtle() t.speed(0) # 1:slowest, 3:slow, 5:normal, 10:fast, 0:fastest kierunki = [0,90,180,270] def powrot(): x,y = t.pos() if x>200: t.setheading(180) elif x<-200: t.setheading(0) elif y>200: t.setheading(270) elif y<-200: t.setheading(90) while (True): t.setheading(random.choice(kierunki)) powrot() t.forward(random.randint(38,42))