hakermania
September 4th, 2012, 11:50 PM
Most strategy games let you choose one or more characters and point with your mouse to a specific point. When you click at this point, then your character(s) move, taking the shortest possible path.
How is this implemented into games? I've thought of the Dijkstra's algorithm (http://en.wikipedia.org/wiki/Dijkstra's_algorithm) but, then, there are maps out there that their grid points (in every strategy game your character moves into a grid) should exceed the million by far. So, including each of these points inside this algorithm should take ages to calculate the shortest distance. Consider your character(s) being on the one side of the map and you choose to move them to the other side. How many possible paths have to be calculated?
How is this implemented into games? I've thought of the Dijkstra's algorithm (http://en.wikipedia.org/wiki/Dijkstra's_algorithm) but, then, there are maps out there that their grid points (in every strategy game your character moves into a grid) should exceed the million by far. So, including each of these points inside this algorithm should take ages to calculate the shortest distance. Consider your character(s) being on the one side of the map and you choose to move them to the other side. How many possible paths have to be calculated?