-
Notifications
You must be signed in to change notification settings - Fork 1.8k
AI denounce automation #14036
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: master
Are you sure you want to change the base?
AI denounce automation #14036
Conversation
|
For those with time to test:
I am aware there are some missing components from Civ V. For example AI denouncing due to constructing a wonder they coveted. Though in that particular case, I would suggest applying the penalty directly to the relationship opinion. This would be easy to implement (just another diplomacy flag), provide transparency to the end user, and be automatically compatible with the denunciation logic in this PR. |
|
This is a little too involved for me at the moment, I don't have the brainpower for it currently, sorry -_- |
|
Don't know what any of this means, but I applaud your efforts. |
|
I can make it even more unlikely for the AI to denounce others, if that is preferred when rolling out. It's not a significant amount of code, so it can be easily replaced or expanded later, such as with PR. Otherwise please share concerns or criticisms. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |
|
Conflicts have been resolved. |
|
@SomeTroglodyte If you have time can you take a look at this? |
tests/src/com/unciv/logic/civilization/diplomacy/DiplomacyManagerTests.kt
Show resolved
Hide resolved
|
|
||
| // limit how many civs we can denounce similtaneously | ||
| // TODO: replace this with logic to consider consequences of denouncing others | ||
| val maxActiveDenunciations = 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, it may be better to collect hardcoded (tweakable for balancing) values in a companion as const val... But this - shouldn't it scale somehow with number of civs in the game?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, possibly. This was not part of my original implementation, but I figured I'd add it as a backstop for the known issue in Civ V where the AIs go on a denouncing spree.
My imagined scenario is:
- X is an unfriendly warmonger
- The world gangs up on (denounces) X
- X is angry with everyone because they denounced them
- X counter denounces everyone because their poor relationship makes them prone to doing so
I think it is realistic that the world can gang up on a warmonger (not that this will happen often given the currently extremely lax attitudes against warmongering), but not so realistic that the victim denounces everyone in return, as that is detremental to themself. Ideally they should consider the impact of denouncing others, such as by attempting to preserve existing alliances etc., but that might not be so easy to implement.
I think a possible remidy for this could be:
If a civ is denounced by many others, its opinion of each of them doesn't drop by the full 35, but rather some lower value, i.e. they become numb to being denounced.
For example, when they are first denounced, their opinion would drop by 35. The second denunciation might also hurt, but a little less, say 25. Then 20 for the third one, and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
they become numb to being deloused
So much to read... So I did a code inspect pass only first. Haven't read the comments yet. Need to visit doctor now.... later. None of my nags would be gamebreaking though, and I feel 'loof' was thorough and would trust that their balancing produced more pleasing AI behaviour than current code. Which may need rebalancing if my suspicion EMA was done incorrectly holds true. |
|
All right, collecting my opinion from this thread...
|
|
Thanks for the comprehensive feedback. Will work through it all, but need some time. |
|
This pull request has conflicts, please resolve those before we can evaluate the pull request. |










Currently the AI will only ever denounce others when they themselves are denounced (as a reflex).
This PR introduces more reasonable AI denunciation automation logic that considers how rapidly their opinion of another civ has dropped, as well as their current relationship. It also has a hook for a denounce willingness personality trait.
It does not copy logic from Civ V, but is an attempt to imitate it.
It measures the change in opinion across multiple turns by keeping a memory of past opinions. This is represented as an exponential average (a single value) that perpetually converges with the current opinion. It can be adjusted to only consider the change in opinion from the previous turn (period=1), or to consider the cumulative opinion drop across multiple turns (period>1).
The smoothing period is currently set to (30 * game speed modifier), but a fixed value can be used if preferred.
The change in opinion, used to determine whether to denounce the other civ, is calculated as the difference between the actual opinion and the smoothed opinion (memory).

The opinion change required to denounce another civ is conservatively set to -65 for neutral relationships (opinion=0).

It is higher for adversaries (more likely to denounce), and lower for friends (less likely to denounce).
A very low initial value of -250f is set as the smoothed opinion (memory) in savefiles where an already encountered civ does not have a value associated with it. This is primarily relevant for savefiles created prior to this version, to prevent sudden mass denunciations when updating the game.
Denunciation will not happen if at war, if there is an active DoF, or if a previous denunciation is in effect.
Testing:
Observations:
I have placed the smoothed opinion variable in DiplomacyManager, and the logic to determine whether to denounce in DiplomacyAutomation.
Feedback is appreciated.