Class SwarmContext

java.lang.Object
megamek.client.bot.princess.SwarmContext

public class SwarmContext extends Object
Context class to control the units as a swarm. Contains information about the current state of the game
  • Constructor Details

    • SwarmContext

      public SwarmContext()
  • Method Details

    • recordEnemyTarget

      public void recordEnemyTarget(int enemyId)
      Record an enemy target, incrementing the number of units targeting the enemy this turn
      Parameters:
      enemyId - The enemy id
    • getEnemyTargetCount

      public int getEnemyTargetCount(int enemyId)
      Get the number of times an enemy has been targeted
      Parameters:
      enemyId - The enemy id
      Returns:
      The number of times the enemy has been targeted
    • resetEnemyTargets

      public void resetEnemyTargets()
      Reset the enemy target counts
    • addStrategicGoal

      public void addStrategicGoal(Coords coords)
      Add a strategic goal to the list of goals, a strategic goal is simply a coordinate which we want to move towards, its mainly used for double blind games where we don't know the enemy positions, the strategic goals help distribute the map evenly accross the units inside the swarm to cover more ground and find the enemy faster
      Parameters:
      coords - The coordinates to add
    • removeStrategicGoal

      public void removeStrategicGoal(Coords coords)
      Remove a strategic goal from the list of goals
      Parameters:
      coords - The coordinates to remove
    • removeStrategicGoal

      public void removeStrategicGoal(Coords coords, int radius)
      Remove strategic goals in a radius around the given coordinates
      Parameters:
      coords - The center coordinates
      radius - The radius to remove goals
    • getStrategicGoalsOnCoordsQuadrant

      public List<Coords> getStrategicGoalsOnCoordsQuadrant(Coords coords)
      Get the strategic goals on the quadrant of the given coordinates
      Parameters:
      coords - The coordinates to check
      Returns:
      A list of strategic goals on the quadrant
    • setCurrentCenter

      public void setCurrentCenter(Coords adjustedCenter)
      Set the current center of the swarm
      Parameters:
      adjustedCenter - The new center
    • getCurrentCenter

      @Nullable public Coords getCurrentCenter()
      Get the current center of the swarm
      Returns:
      The current center
    • isUnitTooFarFromCluster

      @Deprecated(since="0.51.0", forRemoval=true) public boolean isUnitTooFarFromCluster(Entity unit, double v)
      Deprecated, for removal: This API element is subject to removal in a future version.
    • getClusters

      public List<SwarmContext.SwarmCluster> getClusters()
    • removeAllStrategicGoalsOnCoordsQuadrant

      public void removeAllStrategicGoalsOnCoordsQuadrant(Coords coords)
      Remove all strategic goals on the quadrant of the given coordinates
      Parameters:
      coords - The coordinates to check
    • initializeStrategicGoals

      public void initializeStrategicGoals(Board board, int quadrantWidth, int quadrantHeight)
      Initialize the strategic goals for the board
      Parameters:
      board - The board to initialize the goals on
      quadrantWidth - The width of the quadrants
      quadrantHeight - The height of the quadrants
    • getClusterFor

      public SwarmContext.SwarmCluster getClusterFor(Entity unit)
      Get the cluster for a unit
      Parameters:
      unit - The unit to get the cluster for
      Returns:
      The cluster for the unit, initializes a new cluster if it doesn't exist
    • getCenterForUnit

      public Coords getCenterForUnit(int unitId)
      Get the cluster center for a unit
      Parameters:
      unitId - The unit to get the cluster for
      Returns:
      The cluster for the unit, initializes a new cluster if it doesn't exist
    • assignClusters

      public void assignClusters(List<Entity> allUnits)
      Assign units to clusters
      Parameters:
      allUnits - The units to assign