Maze AI

Finally managed to make an AI that solves a maze.

It solves it quickly as well. If it gets jammed, it will fix itself. Don't worry. It can take a few tries before it reaches the end. Just be patient.

You can also make your own maze. Just draw the map, set the Start X and Start Y variables at the start of the script to the starting position, go to the Finish sprite, and change the go to x y to the end area you want the bot to finish at.

In case your wondering how it works, it calculates the longest distance, goes to the area with the longest distance, creates a blockade so it doesn't retrace its steps on accident. Then it un-jams itself. It repeats this until it is touching the finish.

Just made a few changes to make customizable maps work better.

I like it. Thank you for sharing it.

can it solve a maze or just traverse a path? either way still cool

Well, just a traverse path. But a lot of people call things where a bot has to traverse a path a maze.


I updated it to show its thought process now.

so it didnt solve the maze all the way and i dont know why here is the gif
it just restarted it after like 2 and a half minutes

That means it got stuck at some point in the maze.

Mind sending the maze to me?

yeah hold up

Your map in some spots stalls the bot. Try increasing the retry amount. (Reload the page)


Oh my. Nice.

WOAH! I WAS FEATURED! Thanks guys!

:roll_eyes: This is why competition on websites like Snap! are a BAD idea. How are you supposed to make people learn to code when you have competition on websites? That will turn into jealousy and stuff. :roll_eyes:

You will please just STOP bad mouthing Scratch. It's very annoying.

Fine, I'll remove the Scratch parts.

But still I think Competition on coding websites and other websites are a BAD idea. Even though it may seem like a good motivator to do harder and better, once you stay long enough on the website and have a LOT of projects that you have shared, you will start to get angry.

It's not competition. Now please get back on topic.

It is. The featured category is technically competition.