Class Princess
- All Implemented Interfaces:
IClient
- Direct Known Subclasses:
Caspar
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA bot artillery heat-map marker.Nested classes/interfaces inherited from class megamek.client.bot.BotClient
BotClient.CalculateBotTurnNested classes/interfaces inherited from class megamek.client.AbstractClient
AbstractClient.ConnectionHandler -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intDistance to the waypoint to consider for considering the waypoint reachedFields inherited from class megamek.client.bot.BotClient
behaviorSettings, boardClusterTracker, BOT_TURN_RETRY_COUNT, frame, rerolledInitiativeFields inherited from class megamek.client.AbstractClient
awaitingSave, bots, connected, connection, connectionListener, connThread, disconnectFlag, host, iconCache, localPlayerNumber, log, name, phaseReport, port, roundReport, unitNameTracker -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidabandonShipOneUnit(Entity movingEntity, Vector<Transporter> transporters, MovePath path) voidaddDesignatedTagTarget(int targetId) Designates an enemy unit for the bot to put its TAG on, so a player's homing artillery has a known designation.voidaddStrategicBuildingTarget(Coords coords) protected AeroGroundPathFinderaeroGroundPathFinder(Game game) Factory seam for subclasses (CASPAR): builds the path finder used for airborne aerodyne units flying over a ground mapsheet.protected Map<WeaponMounted, Double> calcAmmoConservation(Entity shooter) static intcalculateAdjustment(String ticks) protected intcalculateAimedShotLocation(Mek target, List<WeaponFireInfo> aimedShots, boolean rearAttack, boolean includeHead) Determine which location to aim for on a Mek.protected Vector<BoardLocation> protected intcalculateCalledShotDirection(Mek target, int attackSide, List<WeaponFireInfo> calledShots) Determine which direction to make a called shot against a Mek - left, right, high, or low.protected voidprotected voidprotected voidCalculate what to do during the INFANTRY_VS_INFANTRY_COMBAT phase.protected doublecalculateMoveIndex(Entity entity, StringBuilder msg) Calculates the move index for the given unit.protected MovePathDetermines which entity should be moved next and then calls toBotClient.continueMovementFor(Entity)with that entity.protected PhysicalOptionprotected Vector<EntityAction> calculatePointBlankShot(int firingEntityID, int targetID) Worker method that calculates a point blank shot action vector given a firing entity ID and a target ID.protected voidCalculate what to do during the PRE_END_DECLARATIONS phase.protected voidCalculates the targeting/ off board turn This includes firing TAG and non-direct-fire artilleryprotected booleancheckForEnhancedTargeting(Entity shooter, Targetable targetable, int cover) Determine if a shooter should consider using enhanced targeting - aimed or called shots - against a given target.protected voidvoidClears all designated TAG targets, returning the bot's TAG to autonomous best-hit targeting.voidClear the manual AMS tracking listcomputeGuidedWeapons(Entity entityToFire, Coords location) Because Aerospace units can either TAG _or_ attack with their weapons, we want every friendly TAG-equipped Aero (and possibly others) to know about all the possible incoming Homing or IF attacks that could take advantage of their TAGs, for later calculations.intcomputeTeamTagUtility(Targetable te, int damage) Reduce utility of TAGging something if we're already trying.protected MovePathcontinueMovementFor(Entity entity) static PrincesscreatePrincess(String name, String host, int port, BehaviorSettings behavior) Returns a new Princess Bot with the given behavior and name, configured for the given host and port.protected booleanDetermines whether Princess should reroll initiative using the Tactical Genius special ability.voiddie()Shuts down threads and socketsprotected voidThe client has become disconnected from the servervoidvoidflagManualAMSUse(int id) Flag an entity as having used manual AMS this roundprotected intgetAimedShotLocation(Targetable target, FiringPlan planOfAttack, boolean rearAttack, boolean includeHead) Determine which location to aim for on a general target.booleanDeprecated, for removal: This API element is subject to removal in a future version.getAppropriateTarget(Coords strategicTarget) getAppropriateTarget(Coords strategicTarget, int boardId) Lazy-loading accessor for the artillery targeting control.protected intgetCalledShotDirection(Targetable target, int attackSide, FiringPlan planOfAttack) Determine which direction to make a called shot - left, right, high, or low.Get a list of all hot spots (positions of high activity) for opposing unitsbooleanDeprecated, for removal: This API element is subject to removal in a future version.booleanprotected CoordsgetFirstValidCoords(Entity deployedUnit, List<Coords> possibleDeployCoords) Returns the first set of valid deployment coordinates for the given unit out of the given deployment coordinates.Deprecated, for removal: This API element is subject to removal in a future version.getFriendlyHotSpot(Coords testPosition) Get the nearest top-rated hot spot for friendly unitsbooleanintgetMaxWeaponRange(Entity entity) intgetMaxWeaponRange(Entity entity, boolean airborneTarget) getMovePathsAndSetNecessaryTargets(Entity mover, boolean forceMoveToContact) Function with side effects.booleanDeprecated, for removal: This API element is subject to removal in a future version.booleanintLazy-loaded calculation of the "to-hit target number" threshold, below which rapid fire autocannon will fire multiple shots.Deprecated, for removal: This API element is subject to removal in a future version.protected voidThis method is the starting point that handles all received Packets.booleanhasStrategicBuildingTargets(Coords coords) protected voidSet up heat maps to track enemy unit positions over timeprotected voidprotected voidSet up heat map to track friendly units over timevoidvoidInitialize the fire controls.voidInitialize the possible path rankers.protected voidprotected voidprotected booleanisAtmosphericAerospace(Entity entity) Whether this unit is flying under the atmospheric aerospace rules - over a ground mapsheet or on a low-altitude map.booleanisValidEnhancedTargetingAttacker(int testType) Checks if the supplied unit type is considered a valid attacker for enhanced targetingbooleanisValidEnhancedTargetingTarget(int testType) Checks if the supplied unit type is considered a valid target for enhanced targetingprotected intPicks a tag target based on the data contained within the given GameCFREvent Expects the event to have some tag targets and tag target types.protected voidprioritizeDeploymentCoords(Entity deployedUnit, List<Coords> possibleDeployCoords) Orders the candidate deployment hexes thatrankDeploymentCoords(Entity, List)will scan.protected voidprotected CoordsrankDeploymentCoords(Entity deployedUnit, List<Coords> possibleDeployCoords) protected doublerankKernelAroundCoords(MovePath start, Entity deployedUnit, int radius, BasicPathRanker ranker) voidreceiveEntityUpdate(Packet packet) Override for the 'receive entity update' handler Updates internal state in addition to base client functionalityvoidLoad the list of units considered crippled at the time the bot was loaded or the beginning of the turn, whichever is the more recent.protected voidregisterFireControl(FireControl.FireControlType fireControlType, FireControl fireControl) Wiring seam for subclasses (CASPAR): replaces the registered fire control of the given type.protected voidregisterPathRanker(PathRanker.PathRankerType rankerType, BasicPathRanker pathRanker) Wiring seam for subclasses (CASPAR): replaces the registered path ranker of the given type, wiring the replacement to the precognition path enumerator the same way the stock rankers are wired.voidremoveStrategicBuildingTarget(Coords coords) voidresetEnhancedTargeting(boolean enable) Sets all enhanced targeting controls to default values and optionally enables its usevoidDeprecated, for removal: This API element is subject to removal in a future version.protected voidrevealEntities(int movedEntityID) Given an entity that just moved, decide if I should reveal any entities in responseDeprecated, for removal: This API element is subject to removal in a future version.Deprecated, for removal: This API element is subject to removal in a future version.protected voidHook invoked when the server greets this client, allowing a bot client to push its behavior settings to the server.voidvoidReports to the server which players this bot currently considers dishonored, so that clients can warn a human player before committing an action that would newly dishonor them.voidsendLoadGame(File f) sends a load game file to the servervoidvoidsetAerospaceFocus(AerospaceFocus aerospaceFocus) Sets the flight's standing order: press the air battle, support the ground force, or AUTO to let the doctrine weigh both halves itself.voidsetAerospaceGroundOrder(AerospaceGroundOrder aerospaceGroundOrder) Orders the bot's DropShips and small craft to lift off, land, or hold their current domain.voidsetAllowCalledShotsOnImmobile(boolean newSetting) Deprecated, for removal: This API element is subject to removal in a future version.protected voidsetAttackAsAimedOrCalled(WeaponFireInfo shot, int aimLocation, int calledShotDirection, int destructionThreshold) If a shot meets criteria, set it as aimed or called.voidsetBehaviorSettings(BehaviorSettings behaviorSettings) Applies the given behavior settings to this bot.voidsetEnableEnhancedTargeting(boolean newSetting) Deprecated, for removal: This API element is subject to removal in a future version.voidsetEnhancedTargetingAttackerTypes(List<Integer> newAttackerTypes) Deprecated, for removal: This API element is subject to removal in a future version.voidsetEnhancedTargetingTargetTypes(List<Integer> newTargetTypes) Deprecated, for removal: This API element is subject to removal in a future version.voidsetFallBack(boolean fallBack, String reason) voidsetFleeBoard(boolean fleeBoard, String reason) Sets whether Princess-controlled units are allowed to flee off the board once they reach their destination edge.voidsetHoldPosition(boolean holdPosition) Orders the bot to hold position: its units stay where they are during the movement phase (they still fight from their current location and may turn in place to face the enemy) until the hold is lifted.voidsetPartialCoverEnhancedTargeting(boolean newSetting) Deprecated, for removal: This API element is subject to removal in a future version.voidsetShootAndScoot(boolean shootAndScoot) Enables or disables "shoot and scoot" for artillery.voidsetShootAndScootHex(Coords shootAndScootHex) Designates a fallback hex for shoot-and-scoot: threatened artillery heads to this hex (which may take several turns) and then holds and fires from there, instead of auto-displacing.protected booleanshouldAbandon(Entity entity) voidshowArtilleryHeatMap(Map<Coords, Princess.HeatMapMarker> predictedImpacts, Map<Coords, Princess.HeatMapMarker> chosenTargets, int boardId) Optionally paints this bot's artillery heat map on the board for testing: a cold-to-hot color fill at each hex an enemy is predicted to advance to (navy blue for a single enemy converging, up to crimson red for many, so the map cools as units are destroyed), and a crosshair at each hex it is firing at.voidHelper method to start the pre-cognition.protected voidUpdate the heat maps with known enemy unit positions, then apply decayvoidupdateEntityState(Entity entity) Update the various state trackers for a specific entity.protected voidUpdate the heat map with allied unit positions (entities controlled by this bot have already been processed as they move), then apply decaybooleanusedManualAMS(int id) Methods inherited from class megamek.client.bot.BotClient
cacheImgTag, calculatePrePhaseTurn, changePhase, connectOwnTrains, correctName, deployMinefields, doAlertDialog, getAIType, getArbitraryEntity, getBehaviorSettings, getClusterTracker, getEnemyEntities, getEntitiesOwned, getFriendEntities, getMassOfAllInBuilding, getStartingCoordsArray, getStrandedEntities, isBot, keepGameLog, receiveReport, setClientGUIMethods inherited from class megamek.client.Client
canUnloadStranded, changeTurnIndex, deploy, getAvailableMapSizes, getBoard, getBoard, getEntitiesVector, getEntity, getFirstDeployableEntityNum, getFirstEntityNum, getGame, getMapSettings, getMyTurn, getNextDeployableEntityNum, getNextEntityNum, getPrevEntityNum, getSelectedEntities, getSkillGenerator, handleGameSpecificPacket, isMyTurn, moveEntity, receiveAttack, receiveBuildingAdd, receiveBuildingCollapse, receiveBuildingRemove, receiveBuildingUpdate, receiveDeployMinefields, receiveEntities, receiveEntitiesUpdate, receiveEntityRemove, receiveEntityVisibilityIndicator, receiveForcesDelete, receiveForceUpdate, receiveIlluminatedHexes, receivePrincessDishonored, receiveRemoveMinefield, receiveRevealMinefield, receiveSendingMinefields, receiveTurns, receiveUpdateCutHexes, receiveUpdateGroundObjects, receiveUpdateIndustrialElevators, receiveUpdateMinefields, sendActivateHidden, sendAddEntitiesToForce, sendAddEntity, sendAddForce, sendAddSquadron, sendAmmoChange, sendAMSAssignCFRResponse, sendAPDSAssignCFRResponse, sendArtyAutoHitHexes, sendAssignForceFull, sendAttackData, sendBuildTrain, sendCalledShotChange, sendChangeOwner, sendChangeTeam, sendChargeLevelChange, sendCustomInit, sendDamageEdit, sendDeleteEntities, sendDeleteEntity, sendDeleteForces, sendDeployBridge, sendDeployFortifications, sendDeployGroundObjects, sendDeploymentUnload, sendDeployMinefields, sendDominoCFRResponse, sendEntityWeaponOrderUpdate, sendExplodeBuilding, sendForceParent, sendGameOptions, sendGhostTargetAction, sendHiddenPBSCFRResponse, sendLoadEntity, sendLobbyBoardGenerationRequest, sendMapDimensions, sendMapSettings, sendModeChange, sendMountFacingChange, sendNovaChange, sendPlanetaryConditions, sendPlayerPickedPassThrough, sendPrePhaseData, sendRerollInitiativeRequest, sendResetRoundDeployment, sendSensorChange, sendSinksChange, sendSpecialHexDisplayAppend, sendSpecialHexDisplayDelete, sendSystemModeChange, sendTAGTargetCFRResponse, sendTelemissileTargetCFRResponse, sendTowEntity, sendUnitAbandonmentAnnouncement, sendUnloadStranded, sendUpdateEntity, sendUpdateEntity, sendUpdateForce, sendUpdateForce, sendVariableRangeTargetingModeChange, setSkillGeneratorMethods inherited from class megamek.client.AbstractClient
addCloseClientListener, checkDuplicateNamesDuringAdd, connect, fireSaveCompleted, flushConn, getBots, getHost, getLocalPlayerNumber, getName, getPort, handleGameIndependentPacket, initGameLog, isAwaitingSave, isConnected, memDump, possiblyWriteToLog, receivePlayerInfo, receiveUnitReplace, send, sendArtilleryRevealPreference, sendChat, sendDone, sendNextPlayer, sendPause, sendPlayerInfo, sendPlayerInfo, sendServerChat, sendUnpause, setAwaitingSave, setLocalPlayerNumber, setName, setSaveCompletionCallback, updateConnectionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface megamek.client.IClient
getBotClient, getInGameObject, getInGameObjects, getLocalPlayer, getPlayer, isLocalBot, playerExists
-
Field Details
-
DISTANCE_TO_WAYPOINT
public static final int DISTANCE_TO_WAYPOINTDistance to the waypoint to consider for considering the waypoint reached- See Also:
-
-
Constructor Details
-
Princess
Constructor - initializes a new instance of the Princess bot.- Parameters:
name- The display name.host- The host address to which to connect.port- The port on the host where to connect.
-
-
Method Details
-
createPrincess
public static Princess createPrincess(String name, String host, int port, BehaviorSettings behavior) Returns a new Princess Bot with the given behavior and name, configured for the given host and port. The new Princess Bot outputs its settings to its own LOGGER. -
startPrecognition
public void startPrecognition()Helper method to start the pre-cognition. This is extracted from the initializer to allow for sub-classing of Princess and remove the possibility that it'll start before a sub-class finishes initializing. -
getArtilleryTargetingControl
Lazy-loading accessor for the artillery targeting control.- Returns:
ArtilleryTargetingControl
-
isAtmosphericAerospace
Whether this unit is flying under the atmospheric aerospace rules - over a ground mapsheet or on a low-altitude map.Excludes space, which has no altitude and therefore no dead zone, and excludes vector movement, which
PathRanker.PathRankerType.NewtonianAerospacealready handles.- Parameters:
entity- the unit to test- Returns:
trueif the unit is an airborne aerospace unit in an atmosphere
-
getFallBack
public boolean getFallBack() -
pickTagTarget
Picks a tag target based on the data contained within the given GameCFREvent Expects the event to have some tag targets and tag target types.- Overrides:
pickTagTargetin classBotClient
-
setFleeBoard
Sets whether Princess-controlled units are allowed to flee off the board once they reach their destination edge.- Parameters:
fleeBoard-trueif units should leave the board when they reach their destination edge.reason- The reason for the change, used for logging.
-
getFireControlState
-
getPathRankerState
-
getMaxWeaponRange
-
getMaxWeaponRange
- Parameters:
entity- Entity we're checkingairborneTarget- Whether the potential target is in the air, only relevant for aircraft shooting at other aircraft on ground maps.- Returns:
- maximum weapon range for the given entity. Cached version of entity.getMaxWeaponRange()
-
setFallBack
-
getHoldPosition
public boolean getHoldPosition()- Returns:
trueif the bot has been ordered to hold position (units stay where they are).
-
setHoldPosition
public void setHoldPosition(boolean holdPosition) Orders the bot to hold position: its units stay where they are during the movement phase (they still fight from their current location and may turn in place to face the enemy) until the hold is lifted. Airborne units are exempt, as they cannot legally stand still.- Parameters:
holdPosition-trueto hold position,falseto resume normal movement.
-
getAerospaceFocus
- Returns:
- the standing aerospace focus order,
AerospaceFocus.AUTOwhen none has been given.
-
setAerospaceFocus
Sets the flight's standing order: press the air battle, support the ground force, or AUTO to let the doctrine weigh both halves itself. A battle order rather than saved configuration - it is not part of behavior settings and resets with the bot client.- Parameters:
aerospaceFocus- the focus to fly under
-
getAerospaceGroundOrder
- Returns:
- the standing ground-or-sky order for DropShips and small craft,
AerospaceGroundOrder.AUTOwhen none has been given.
-
setAerospaceGroundOrder
Orders the bot's DropShips and small craft to lift off, land, or hold their current domain. Fighters are unaffected. A battle order rather than saved configuration - it resets with the bot client.- Parameters:
aerospaceGroundOrder- the order to follow
-
getShootAndScoot
public boolean getShootAndScoot()- Returns:
trueif "shoot and scoot" is enabled, letting a threatened artillery unit displace to regain its standoff instead of holding in place
-
setShootAndScoot
public void setShootAndScoot(boolean shootAndScoot) Enables or disables "shoot and scoot" for artillery. While the bot is holding position, an artillery unit with usable ammo that has an enemy inside its minimum effective range breaks the hold and displaces toward safety to regain standoff, instead of sitting still and being overrun. Only the threatened artillery unit moves; every other unit keeps holding.- Parameters:
shootAndScoot-trueto let threatened artillery displace,falsefor a pure hold.
-
getShootAndScootHex
- Returns:
- The hex the bot's artillery should fall back to under shoot-and-scoot, or
nullto auto-displace away from the nearest enemy
-
setShootAndScootHex
Designates a fallback hex for shoot-and-scoot: threatened artillery heads to this hex (which may take several turns) and then holds and fires from there, instead of auto-displacing. Setting a hex also enables shoot-and-scoot. Passingnullclears the hex and reverts to auto-displacement.- Parameters:
shootAndScootHex- The fallback hex, ornullto clear it
-
getDesignatedTagTargets
- Returns:
- The set of enemy unit IDs the player has designated for the bot to TAG (for the player's own homing artillery). The bot's TAG fire prefers these targets when they are hittable.
-
addDesignatedTagTarget
public void addDesignatedTagTarget(int targetId) Designates an enemy unit for the bot to put its TAG on, so a player's homing artillery has a known designation.- Parameters:
targetId- The enemy unit ID to TAG
-
clearDesignatedTagTargets
public void clearDesignatedTagTargets()Clears all designated TAG targets, returning the bot's TAG to autonomous best-hit targeting. -
showArtilleryHeatMap
public void showArtilleryHeatMap(Map<Coords, Princess.HeatMapMarker> predictedImpacts, Map<Coords, Princess.HeatMapMarker> chosenTargets, int boardId) Optionally paints this bot's artillery heat map on the board for testing: a cold-to-hot color fill at each hex an enemy is predicted to advance to (navy blue for a single enemy converging, up to crimson red for many, so the map cools as units are destroyed), and a crosshair at each hex it is firing at. A predicted hex shows the prediction's turn; a firing hex counts down the turns until the rounds land. Only acts when the local client has the "Show Bot Artillery Heat Map" advanced testing setting on; the markers are visible to all and clear themselves each round. No-op for a headless bot (no GUI preferences).- Parameters:
predictedImpacts- The hexes enemies were predicted to advance to, mapped to their heat-map markerchosenTargets- The hexes the bot is firing at (this turn's shots plus in-flight shells), mapped to their heat-map marker (turn = countdown to impact)boardId- The board the hexes are on
-
setBehaviorSettings
Description copied from class:BotClientApplies the given behavior settings to this bot. Implementations decide how the settings take effect (for example, re-initializing scorers or notifying the server) and are responsible for storing them inBotClient.behaviorSettings.- Specified by:
setBehaviorSettingsin classBotClient- Parameters:
behaviorSettings- the new behavior settings to apply
-
getUnitBehaviorTracker
-
getStrategicBuildingTargets
-
hasStrategicBuildingTargets
-
addStrategicBuildingTarget
-
removeStrategicBuildingTarget
-
getPriorityUnitTargets
-
getAppropriateTarget
-
getAppropriateTarget
-
calculateArtyAutoHitHexes
- Specified by:
calculateArtyAutoHitHexesin classBotClient
-
initTargeting
protected void initTargeting()- Overrides:
initTargetingin classBotClient
-
calculateDeployment
protected void calculateDeployment()- Specified by:
calculateDeploymentin classBotClient
-
getFirstValidCoords
@Nullable protected Coords getFirstValidCoords(Entity deployedUnit, List<Coords> possibleDeployCoords) Returns the first set of valid deployment coordinates for the given unit out of the given deployment coordinates. It's possible to return null, which indicates that there are no valid hexes for the given unit to deploy into.- Overrides:
getFirstValidCoordsin classBotClient
-
rankKernelAroundCoords
protected double rankKernelAroundCoords(MovePath start, Entity deployedUnit, int radius, BasicPathRanker ranker) -
prioritizeDeploymentCoords
protected List<Coords> prioritizeDeploymentCoords(Entity deployedUnit, List<Coords> possibleDeployCoords) Orders the candidate deployment hexes thatrankDeploymentCoords(Entity, List)will scan.This matters more than it looks. The candidate list arrives shuffled, and the scan below stops after roughly twenty entries, so whatever sits at the front of this list is very nearly the whole choice. Princess returns it unchanged: each unit is placed on terrain merit alone, with no regard for where the rest of the force went.
- Parameters:
deployedUnit- the unit being placedpossibleDeployCoords- legal deployment hexes- Returns:
- the hexes to scan, in the order to scan them
-
rankDeploymentCoords
-
calculateFiringTurn
protected void calculateFiringTurn()- Specified by:
calculateFiringTurnin classBotClient
-
calculateTargetingOffBoardTurn
protected void calculateTargetingOffBoardTurn()Calculates the targeting/ off board turn This includes firing TAG and non-direct-fire artillery- Overrides:
calculateTargetingOffBoardTurnin classBotClient
-
calcAmmoConservation
-
calculatePointBlankShot
Worker method that calculates a point blank shot action vector given a firing entity ID and a target ID.- Overrides:
calculatePointBlankShotin classBotClient- Parameters:
firingEntityID- the ID of the entity taking the point blank shottargetID- the ID of the entity being shot at potentially
-
calculateMoveIndex
Calculates the move index for the given unit. In general, faster units and units closer to the enemy should move before others. Additional modifiers for being prone, stealth-ed, unit type and so on are also factored in.- Parameters:
entity- The unit to be indexed.- Returns:
- The movement index of this unit. May be positive or negative. Higher index values should move first.
-
getEnhancedTargetingControl
Deprecated, for removal: This API element is subject to removal in a future version. -
setEnableEnhancedTargeting
@Deprecated(since="0.51.0", forRemoval=true) public void setEnableEnhancedTargeting(boolean newSetting) Deprecated, for removal: This API element is subject to removal in a future version. -
resetEnhancedTargeting
public void resetEnhancedTargeting(boolean enable) Sets all enhanced targeting controls to default values and optionally enables its use- Parameters:
enable- true to immediately enable enhanced targeting features after reset
-
setEnhancedTargetingTargetTypes
@Deprecated(since="0.51.0", forRemoval=true) public void setEnhancedTargetingTargetTypes(List<Integer> newTargetTypes) Deprecated, for removal: This API element is subject to removal in a future version.Swap out current set of valid enhanced targeting target types for a new set. Automatically removes certain types that will never apply, such as infantry.- Parameters:
newTargetTypes- List ofUnitTypeconstants, may be empty or null to clear
-
setEnhancedTargetingAttackerTypes
@Deprecated(since="0.51.0", forRemoval=true) public void setEnhancedTargetingAttackerTypes(List<Integer> newAttackerTypes) Deprecated, for removal: This API element is subject to removal in a future version.Swap out current set of valid enhanced targeting attacker types for a new set- Parameters:
newAttackerTypes- List ofUnitTypeconstants, may be empty or null to clear
-
seeEnhancedTargetingTargetTypes
Deprecated, for removal: This API element is subject to removal in a future version.Returns a copy of the list of valid enhanced targeting target types- Returns:
- list of
UnitTypeconstants, or empty list
-
seeEnhancedTargetingAttackerTypes
@Deprecated(since="0.51.0", forRemoval=true) public List<Integer> seeEnhancedTargetingAttackerTypes()Deprecated, for removal: This API element is subject to removal in a future version.Returns a copy of the list of valid enhanced targeting attacker types- Returns:
- list of
UnitTypeconstants, or empty list
-
isValidEnhancedTargetingTarget
public boolean isValidEnhancedTargetingTarget(int testType) Checks if the supplied unit type is considered a valid target for enhanced targeting- Parameters:
testType-UnitTypeconstant- Returns:
- true, if unit is a valid target for enhanced targeting
-
isValidEnhancedTargetingAttacker
public boolean isValidEnhancedTargetingAttacker(int testType) Checks if the supplied unit type is considered a valid attacker for enhanced targeting- Parameters:
testType-UnitTypeconstant- Returns:
- true, if unit is a valid attacker for enhanced targeting
-
getAllowCalledShotsOnImmobile
Deprecated, for removal: This API element is subject to removal in a future version. -
setAllowCalledShotsOnImmobile
@Deprecated(since="0.51.0", forRemoval=true) public void setAllowCalledShotsOnImmobile(boolean newSetting) Deprecated, for removal: This API element is subject to removal in a future version. -
getPartialCoverEnhancedTargeting
Deprecated, for removal: This API element is subject to removal in a future version. -
setPartialCoverEnhancedTargeting
@Deprecated(since="0.51.0", forRemoval=true) public void setPartialCoverEnhancedTargeting(boolean newSetting) Deprecated, for removal: This API element is subject to removal in a future version.Controls whether enhanced targeting will be used against targets with partial cover from the shooter. Use with caution as this can result in situations like aiming for a location which is protected by intervening cover.- Parameters:
newSetting- true, to allow aimed/called shots against targets with partial cover
-
checkForEnhancedTargeting
Determine if a shooter should consider using enhanced targeting - aimed or called shots - against a given target. This includes some basic filtering for unit types and equipment such targeting computers.- Parameters:
shooter- Entity doing the shootingtargetable- Hex, Building, or Entity being shot at (Enhanced Targeting only works on the last one)cover-LosEffectsconstant for partial cover, derived fromToHitData.getCover()- Returns:
- true, if aimed or called shots should be checked
-
getAimedShotLocation
protected int getAimedShotLocation(Targetable target, FiringPlan planOfAttack, boolean rearAttack, boolean includeHead) Determine which location to aim for on a general target. Returned location constant is relative to the provided target type. Currently only supports aimed shots against Meks.- Parameters:
target- Entity being shot atplanOfAttack- Proposed attacks againsttargetrearAttack- true if attacking from rear arcincludeHead- true if the head is a valid location, ignored for non-Mek targets- Returns:
- location constant to aim for, with the
LOC_NONEconstant indicating no suitable location
-
getCalledShotDirection
Determine which direction to make a called shot - left, right, high, or low. Some target types only support calling shots left or right. Currently only supports called shots against Meks.- Parameters:
target- Entity being shot atattackSide-ToHitDataSIDE_ constant, indicating attack direction relative to targetplanOfAttack- Proposed attacks againsttarget- Returns:
CalledShotconstant indicating which direction to call, may returnCalledShot.CALLED_NONE.
-
calculateAimedShotLocation
protected int calculateAimedShotLocation(Mek target, List<WeaponFireInfo> aimedShots, boolean rearAttack, boolean includeHead) Determine which location to aim for on a Mek. Prioritizes torsos and legs, and ignores destroyed locations. Prefers right to left, given that most non-symmetrical Meks are 'right-handed'.- Parameters:
target- Mek being shot ataimedShots- Proposed attacks againsttargetrearAttack- true if attacking from the rear arcincludeHead- true to include the head as a valid location- Returns:
Mekconstant for location to shoot, orMek.LOC_NONEfor none
-
calculateCalledShotDirection
protected int calculateCalledShotDirection(Mek target, int attackSide, List<WeaponFireInfo> calledShots) Determine which direction to make a called shot against a Mek - left, right, high, or low. Shots into a side arc will be called to become rear shots. Shots to the front or rear will call high or low based on how many locations have minimal armor.- Parameters:
target- Mek being shot atattackSide-ToHitDataSIDE_ constant, indicating attack direction relative to targetcalledShots- Proposed attacks againsttargetparameter- Returns:
CalledShotconstant indicating which direction to call, may returnCalledShot.CALLED_NONE.
-
setAttackAsAimedOrCalled
protected void setAttackAsAimedOrCalled(WeaponFireInfo shot, int aimLocation, int calledShotDirection, int destructionThreshold) If a shot meets criteria, set it as aimed or called.aimLocationandcalledShotDirectionare not mutually exclusive - if both are provided, weapons which cannot make an aimed shot will make a called shot instead- Parameters:
shot- Single-weapon attack actionaimLocation-MekLOC_ constant with aiming locationdestructionThreshold- how much damage to completely destroy the location
-
calculateMoveTurn
Description copied from class:BotClientDetermines which entity should be moved next and then calls toBotClient.continueMovementFor(Entity)with that entity.- Specified by:
calculateMoveTurnin classBotClient- Returns:
- The calculated move path.
-
calculatePhysicalTurn
- Specified by:
calculatePhysicalTurnin classBotClient
-
calculatePreEndDeclarationsTurn
protected void calculatePreEndDeclarationsTurn()Description copied from class:BotClientCalculate what to do during the PRE_END_DECLARATIONS phase. This phase allows infantry to initiate building/vessel combat.- Specified by:
calculatePreEndDeclarationsTurnin classBotClient
-
calculateInfantryVsInfantryCombatTurn
protected void calculateInfantryVsInfantryCombatTurn()Description copied from class:BotClientCalculate what to do during the INFANTRY_VS_INFANTRY_COMBAT phase. This phase allows infantry to reinforce or withdraw from building/vessel combat.- Specified by:
calculateInfantryVsInfantryCombatTurnin classBotClient
-
continueMovementFor
Description copied from class:BotClient- Specified by:
continueMovementForin classBotClient- Parameters:
entity- The entity who is to move.- Returns:
- The calculated move path.
-
initFiring
protected void initFiring()- Specified by:
initFiringin classBotClient
-
getMovePathsAndSetNecessaryTargets
Function with side effects. Retrieves the move path collection we want the entity to consider. Sometimes it's the standard "circle", sometimes it's pruned long-range movement paths -
updateEntityState
Update the various state trackers for a specific entity. Useful to call when receiving an entity update packet -
initMovement
protected void initMovement()- Specified by:
initMovementin classBotClient
-
initialize
public void initialize()- Specified by:
initializein classBotClient
-
initializeFireControls
public void initializeFireControls()Initialize the fire controls. -
registerFireControl
protected void registerFireControl(FireControl.FireControlType fireControlType, FireControl fireControl) Wiring seam for subclasses (CASPAR): replaces the registered fire control of the given type. Call aftersuper.initializeFireControls(). MirrorsregisterPathRanker(megamek.client.bot.princess.PathRanker.PathRankerType, megamek.client.bot.princess.BasicPathRanker).- Parameters:
fireControlType- the fire control slot to replacefireControl- the replacement fire control
-
initializePathRankers
public void initializePathRankers()Initialize the possible path rankers. Has a dependency on the fire controls being initialized. -
registerPathRanker
Wiring seam for subclasses (CASPAR): replaces the registered path ranker of the given type, wiring the replacement to the precognition path enumerator the same way the stock rankers are wired. Call aftersuper.initializePathRankers().- Parameters:
rankerType- the ranker slot to replacepathRanker- the replacement ranker
-
aeroGroundPathFinder
Factory seam for subclasses (CASPAR): builds the path finder used for airborne aerodyne units flying over a ground mapsheet.Unlike the low-altitude finder, the stock ground finder drives every path it generates to a single altitude, so a ranker never gets an altitude to choose between. Overriding this is the only way to put that choice back without changing what Princess generates.
- Parameters:
game- the current game- Returns:
- the path finder to enumerate ground-mapsheet aerospace movement with
-
computeTeamTagUtility
Reduce utility of TAGging something if we're already trying. Update the utility if it's better, otherwise try to dissuade the next attacker. -
computeGuidedWeapons
Because Aerospace units can either TAG _or_ attack with their weapons, we want every friendly TAG-equipped Aero (and possibly others) to know about all the possible incoming Homing or IF attacks that could take advantage of their TAGs, for later calculations.Steps are: 1. All relevant guidable attacks (within range of the target) are added to a list. 1a. All Homing Weapons landing this turn are added to the list. 1b. All IF-capable, Semi-Guided, and Homing weapons that have not yet fired but _could_ are added as well. 2. Each attacker-target location pair's expected homing/indirect fire damage is cached for later re-use. 3. During the Indirect phase, when TAG attacks are announced, relevant units can use this info to decide whether they want to TAG or reserve their activation for actual attacks. 4. All info is cleared at the start of the next turn.
-
refreshCrippledUnits
public void refreshCrippledUnits()Load the list of units considered crippled at the time the bot was loaded or the beginning of the turn, whichever is the more recent. -
die
public void die()Description copied from class:AbstractClientShuts down threads and sockets- Specified by:
diein interfaceIClient- Overrides:
diein classAbstractClient
-
processChat
- Specified by:
processChatin classBotClient
-
calculateAdjustment
-
checkMorale
protected void checkMorale()- Specified by:
checkMoralein classBotClient
-
getHonorUtil
-
getSpinUpThreshold
public int getSpinUpThreshold()Lazy-loaded calculation of the "to-hit target number" threshold, below which rapid fire autocannon will fire multiple shots. More aggressive behavior (left on the Self Preservation slider) start at TN 11 and under, while less aggressive behavior (right on the slider) start at 4 and under. -
resetSpinUpThreshold
Deprecated, for removal: This API element is subject to removal in a future version. -
endOfTurnProcessing
public void endOfTurnProcessing()- Overrides:
endOfTurnProcessingin classBotClient
-
handlePacket
Description copied from class:AbstractClientThis method is the starting point that handles all received Packets. This method should only be overridden in very special cases such as in Princess to call Precognition.- Overrides:
handlePacketin classAbstractClient- Parameters:
c- The packet to handle
-
sendLoadGame
sends a load game file to the server- Overrides:
sendLoadGamein classClient
-
sendPrincessSettings
public void sendPrincessSettings() -
sendDishonoredData
public void sendDishonoredData()Reports to the server which players this bot currently considers dishonored, so that clients can warn a human player before committing an action that would newly dishonor them. The reported set is fully resolved - it already accounts for pirates having no honor to give - so a receiving client only needs a membership test. -
sendBotSettingsToServer
protected void sendBotSettingsToServer()Description copied from class:ClientHook invoked when the server greets this client, allowing a bot client to push its behavior settings to the server. Non-bot clients have no settings to send, so this default implementation does nothing; bot clients override it.- Overrides:
sendBotSettingsToServerin classClient
-
disconnected
protected void disconnected()Description copied from class:AbstractClientThe client has become disconnected from the server- Overrides:
disconnectedin classAbstractClient
-
shouldAbandon
-
abandonShipOneUnit
protected void abandonShipOneUnit(Entity movingEntity, Vector<Transporter> transporters, MovePath path) -
flagManualAMSUse
public void flagManualAMSUse(int id) Flag an entity as having used manual AMS this round -
usedManualAMS
public boolean usedManualAMS(int id) -
clearManualAMSIds
public void clearManualAMSIds()Clear the manual AMS tracking list -
getEnemyHotSpots
Get a list of all hot spots (positions of high activity) for opposing units -
getFriendlyHotSpot
Deprecated, for removal: This API element is subject to removal in a future version.Get the best hot spot (positions of high activity) for friendly units- Returns:
Coordswith high friendly activity; may return null
-
getFriendlyHotSpot
Get the nearest top-rated hot spot for friendly units -
initEnemyHeatMaps
protected void initEnemyHeatMaps()Set up heat maps to track enemy unit positions over time -
initFriendlyHeatMap
protected void initFriendlyHeatMap()Set up heat map to track friendly units over time -
updateEnemyHeatMaps
protected void updateEnemyHeatMaps()Update the heat maps with known enemy unit positions, then apply decay -
updateFriendlyHeatMap
protected void updateFriendlyHeatMap()Update the heat map with allied unit positions (entities controlled by this bot have already been processed as they move), then apply decay -
sendChat
-
receiveEntityUpdate
Override for the 'receive entity update' handler Updates internal state in addition to base client functionality- Overrides:
receiveEntityUpdatein classBotClient- Throws:
InvalidPacketDataException
-
getSwarmContext
-
getEnemyTracker
-
getCoverageValidator
-
getSwarmCenterManager
Deprecated, for removal: This API element is subject to removal in a future version. -
postMovementProcessing
protected void postMovementProcessing()- Specified by:
postMovementProcessingin classBotClient
-
getArtilleryCommandAndControl
-
revealEntities
protected void revealEntities(int movedEntityID) Given an entity that just moved, decide if I should reveal any entities in response- Overrides:
revealEntitiesin classBotClient
-
decideToRerollInitiative
protected boolean decideToRerollInitiative()Determines whether Princess should reroll initiative using the Tactical Genius special ability.The decision is based on:
- Whether Tactical Genius is available to the player
- Whether it has already been used this round
- The probability that rerolling will improve the net initiative outcome against enemies
Princess will only reroll if currently losing more initiative comparisons than winning, and if the probability of improvement exceeds the configured threshold.
- Overrides:
decideToRerollInitiativein classBotClient- Returns:
trueif Tactical Genius should be used to reroll initiative
-