Skip to content
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

Refactor powermodifier.js #3725

Closed
wants to merge 34 commits into from

Conversation

Arithyce
Copy link

@Arithyce Arithyce commented Apr 5, 2024

Closed.

@Arithyce Arithyce changed the title Refactor powermodifier.js [WIP] Refactor powermodifier.js Apr 5, 2024
@Iluvalar
Copy link
Contributor

Iluvalar commented Apr 6, 2024

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...

@Arithyce
Copy link
Author

Arithyce commented Apr 6, 2024

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.

@Arithyce
Copy link
Author

Arithyce commented Apr 6, 2024

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.

Simplify the logic for the player(s) to 1 line as well.
Add some help for modders.
Extend the modding help info.
@Arithyce
Copy link
Author

Arithyce commented Apr 7, 2024

Hmm... Should the documentation i added inside powermodifier.js be moved into a separate doc file?

Remove `~` to make it clearer that the percentages are now exact.
Remove `~` to make it clearer that the percentages are now exact.
Remove `~` to make it clearer that the percentages are now exact.
Remove `~` to make it clearer that the percentages are now exact.
Remove `~` to make it clearer that the percentages are now exact.
Remove `~` to make it clearer that the percentages are now exact.
Remove `~` to make it clearer that the percentages are now exact.
@Arithyce Arithyce marked this pull request as ready for review April 11, 2024 00:21
@Arithyce Arithyce changed the title [WIP] Refactor powermodifier.js Refactor powermodifier.js Apr 11, 2024
@KJeff01
Copy link
Member

KJeff01 commented Apr 15, 2024

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.

@Chewbakka-Wakka
Copy link

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.

@Arithyce
Copy link
Author

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.

@Arithyce
Copy link
Author

I think i will update the translatable strings, there shouldn't be any issues if i do.

Add the new/changed strings, this also includes stuff from the campaign update, but that shouldn't be an issue.
@past-due
Copy link
Member

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.

@Arithyce
Copy link
Author

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)

@Arithyce
Copy link
Author

Arithyce commented May 3, 2024

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).

@Arithyce Arithyce closed this May 3, 2024
@Arithyce Arithyce deleted the power_modifier_refactor branch May 3, 2024 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants