DEV Community

Cover image for Scratch – Solve Maze Problem automatically
Be Here Now
Be Here Now

Posted on

Scratch – Solve Maze Problem automatically

The problem is to solve the maze automatically without any mouse or keyboard actions.

Scratch

https://scratch.mit.edu/projects/644610721/embed

The main idea is to bind two colors blocks at the **top **and the **bottom **of the dog which will get out of the maze. The top color is greenand the bottom color is purple. If the greencolor touches the blackcolor which is the maze line, then turn right. If the purplecolor touches the blackcolor, then turn left. A redcolor is bind to the head of the dog, which is used to detect the head blackcolor. If the head touches the blackcolor, then turn back.

Sprite’s Costume

Turn right is the default option, and turn left is also feasible. Sometimes turning left may speed up the solving speed but highly dependent the map.

Scratch code to solve maze problem

Top comments (0)