Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Scoppio
Copy link
Collaborator

@Scoppio Scoppio commented Feb 9, 2025

What it does?

The Better Facing Mod uses the median of the 5 closest enemies as the center position to face towards. The number 5 is completely arbitrary, but I think it is a good compromise betwen "sheer numbers" and emergency.

The new algorithm added is very direct:

  • It sort enemies for the distance away from the unit.
  • Units that have not moved are considered as if they were going to move directly towards the unit.
  • The top 5 closest units are chosen.
  • The median of the current position of the units is picked up as the target to face towards.
  • The final facing is decided also basing upon which side of the entity has more armor left. It is using a very simple calculation which should be further improved in the future to consider things like exposed internals, XL engines, sides containing ammo bins. It is also missing other types of vehicles, as only Meks are considered in this bias for facing left or right side.

The result we can see in this image, im yellow we have the warhammer looking towards the Wraith, its closest enemy. In Green we have the median position of the 5 enemies closest to the Warhammer, with the new algorithm, the Warhammer would be facing towards that point instead.

Screenshot 2025-02-08 at 22 49 49

@Scoppio Scoppio self-assigned this Feb 9, 2025
@Scoppio Scoppio added the Princess/AI Issues or PR that relate to the current Bot AI label Feb 9, 2025
@codecov
Copy link

codecov bot commented Feb 9, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.57%. Comparing base (a4f835c) to head (8359a10).
Report is 113 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #6523      +/-   ##
============================================
+ Coverage     28.56%   28.57%   +0.01%     
- Complexity    14495    14508      +13     
============================================
  Files          2815     2815              
  Lines        277388   277474      +86     
  Branches      49002    49011       +9     
============================================
+ Hits          79226    79284      +58     
- Misses       193446   193469      +23     
- Partials       4716     4721       +5     

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

@Scoppio
Copy link
Collaborator Author

Scoppio commented Feb 9, 2025

Results are promising, but once the ball of death happens, things start to go out of the window:

Screenshot 2025-02-08 at 23 37 19 Screenshot 2025-02-08 at 23 37 49 Screenshot 2025-02-08 at 23 38 02 Screenshot 2025-02-08 at 23 41 03 Screenshot 2025-02-08 at 23 42 58 Screenshot 2025-02-08 at 23 43 18 Screenshot 2025-02-08 at 23 43 43 Screenshot 2025-02-08 at 23 45 00

Copy link
Collaborator

@Sleet01 Sleet01 left a comment

Choose a reason for hiding this comment

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

LGTM, although I think some of this code was also in the AI Tools PR so there may be some merge errors.

We might be able to get this behavior if we added facing awareness to the code that assesses Crit and Kill chances (when Princess is figuring out how painful a given path might be to the moving unit).
Currently it always assumes the shots are coming from the front, but making back shots accurately reflect their higher crit and kill chances might make Princess face differently for less work...

@HammerGS HammerGS merged commit 0cb8886 into MegaMek:master Feb 9, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Princess/AI Issues or PR that relate to the current Bot AI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants