Daily Archives: December 5, 2019

Mice Maze

My Second dream was ‘mice maze’, it was very popular when I was childhood, program a ‘mice’ to solve the maze automatically. Actually, my 25 years old final year project was ‘smart vacuum cleaner’, it is now very popular. But, it was very new concept at that time and I defined some ‘mice’ behavior. And now, I proof that it work based on Scratch.

Scratch, thanks a again!!

P.S. I like to stare the screen to see the mice to run the path. If you want to run it faster, hold shift when press the green flag.. 🙂

Basic idea for the mice’s logic

That’s a very basic and simple logic for the mice…. XD

  1. We make the mice in a square with dimension same as the maze path, we are using 48pt x 48pt.
  2. The mice is moving in a unit of it’s size, i.e. 48pt
  3. We define the priority of the movement for the mice to follow,
    • Always go forward
    • Go right if cannot go forward
    • Go left if both forward and right are blocked
    • Move backward if no more movement.
  4. Then, we need to record each movement and possible (not explore) directions.
  5. When the mice move backward, it will read the record and go to un-explore directions.

How does the program work

Prior I created the mice maze, I actually made a program by using WASD key to move the mice, solve the maze manually. So, keep in mind, W – up, D – right, S – down, A – left, it is too hard for you if you are FPS game player.. LOL

Sensor – detecting wall

Before the ‘mice’ do any movement, it will detect any wall in it’s four directions. In this program, I move the ‘mice’ to four directions in a certain distance. See if it will hit a wall (black in color) or not. If not hit, W A S & D will be put into the corresponding variable Wall U, D, R & L, tell the ‘mice’ that the direction is OK to move. Otherwise, keep the variable as X, means there is a wall.

Movement

Path Tracking

I am using a LIST called ‘Path’ to record each movement of the ‘mice’,