Skip to content

Fix #8385: ACAR always reporting 100% loss odds in StratCon scenarios#8809

Open
VicenteCartas wants to merge 7 commits intoMegaMek:mainfrom
VicenteCartas:vc/8385
Open

Fix #8385: ACAR always reporting 100% loss odds in StratCon scenarios#8809
VicenteCartas wants to merge 7 commits intoMegaMek:mainfrom
VicenteCartas:vc/8385

Conversation

@VicenteCartas
Copy link
Collaborator

@VicenteCartas VicenteCartas commented Mar 14, 2026

Description

Fixes #8385 — ACAR always reports 100% chance of loss in all StratCon scenarios. Player units were never added to the simulation, so the enemy won instantly every time.

After change, with the campaign from the bug report:
Fix Acar

Root Cause

Two issues in ScenarioSetupForces.sendEntities():

  1. Empty root force name: Formation.getFullMMName() includes the campaign's unnamed root force, producing a forceString like |1||Mech Force|29||Alpha Company|528||.... The leading segment has a blank name, which Forces.verifyForceName() rejects. This caused addTopLevelForce() to return NO_FORCE, and the entire force chain for the player entities silently failed — entities were never added to any force, no player formations were created, and the enemy team won immediately.
  2. Blank forceString fallback: Ally entities (from getAlliesPlayer()) and any units without a campaign formation assignment had no forceString set at all. The existing code only added entities to the game when forceString was non-blank, silently dropping these entities.

Changes

In ScenarioSetupForces.sendEntities():

  1. Assign a default force name to entities with a blank forceString (matching how bot entities are handled).
  2. Strip leading empty-named force segments from the forceString before parsing, so the actual named forces (e.g., "Mech Force", "Alpha Company") are used as the top-level force.

Related

MegaMek companion PR
Fixes #8385

@VicenteCartas VicenteCartas requested a review from a team as a code owner March 14, 2026 05:17
Copilot AI review requested due to automatic review settings March 14, 2026 05:17
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

Fixes StratCon ACAR simulations incorrectly reporting 100% loss odds by ensuring player/allied entities are actually added to the simulation even when their forceString is missing or begins with an empty root-force segment.

Changes:

  • Assigns a default forceString to entities that would otherwise have no force assignment (preventing them from being silently skipped).
  • Normalizes forceString by stripping leading empty-named force segments that break MegaMek force parsing/validation.

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

@codecov
Copy link

codecov bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 13.39%. Comparing base (6e9f6a0) to head (dd2371e).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...ekhq/campaign/autoResolve/ScenarioSetupForces.java 66.66% 0 Missing and 4 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8809      +/-   ##
============================================
+ Coverage     13.22%   13.39%   +0.16%     
- Complexity     7874     7993     +119     
============================================
  Files          1306     1306              
  Lines        169191   169203      +12     
  Branches      25458    25464       +6     
============================================
+ Hits          22383    22668     +285     
+ Misses       144632   144321     -311     
- Partials       2176     2214      +38     

☔ 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
Member

@psikomonkie psikomonkie left a comment

Choose a reason for hiding this comment

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

Code looks fine but the copyright on the new file is incorrect.

HammerGS added a commit to MegaMek/megamek that referenced this pull request Mar 15, 2026
…8094)

## Description
Fixes a deployment timing bug in the ACAR auto-resolve simulation where
formations with deployRound=0 were never deployed.

The ACAR game loop increments the round counter to 1 before the first
deployment check. Both shouldDeployForRound() and DeploymentPhase used
exact equality (==) to match the current round against a formation's
deploy round. Since all formations default to deployRound=0 and the
first round is 1, the deployment phase was always skipped — no
formations from either side ever deployed, and every simulation ended as
a draw.

## Changes
SimulationContext.shouldDeployForRound(): Changed from
containsKey(round) to check for any pending deployment at or before the
current round (<= round).
DeploymentPhase.executePhase(): Changed deployment filter from ==
currentRound to <= currentRound so formations whose deploy round has
already passed are still deployed.

##Related
[MekHQ companion PR](MegaMek/mekhq#8809)
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.

[Issue] StratCon Scenario Auto Resolve: ACAR always reporting 100% loss odds

3 participants