luv_anu:
i am trying to make a maze solving robot which takes some data from the sensors.... keep it in its memory ..... sort it to find the shortest route and execute.
First you will need to have a data structure that stores the maze.
I.e. for a 2D maze this could be a 2D array, where "1" represents "wall" and "0" represents "free".
This maze would consist of a 10x10 2D array, has one IN and one OUT position where the robot can walk in and out:
byte maze [10][10]={
{1,1,1,1,1,1,1,1,1,1},
{1,0,0,0,1,0,0,0,0,1},
{1,0,0,0,1,0,0,1,0,0}, OUT
{1,0,0,0,1,0,0,1,0,1},
{1,0,0,0,1,0,0,1,0,1},
{1,0,0,0,0,0,0,1,0,1},
{1,0,0,1,1,1,1,1,0,1},
{1,0,0,0,0,0,0,0,0,1},
{1,1,0,1,1,1,1,1,1,1},
} IN
Each position in the array is represented by a (row, column) index into the array.
This maze example has two solution where it is possible to walk from IN to OUT: A shorter and a longer path.
You will need an algorithm to find the shortest path from IN to OUT.
And your robot and the sensors need a way to sense the position in the maze. If the maze is known, the only thing you will have to store besides of the maze is the robot position (row, column) within the maze. The difficulty then is
- to sense the robot position
- to direct the robot to walk where you want (shortest path IN to OUT)