Package model

Class Pathfinder

java.lang.Object
model.Pathfinder
All Implemented Interfaces:
Serializable

public class Pathfinder extends Object implements Serializable
Implementation of the Dijkstra's algorithm for finding the shortest path between two nodes.
See Also:
  • Constructor Details

    • Pathfinder

      public Pathfinder()
      Constructs a Pathfinder instance.
  • Method Details

    • setMap

      public static void setMap(Map map)
      Sets the map that the pathfinder is working on.
      Parameters:
      map - The map that the pathfinder is working on.
    • Dijkstra

      public Point Dijkstra(Soldier start, Sides side, Building building)
      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

      public ArrayList<Point> genPath(Soldier start, Sides side, Building building, String mode)
      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.