-
Notifications
You must be signed in to change notification settings - Fork 708
Revamp nation/bot enemy selection 🗡️ #2550
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
base: main
Are you sure you want to change the base?
Revamp nation/bot enemy selection 🗡️ #2550
Conversation
WalkthroughThis pull request centralizes and refactors bot attack decision-making by moving target selection logic from execution classes into BotBehavior. BotExecution delegates to Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes
Possibly related PRs
Suggested labels
Suggested reviewers
Poem
Pre-merge checks✅ Passed checks (3 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Description:
I closed my previous PR #2533 which was already reviewed by evan but not yet merged because I noticed some issues.
Which led me to changing the enemy selection entirely.
Nations / Bots previously had a fixed enemy which they kept for 100 ticks (10 seconds). This could make them react too late and feel slow. Now they are a bit more responsive.
But the main benefit: Without a fixed enemy we can do multiple sendAttack() on the same tick, which allowed me to give impossible nations extremely efficient parallel bot attacks:
2025-12-02-19-00-36_g088wvHG.mp4
Previously nations were so slow in taking out bots that you could even encircle them on the Archiran map...
Now they are like 200% faster (but only on the impossible difficulty)
Nuke enemy selection
Previously, the enemy for troop attacks and nukes was identical. Now, as we no longer have a fixed enemy in BotBehaviour, I added findBestNukeTarget() to select better nuke-targets. I will probably open a PR soon which makes nations nuke the crown :)
Betrayal logic
While revamping the attack logic I had to work on the betrayal logic, which was quite confusing, with many negations. And the betrayals were just random.
So I made it easier to understand with maybeBetrayAndAttack().
Now it does betray friends if we have 10 times more troops than them. I will improve that method in a future PR, but already now it should be better than just betraying randomly.
Attack order
Previously, nations attacked in this order:
Now its in this order:
So the changes are these:
I also changed the attack order of bots a bit (retaliate before attacking randoms), but that isn't even noticeable.
Big bug fixed
Additionally, I fixed a big bug: selectEnemy() oftentimes returned null (because of enemySanityCheck) and therefore no attack happened.
This was especially visible in games where nations are surrounded by friends (Team games and nations vs humans).
This was also the reason why Enzo could play nations vs humans in singleplayer and NO NATION of the much bigger nation team would try to attack him.
Please complete the following:
Please put your Discord username so you can be contacted if a bug or regression is found:
FloPinguin