This weeks task is to solve the maze. You are not allowed to touch the black lines.
You can use any Python Turtle commands you want including
- goto(x,y)
- right(deg)
- left(deg)
- forward(length)
Save the image as maze.png and use the boilerplate code below in Thonny to start the task.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Solve the maze # Mr Stratton # 7/6/19 from turtle import * # Help here https://docs.python.org/3/library/turtle.html setup( 1000 , 600 ) # set the window size to 480x360 pixels bgcolor( 'yellow' ) # set BG to yellow bgpic( "maze.png" ) # BG pic only works with PNG and GIF title( "Mr. Stratton's Maze Tutorial" ) # Title of window color( "red" ) # Colour line # shape("arrow") # Shape of the turtle (“arrow”, “turtle”, “circle”, “square”, “triangle”, “classic”) turtlesize( 3 ) # size of turtle (easier for some kids to see) pensize( 3 ) # Set the size of the pen penup() goto( - 420 , 220 ) pendown() # vvvvvv Enter your code below here vvvvvv |
After you have solved the maze answer these questions:
- How many programming steps did you take?
- Can you reduce the number of steps?
Save a new copy of the program and edit it to make it more efficient (fewer lines). The number of extra lines that my program needed is below.