repl.it
@KianAlford/

Robot Maze remake

Python (with Turtle)

A maze in which a Computer will solve

fork
loading
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# robot maze
import turtle as trtl

#----- maze and turtle config variables
screen_h = 400
screen_w = 420
square = 50
startx = -100
starty = -100
turtle_scale = 1.5

#------ robot commands
def move():
  robot.fd(square)

def turn_left():
  robot.lt(90)

def reset():
  robot.penup()
  robot.goto(startx, starty)
  robot.pendown()

#----- init screen
wn = trtl.Screen()
wn.setup(width=screen_w, height=screen_h)

#----- init robot
robot = trtl.Turtle(shape="turtle")
robot.penup()
robot.setheading(90)
robot.turtlesize(turtle_scale, turtle_scale)
robot.goto(startx, starty)
robot.speed(2)
robot.pendown()

#---- TODO: change maze here
wn.bgpic("maze1.png") # other file names should be maze2.png, maze3.png

#---- TODO: begin robot movement here
# move robot forward with move()
# turn robot left with turn_left()
# sample while loop:
'''
i = 0
while (i < 3): # forward 3
  i += 1
  move()
'''

#---- end robot movement 

wn.mainloop()
result
console
?