warzone2100
warzone2100 copied to clipboard
Refactor powermodifier.js
powermodifier.js currently has some issues:
- For the player(s), the check for Medium Power levels is missing, this isn't a problem as the game will use the default, however for the sake of easier modding it should be present.
- The power modifiers for the bot difficulty options do not reflect the descriptions, either the power modifiers should be corrected or the descriptions corrected, i have opted for correcting the modifiers.
- The biggest problem: The bots do not use the Power level setting precisely, instead, the current math misses the mark by huge margins.
This PR aims to primarily address the 3rd and biggest problem, the scope can be limited to just the 3rd problem if required. This PR makes the following changes (check the changed files for details):
- Add in the check for Medium Power, this can be omitted if needed, it is not essential to this PR's goals.
- Change the Power Modifiers for the bots to reflect the descriptions. If the players and devs would rather change the description, then that is fine too.
- Change the Power Modifier for the Easy bot to be 25% less as said in the description.
- Change the Power Modifier for the Medium bot to be 10% more, the bots waste a lot of power, and the intent of Medium is a fair match with a competent AI, most average players playing casually can defeat the Medium bot as is, this aims to make things more equitable. This change can be dropped if needed.
- Change the Power Modifier for the Hard bot to be exactly 50% more as intended. Currently, the description does not mention this, ~~i will update this PR later with an updated description.~~
- Change the Power Modifier for the Insane bot to be 100% more as said in the description.
- Major refactor of the power modifiers for the bots to use the selected Power level, and then apply the difficulty nerf or buff based on that.
To conclude, the primary goal of this PR is to make the bots properly use the Power level setting, so that they behave more like real players, it also prevents situations in which the strength of the bots is not what the player expected, as the player expects the bots to use the Power level setting.
I'm not sure why you add all those if statement if all you try to do is to make power = (85+powerType*20)*difficultyFactor
I just want to throw it here : I give an UBI to all players in NRS that amount to 2/5 of the total expected power in the map, Turns out scaling that UBI with the bots makes the AI much more predictable than scaling just the oil power. Most of the excess power usage that AI use comes from the research that they do very poorly and base building that they don't always need.
So UBI for all AIs! That's my slogan for the day...
I'm not sure why you add all those if statement if all you try to do is to make power = (85+powerType*20)*difficultyFactor
I just want to throw it here : I give an UBI to all players in NRS that amount to 2/5 of the total expected power in the map, Turns out scaling that UBI with the bots makes the AI much more predictable than scaling just the oil power. Most of the excess power usage that AI use comes from the research that they do very poorly and base building that they don't always need.
So UBI for all AIs! That's my slogan for the day...
Ahh yes, i see what you mean. Yeah, i can greatly simplify it to just 1 line that way.
As for the rest of your comment, i want this PR to be as uncontroversial as possible, i am sure your suggestion would be very controversial. I also don't want to change or affect the balance outside of the bots.
I am an idiot, i just realized the current code is trying to do the same thing i am doing, it just sucks at it.
Hmm... Should the documentation i added inside powermodifier.js be moved into a separate doc file?
You could do something like this:
let diffMod = 1;
if (playerData[player].isAI)
{
if (playerData[player].difficulty === EASY)
{
diffMod = 0.75;
}
else if (...)
}
setPowerModifier((85 + 20 * powerType) * diffMod, player);
This way the formula doesn't get duplicated a bunch.
I like the approach you've taken here, nice work.
"Change the Power Modifier for the Medium bot to be 10% more, the bots waste a lot of power, and the intent of Medium is a fair match with a competent AI, most average players playing casually can defeat the Medium bot as is, this aims to make things more equitable. This change can be dropped if needed. Change the Power Modifier for the Hard bot to be exactly 50% more as intended."
My thoughts are that for Easy and Insane this makes sense to have modifiers in place... but for both Medium and Hard I'd prefer those to be untouched, in the way of no bonus modifier being applied.
Whether others agree or disagree, the thought occurs that having an option within the menu UI to Enable / Disable power modifiers per AI bot and or Human players as a kind of handicap option would be useful for this (separate from difficulty), so it can be set maybe even dynamically within a given range. Though let us keep it simple here, with AI bots first.
When it comes to having competent playing AI bots at each difficulty level in an equitable manner to each other whilst being appropriately scaled, this is best solved directly within the AI bot code itself. Something to which I am currently undertaking and wish to provide.
My thoughts are that for Easy and Insane this makes sense to have modifiers in place... but for both Medium and Hard I'd prefer those to be untouched, in the way of no bonus modifier being applied.
Hard already gets a ~50% bonus (it varies between ~30% and ~50%), this PR aims to improve the code, and not make any big changes to the way the game plays, so removing the bonus for hard would be a separate PR.
As for the 10% bonus for medium, it will do for now, until the AIs can be improved.
I think i will update the translatable strings, there shouldn't be any issues if i do.
I think i will update the translatable strings, there shouldn't be any issues if i do.
Please do not do this - these files are updated by a maintenance task on our GitHub CI, and it makes it more difficult to merge and review changes.
Please do not do this - these files are updated by a maintenance task on our GitHub CI, and it makes it more difficult to merge and review changes.
Ahh, i see. I misunderstood https://github.com/Warzone2100/warzone2100/blob/master/doc/Translations.md#notes-for-developers (my mistake, the wording there is fine)
After testing against bots for a while with these changes, i have determined that the +10% bonus for medium bots was too much (a few extra tanks makes a big difference in non-NTW). I have also observed that hard and insane are far more difficult than before, i think this is because the average power modifier bonus has increased with this PR. Easy bots are also far easier now (same reason, in reverse).