Package megamek.client.bot.princess
Class SwarmContext
java.lang.Object
megamek.client.bot.princess.SwarmContext
Context class to control the units as a swarm. Contains information about the current state of the game
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddStrategicGoal(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 fastervoidassignClusters(List<Entity> allUnits) Assign units to clustersgetCenterForUnit(int unitId) Get the cluster center for a unitgetClusterFor(Entity unit) Get the cluster for a unitGet the current center of the swarmintgetEnemyTargetCount(int enemyId) Get the number of times an enemy has been targetedGet the strategic goals on the quadrant of the given coordinatesvoidinitializeStrategicGoals(Board board, int quadrantWidth, int quadrantHeight) Initialize the strategic goals for the boardbooleanisUnitTooFarFromCluster(Entity unit, double v) Deprecated, for removal: This API element is subject to removal in a future version.voidrecordEnemyTarget(int enemyId) Record an enemy target, incrementing the number of units targeting the enemy this turnvoidRemove all strategic goals on the quadrant of the given coordinatesvoidremoveStrategicGoal(Coords coords) Remove a strategic goal from the list of goalsvoidremoveStrategicGoal(Coords coords, int radius) Remove strategic goals in a radius around the given coordinatesvoidReset the enemy target countsvoidsetCurrentCenter(Coords adjustedCenter) Set the current center of the swarm
-
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
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
Remove a strategic goal from the list of goals- Parameters:
coords- The coordinates to remove
-
removeStrategicGoal
Remove strategic goals in a radius around the given coordinates- Parameters:
coords- The center coordinatesradius- The radius to remove goals
-
getStrategicGoalsOnCoordsQuadrant
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
Set the current center of the swarm- Parameters:
adjustedCenter- The new center
-
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
-
removeAllStrategicGoalsOnCoordsQuadrant
Remove all strategic goals on the quadrant of the given coordinates- Parameters:
coords- The coordinates to check
-
initializeStrategicGoals
Initialize the strategic goals for the board- Parameters:
board- The board to initialize the goals onquadrantWidth- The width of the quadrantsquadrantHeight- The height of the quadrants
-
getClusterFor
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
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
Assign units to clusters- Parameters:
allUnits- The units to assign
-