-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add global constants for damage roll related code and make AverageRollDmg faster #4663
Conversation
I should note that the initial intent for these boundaries was specifically to give the user control over how the AI perceives damage rolls in their calculations, and not affect the calculations of actual damage themselves. Using the same constants in the DoDamage calcs removes this feature, which was its intended use. |
That seems like a strange design choice, but I could restore it. |
It's for users who would prefer the AI behave more like a human. A human running damage calcs in a competitive game is very unlikely to consider the highest rolls in the vast majority of cases because of how unlikely they are, and is more likely to make decisions around KO thresholds based off say a 66% or a 50% damage roll threshold most of the time. This lets users have the AI emulate those lines of thinking without altering the actual damage calculation. I'm on board for adding the new defines that do directly affect the damage calculation, that's an interesting knob to control, but I'd keep them completely separate from how the AI manages its rolls when making decisions. |
You made it use the average roll by default and added the conservative flag. Do these not do the same thing? |
Separately, I'm not sure the change to speed up I'm not sure whether it's considered better practice to futureproof or maximize efficiency, but I thought it worth mentioning that there is a difference in what approach is preferred here :) |
No, because the conservative flag uses lowrolls and the average flag uses an exactly average roll. If you don't want the AI to consider say the upper third of results because rolls only have a ~33% chance of falling in that range, you can adjust their thinking manually by setting the upper bound constant to 95 and the lower bound to 85. This supports all of the permutations of AI behaviour, risky, standard and conservative, but gives flexibility on what roll bounds the AI uses across the board for the reasons I mentioned above, again without actually impacting the damage itself. |
src/battle_ai_util.c
Outdated
dmg /= 100; | ||
return dmg; | ||
} | ||
|
||
static inline s32 AverageRollDmg(s32 dmg) | ||
{ | ||
dmg = ((HighestRollDmg(dmg) + LowestRollDmg(dmg)) * 100) / 2; | ||
dmg = (dmg * (DMG_ROLL_PERCENT_LO + DMG_ROLL_PERCENT_HI)) / 2; |
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.
Could you change the equation to always result in the 9th roll of the damage? I brought it up before and ultimately thought it didn't matter much but I think it is crucial for the debug menu to have the correct value shown. Right now the calc could end up in a non existing roll.
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.
I have absolutely no idea what this means.
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.
The current calculation calcs an average but the average can end up between roll 8 and 9. This doesn't matter for the actual damage calculations but it will affect the values in the debug menu.
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.
I still do not follow. What is a "roll 8" and "roll 9?"
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.
Discord contact info
duke5614