문제

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

도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top