Pregunta

I have a board which is 6x6 see picture below. The black thing is a ball. The red block is where the ball needs to go. So my question is how do I find the shortest way to the red block. The ball can only be moved up, down, right and left. There are also obstacles. I have been thinking a lot but have no clue or idea on how the algorithm to find the shortest way should be. I need some advise on how I can solve the problem.

enter image description here

¿Fue útil?

Solución

If there are any obstacles, use breadth-first-search algorithm.

If there aren't, the task is even easier. Just get to the right column and then continue to the right row.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top