I want to write cellular automata lee algorithm (I call it wave method) which searches for the shortest path between 2 points.In lee algorithm the user specifies the weight one for all grid points and the algorithm will find thepath with the lowest number of grid points(it means the accumulated weights are needed to find the path).But this method which I want to write , instead of storing accumulated weights , stores the direction in which we have to move to get back to the starting point.( it means we use marks instead of weights)
In this method we have 15 state that a number will be assign for each state,& also it has two phase : at the begining all cells are in the free state except start and end points.In the first phase all neighbour cells of start point became wave ( which are arrow in 4th direction ( north -south-west east)to start)and after that all cells check whether there is any cell in neiborhood that already has a wave mark, if found the cell becomes wave mark towards the already wave cell.this step ends when the end point is reached Now the second step begins and the path is built backward towards the start point along the wave marks (if a cell is one of the wave states &it sees a neighbour cell that is a path towards this cell then this cell becomes a path I the direction of it,s previous mark(f.example wave up become path up)
The algorithm terminates when the start cell sees one of it's neighbours become part of the path .the start celll changes it's state to found and signals that the path is complete.
15states are defined: block, free (Initial State of the Nodes), initD (Initial State of the Destination Node), 4state for wavemarkwhich are ( wave up,Wave Down, Wave Right & Wave Left),and etc.....
I assign a number to each states and each cell according to it's current state and it's neighbours which are north- south-east-west), change it's state .
Now my problem is that I don't know how to begin & write it and have no idea( I just know that I have a matrix for grid point), Can someone help me out with this, please? Please help me write this algorithm I'm not professional
Tnx all

6 Years
Discussion Span
Last Post by hkdani

You want to write this in C.
That's fine.
Use a while statement.

While (expression) // 
      statements ; // statements to test for the state you are seeking


tnx for answering ,In C or C++ doesn't difference,
In this algorithm each cell must check it's north east west south neighbors and my qestion is that for writing that I need a for loop ?
and also you mean that I don't need any pointer or struct.. , and also if I want to show each state with color what can I do
Thank you for helping me


Your first step should be to find the start or the end point.

You need to cycle through the matrix of given points until a start or end point has been found. At that point in your program, you can proceed to the next phase in your search. I presume you will start your search in one of the four corners of the matrix.

You probably should declare a two dimensional array to contain the values of the points on the matrix. I'm also assuming that the state for each point has already been supplied in some manner.

The values for the array declaration will depend on the size of your matrix. int MYPOINTS[100][100] ;

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.