Skip to content

Fix princess detecting hidden units through expected damage calcs#7956

Open
Sleet01 wants to merge 2 commits intoMegaMek:mainfrom
Sleet01:Fix_princess_detecting_hidden_units_through_expected_damage_calcs
Open

Fix princess detecting hidden units through expected damage calcs#7956
Sleet01 wants to merge 2 commits intoMegaMek:mainfrom
Sleet01:Fix_princess_detecting_hidden_units_through_expected_damage_calcs

Conversation

@Sleet01
Copy link
Collaborator

@Sleet01 Sleet01 commented Feb 4, 2026

Princess has been observed using finding hidden units and bombing them before they could be detected.
It looks like the mechanism is this:

  1. Princess brings an Aerospace unit loaded with bombs to a fight that includes hidden units.
  2. Princess plots a flight path (in ignorance of the hidden units)
  3. In order to determine whether she should bomb any hexes along the flight path, Princess predicts how much damage each carried bomb would do to A) enemies, B) friendlies, and C) buildings, for _any level:coords pair in the bomb's blast zone.
  4. Dive bomb the hex that produces the highest expected damage score and the lowest expected friendly damage score.

Since step 3 does not ignore hidden units, this means she can find concentrations of hidden enemies anywhere along her ASF's flight path, out to the max radius of her largest bomb. She doesn't see the units, but she sees the potential damage-dealing benefit, so she bombs the best hex even if the entities that will be damaged are otherwise hidden.

This, obviously, is sub-optimal.

Testing:

  • Ran all 3 projects' unit tests.
  • Added a new unit test to prove hidden units are ignored now.
  • Set up bot-vs-player game with all hidden units but one, showing she does not detect the hidden units.

@Sleet01 Sleet01 requested a review from a team as a code owner February 4, 2026 04:43
@Sleet01 Sleet01 force-pushed the Fix_princess_detecting_hidden_units_through_expected_damage_calcs branch from aaaf385 to 8678020 Compare February 4, 2026 04:45
@HammerGS HammerGS requested a review from Copilot February 4, 2026 04:48
@codecov
Copy link

codecov bot commented Feb 4, 2026

Codecov Report

❌ Patch coverage is 0% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 29.78%. Comparing base (fe0b8b7) to head (8678020).
⚠️ Report is 72 commits behind head on main.

Files with missing lines Patch % Lines
...rc/megamek/client/bot/princess/WeaponFireInfo.java 0.00% 2 Missing and 1 partial ⚠️
...k/src/megamek/client/bot/princess/FireControl.java 0.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##               main    #7956    +/-   ##
==========================================
  Coverage     29.77%   29.78%            
- Complexity    16655    16732    +77     
==========================================
  Files          3134     3140     +6     
  Lines        301874   302387   +513     
  Branches      52863    52952    +89     
==========================================
+ Hits          89895    90052   +157     
- Misses       202646   202978   +332     
- Partials       9333     9357    +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request fixes a bug where the Princess bot could detect and bomb hidden enemy units by calculating expected bomb damage before those units were visible. The fix adds checks to skip hidden units in bomb damage calculations and target selection.

Changes:

  • Added isHidden() checks to filter out hidden entities in bomb damage calculations
  • Modified dive bomb targeting logic to reject hidden entities as targets
  • Added comprehensive unit test to verify hidden units are properly excluded from damage calculations

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
megamek/src/megamek/client/bot/princess/WeaponFireInfo.java Added isHidden() checks in computeExpectedBombDamage() (line 811) and initDamage() (lines 951-954) to exclude hidden entities from damage calculations
megamek/src/megamek/client/bot/princess/FireControl.java Updated getDiveBombPlan() to return empty plan when target is hidden (line 1993) and added comment explaining the check (line 1987)
megamek/unittests/megamek/client/bot/princess/WeaponFireInfoTest.java Added new test computeExpectedBombDamageDoesNotShowHidden() to verify hidden units are excluded, and added necessary imports for the test

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant