Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored autoAwards Kill Handling for Improved Reliability #4539

Merged
merged 9 commits into from
Aug 8, 2024

Conversation

IllianiCBT
Copy link
Collaborator

@IllianiCBT IllianiCBT commented Aug 1, 2024

Requires #4573, merge order unaffected

Rewrote how autoAwards handles lifetime and mission-based kills to more reliably read the TO&E and with a mind to reducing the amount of parses made across both the TO&E and when retrieving kills from a force.

This takes advantage of our new TO&E reading functionality, which allows users to better handle non-traditional TO&E layouts - for example, TO&Es in which the deepest formation is not a lance, but is actually a company.

Closes #4514

Replaced LogManager with MMLogger across AutoAwardsController for consistency and better logging abstraction. Introduced pre-processed kill data map in KillAwards to improve kill awards processing efficiency.
@IllianiCBT IllianiCBT self-assigned this Aug 1, 2024
@IllianiCBT IllianiCBT marked this pull request as draft August 1, 2024 23:58
@codecov-commenter
Copy link

codecov-commenter commented Aug 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 10.32%. Comparing base (b5ff179) to head (07c54c7).
Report is 6 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff            @@
##             master    #4539   +/-   ##
=========================================
  Coverage     10.32%   10.32%           
  Complexity     5816     5816           
=========================================
  Files           935      935           
  Lines        128792   128780   -12     
  Branches      18951    18943    -8     
=========================================
  Hits          13296    13296           
+ Misses       114220   114208   -12     
  Partials       1276     1276           

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

IllianiCBT and others added 2 commits August 1, 2024 19:31
# Conflicts:
#	MekHQ/src/mekhq/campaign/personnel/autoAwards/AutoAwardsController.java
@repligator
Copy link
Collaborator

New campaign. I forgot to actually turn on auto-awards until part way through the first mission. All the kills were cheesed by using GM mode to change the weather to an F4 tornado and manually assigning them after the scenario. Everything looks fine to me, but I've attached the logs/save in case you want to look them over.

mekhq.log
megamek.log
KillAwardTest30351227.cpnx.gz

@IllianiCBT
Copy link
Collaborator Author

Ok, that's a good sign. Fingers crossed this should be good to go.

I'm going to hold off marking this as live until I've got a couple more confirmations, but it passing the 'not immediately breaking' test fills me with some confidence.

@repligator
Copy link
Collaborator

repligator commented Aug 3, 2024

Different new campaign. I used command line nukes this time instead of tornadoes.

before-early-completion-TOE-AWARD-TEST30350410.cpnx.gz

mekhq.log

When I try to complete the mission early, MHQ freezes. Running in debug mode and setting a breakpoint shows that line 156 of KillAwards.java is running over and over, on the same person every time.

person = 0d49973a-2611-454a-ad9c-9329786c6603
parentForce: "A Company"
parentForce: "1st Battalion"

Hitting resume program switches between the company and the Battalion, but the person never changes. If I mute the breakpoint, MHQ freezes, and none of the other breakpoints I set get hit. If I turn the breakpoint back on, it goes right back to the same person, switching between company and battalion.

The person in question is Colonel Gobnat Bagss. MHQ commanding officer, as well as the commander of A Companies A Lance. Read top to bottom, she is the first person, in the first lance, in the first company, in the first battalion, in the first (and only) regiment, in the campaign.

IllianiCBT and others added 4 commits August 7, 2024 14:01
Added a missing recursion element to ensure the TO&E is read correctly.
Streamlined the kill processing logic in AutoAwardsController using Java Streams to reduce redundancy. Improved the handling of force traversal in KillAwards to avoid re-evaluation of previously visited nodes, enhancing both performance and readability.
@IllianiCBT IllianiCBT marked this pull request as ready for review August 8, 2024 01:30
@IllianiCBT
Copy link
Collaborator Author

Flipping this to live. It is no longer in draft.

@IllianiCBT IllianiCBT merged commit 0e12f4a into MegaMek:master Aug 8, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[0.50.0-SNAPSHOT] AutoAward misinterprets TOE for formation kills
4 participants