Skip to content

Commit

Permalink
Comment cleanup and slight tweak to range filter for bombs
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Jan 8, 2024
1 parent 3054e47 commit e4260eb
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
12 changes: 5 additions & 7 deletions megamek/src/megamek/client/bot/princess/Princess.java
Original file line number Diff line number Diff line change
Expand Up @@ -1666,13 +1666,11 @@ public void initializePathRankers() {
* 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.
*
* Note: this is a very rough first draft. Currently order is O(n*w), near enough to O(n^2).
*
* Steps are:
* 1. All relevant guidable attacks are added to a list.
* 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 TAG-capable Aerospace unit is given a reference to this list.
* 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.
Expand All @@ -1699,7 +1697,7 @@ public ArrayList<Mounted> computeGuidedWeapons(Entity entityToFire, Coords locat
}
}

// Next find all friendly IFers, be-Guided-ers, and TAGgers in the sky.
// Next find all friendly Homing-weapon-havers, Indirect-Firers, and LG-Bombers within range.
for (Entity f : new HashSet<Entity>(getEntitiesOwned())) {
if (f.equals(entityToFire)) {
continue; // This entity's weapons should not be considered for this calculation
Expand All @@ -1709,8 +1707,8 @@ public ArrayList<Mounted> computeGuidedWeapons(Entity entityToFire, Coords locat

for (Mounted m : f.getTotalWeaponList()) {
WeaponType w = (WeaponType) m.getType();
// Ignore weapons outside of viable long range
if (fLoc.distance(location) > w.getLongRange() + f.getRunMP()) {
// Ignore weapons outside of viable long range; does not apply to bombs.
if (fLoc.distance(location) > w.getLongRange() + f.getRunMP() && !m.isGroundBomb()) {
continue;
}
if (Compute.isIndirect(w) && !f.isAero()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,6 @@ private WeaponAttackAction buildBombAttackAction(final HashMap<String, int[]> bo
/**
* Aerospace units need to think carefully before firing TAGs at ground targets, because this
* precludes firing _any_ other weapons this turn.
* May be a high-demand calculation so only use when appropriate.
* @return expected damage of firing a TAG weapon, in light of other options.
*/
double computeAeroExpectedTAGDamage(){
Expand Down

0 comments on commit e4260eb

Please sign in to comment.