My Python Turtle Maze!

What It Is And How It Works:

My python Turtle Maze is a project I did where the turtle solves the maze every time and the maze changes every time. Now you’re probably wondering: How does this work? How do you even do this? Well, it’s very complicated to say, but I’ll explain it and summarize it in the least confusing way possible.

To start off, for every black line, there’s a specific name given to it. Each black line represents a little part of the big maze. So, as you can see in the picture, the name of the first black line at the very top is named ”r1”. I made the turtle always go the same distance as r1 and a little bit more. I did the because if it were to turn right, right after that, it would bump into the last part of r1, so it needs to go a bit more forward (for me I did 10 forward). After all of that, I made the turtle turn right 90 (so it could be down towards the other patch of lines) and then go to a coordinate on the second line that didn’t touch or go through any of the walls. For the next line, which name is ”t1”, I did the same thing except since the name of this line is named t1, I told the code to go the same amount of distance forward as t1, then a little bit more. To give a bit more of an understanding, the names r(number) and t(number) switch every time, per line, and the numbers go up for their variable. They’re both not combined. For example, r1, then t1, then r2, then t2, the number keeps going up and the 2 variables keep repeating until the turtle has reached the end of the maze. Otherwise, besides those 2 variables and them switching off, I did the same repetitive code for the rest of it until the end of the maze is reached (go forward the same amount line is, go forward a bit more, turn right 90, and go to a coordinate located on the next line down below that doesn’t touch or go through any walls of the maze). Also for fun, I did a victory circle when the turtle reaches the end.

The Code For It:

If you’re still confused on how this works, here is all the code (And here’s the link: TURTLE MAZE):

In conclusion, that is my Python Turtle Race and How It Works! (Just in case, here’s another like to the maze: TURTLE MAZE). In the end, I hope you enjoyed reading this, and as always: I’ll blog to ya later! 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *