Fix princess detecting hidden units through expected damage calcs#7956
Fix princess detecting hidden units through expected damage calcs#7956Sleet01 wants to merge 2 commits intoMegaMek:mainfrom
Conversation
aaaf385 to
8678020
Compare
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
megamek/unittests/megamek/client/bot/princess/WeaponFireInfoTest.java
Dismissed
Show dismissed
Hide dismissed
There was a problem hiding this comment.
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.
Princess has been observed using finding hidden units and bombing them before they could be detected.
It looks like the mechanism is this:
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: