Optimization in matrix ?

I have matrix[4][4] for example:
' *  '
'  * '
'     '
'     '
enter in matrix(for example) with coordinates [0][0]
and exit [0][3].
How to find optimizing way from enter to exit ?
Thank's
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
What do you wish to optimize?
0
Commented:
What you want is a maze-solving solution, not a matrix-solving solution.  A matrix is just a way of storing/representing a maze (such as a minefield).

The solution will depend on whether you allow wrapping, etc.  We need the rules.
0
Commented:
if there are no blocks between
the enter and exit point:
I would calculate each step the Length
from the immidiate neighbour points to me to the exit point.
I would choose the shortest length each time.

If there might be block, it isn't as simple.
one should can use Backtracking
to find the path.

heres a recurse "rough" definition:

f(location, matrix)
{
if you are at the enter pos and have
nowhere to go - quit, failer.
else
if you are in the Exit point -
quit, Success.
else
if you don't have any place to go
(all is block (except the from where
you came)) mark the place as DeadEnd.
<do nothing, the recurse will pop you
to the prev. position>
else
call f(Location, matrix) for all
free places that aren't blocked or a dead end.
}

Any questions ....

0

Experts Exchange Solution brought to you by