a code for shorten a path in a grid
-
I have an 8x8 grid...On the grid i have a robot standing in the origin point (0,0) Also,i have a little lamp placed at any tile RANDOMLY at the start of puzzle. The robot can only move square by square either horizontally or vertically (no diagonals allowed!) The robot wants to get to the lamp as quickly as possible (means in the least number of moves possible) So how can i shorten the path?
-
I have an 8x8 grid...On the grid i have a robot standing in the origin point (0,0) Also,i have a little lamp placed at any tile RANDOMLY at the start of puzzle. The robot can only move square by square either horizontally or vertically (no diagonals allowed!) The robot wants to get to the lamp as quickly as possible (means in the least number of moves possible) So how can i shorten the path?
Try the appropriate[^] forum.
-
I have an 8x8 grid...On the grid i have a robot standing in the origin point (0,0) Also,i have a little lamp placed at any tile RANDOMLY at the start of puzzle. The robot can only move square by square either horizontally or vertically (no diagonals allowed!) The robot wants to get to the lamp as quickly as possible (means in the least number of moves possible) So how can i shorten the path?
The general answer to any pathfinding question is "have you checked out A*[^]?". So, have you? In the case of a uniform grid with no obstacles you can just go straight for the target, but I'm guessing this is a preliminary to pathfinding with obstacles, and in that case A* is exactly what you'll want.