Package model
Class Pathfinder
java.lang.Object
model.Pathfinder
- All Implemented Interfaces:
Serializable
Implementation of the Dijkstra's algorithm for finding the shortest path between two nodes.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFinds the shortest path from the start to the end.Generates a path from start to end.static void
Sets the map that the pathfinder is working on.
-
Constructor Details
-
Pathfinder
public Pathfinder()Constructs a Pathfinder instance.
-
-
Method Details
-
setMap
Sets the map that the pathfinder is working on.- Parameters:
map
- The map that the pathfinder is working on.
-
Dijkstra
Finds the shortest path from the start to the end.- Parameters:
start
- The soldier to move.side
- The side of the end point.building
- The building to check when searching path at building phase.- Returns:
- The shortest path from the start to the end.
-
genPath
Generates a path from start to end.- Parameters:
start
- The soldier to move.side
- The side of the enemy.building
- The building to check when searching path at building phase.mode
- The return mode.- Returns:
- The path.
-