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

Add description of playing strength and difficulty levels to AI tooltips #419

Merged
merged 6 commits into from Jul 4, 2019

Conversation

@Forgon2100
Copy link
Contributor

commented Jul 2, 2019

The AIs installed by default in this game are listed by alphabetical order of
their JSON files. The default AI is supposed to be the first entry.
A typo caused NullBot to be on top of the list by mere accident, so that adding
other AIs like Cobra could cause bugs (see ticket:4791).
Identifying the default AI by its filename rather than its human-friendly name
fixes this problem and should prevent similar accidents in the future.

AI names and tooltips are translated properly.
When names or tooltips are missing in JSON files, a warning is printed instead.
To prevent AI properties from being mistranslated, the list of AIs is reloaded
every time the game language is changed via "Options->Game Options->Language".
This completes 509f6bc of #281.

The playing strength of AIs relative to each other has been measured by
Prot in his AI tournament.
Its results were shown at http://wz2100.euphobos.ru/wzait which is now
offline but was archived on 23 October 2018 at https://archive.fo/QtSjR.
Results for default AIs (note that draws are defined as 2 hours of
playing time without a winner
):

name wins losses draws
NullBot 18927 (59.2%) 12773 (39.9%) 261 (0.8%)
Semperfi JS 20180321 1806 (43.1%) 2355 (56.2%) 23 (0.5%)

Hover AI, Nexus, SemperFi and Turtle AI were not tested.
Another problem is that not all AIs played against the same opponents,
and that most AI opponents are only available as mods.

I have considered trying to improve upon Prot's results with an AI
tournament of my own, but do not own the necessary hardware.
Unfortunately, it would take my computer months to generate better data.
There are also a couple of AI-related bugs that make testing difficult.

Wins, losses and draws can be stored in an AI's JSON file, as below:

        "wins": 18927,
        "losses": 12773,
        "draws": 261

If such data are available, AI tooltips list them as percentages in
a line below the usual AI description:

ai_tooltip_new

More detailed descriptions of difficulty levels can also help players to
choose an AI. In particular, they might want to know whether AIs cheat.
To that end, their JSON files contain new keys. Example:

        "easy_tip": "Gets ~ 25% less power from each oil derrick",
        "medium_tip": "Research speed +40% (per minute)",
        "hard_tip": "Research speed +60% (per minute)",
        "insane_tip": "Gets ~ 100% more power from each oil derrick\nResearch speed +80% (per minute)\nStarts with defensive structures and oil derricks"

Just like the playing strength data, they are optional. This ensures
backward compatibility for AI mods. If present, tooltips print the
difficulty levels below the generic labels for AI difficulties:

ai_difficulty_chooser_new

All AIs share the cheats defined in data/mp/multiplay/skirmish/rules.js:

  • power bonuses depending on power level and AI difficulty:

    power easy medium hard insane easy/medium insane/medium
    low 70 85 85 200 .82 2.35
    medium 75 100 100 215 .75 2.15
    high 80 125 125 230 .64 1.84
  • on Insane difficulty, some buildings are not removed from the map:

    • Start with No Bases: walls, gates, defenses, oil derricks
    • Start with Bases: as above, but without gates

Nexus cheats outside of multiplayer games for all difficulties except
Easy with the function scrSkDifficultyModifier() in src/scriptai.cpp:

  • research costs are reduced every minute (40% for Normal, 60% for Hard,
    80% for Insane). This is easily observable with the bot as an ally.
  • its power bonus cheat is broken and only causes this warning message:
    warning |17:00:00: [recvGift:87] Gift (4) from 99, to 1, queue.index 0 (**Further warnings of this type are suppressed.)
    
  • unit limit cheating has not yet been re-observed
  • production and construction using technologies not yet researched
    may no longer be a problem, judging from commits like those below:

SemperFi

  • does not build defenses near enemy oil derricks with difficulty Easy
  • never attempts a truck rush with difficulties Easy or Medium

NullBot

  • randomly changes its personality every 30 seconds on difficulty Easy
  • always uses the standard build order on Insane (not worth mentioning)
  • tries to avoid building units without an HQ being built for all levels
    except Insane. This hack may be obsolete due to #378 and #394.
  • does not tweak its adaption mechanisms depending on difficulty level,
    as it once did
  • sees everything on the map (a.k.a. visibility cheating). However, NoQ
    has often written that this is not noticeable, and I agree with this.

TurtleAI behaves like NullBot. So does HoverAI, but since it has only a
single personality, it cannot change it on difficulty level Easy.

SemperFi JavaScript has no exceptions for different difficulty levels.

If an AI cannot be changed by a player, its difficulty tooltip is shown.

Challenges no longer show the "Difficulty locked" tooltip:

locked_challenge_ai_difficulty_new

Players who join multiplayer games will also see AI difficulty tooltips:

multiplayer_joining_ai_difficulty_new

Note that this PR contains new messages that will need to be translated.

The attached ZIP file contains

  • all 4 images shown in this summary, shot before and after this PR
  • a shell script to generate them

ai_tooltips_documentation.zip

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented Jul 2, 2019

Looks pretty neat. Will test some later time.

Unfortunately, there are no accurate tournament ratios for current SemperFi-JS. The ratios you used were from how it was in 3.2.3 and if you try current SemperFi-JS against NullBot, Cobra, or BoneCrusher! a few times you'll easily see it doesn't lose 86% of matches, 1v1 or teamed, on T1 no bases. The most accurate would be the 2018 variant, however, that has a lot less games played with. :/

Bots can build units as soon as they can research the necessary components. It's up to the bot maker to choose what rules to follow, or invent, for their unique bot.

@Forgon2100 Forgon2100 force-pushed the Forgon2100:ai_tooltips branch from 645ba32 to 6e6c5ae Jul 2, 2019

Forgon2100 added a commit to Forgon2100/warzone2100 that referenced this pull request Jul 2, 2019
Add optional playing strength descriptions for AIs
* support the following numerical keys in JSON files for AIs:
  * "wins"
  * "losses"
  * "draws" (games without a winner after several hours of game time)

* keys contain data about playing strength of AIs relative to eath other

* if at least one key value is non-zero, calculate percentages and print
  these data in an extra line of AI tooltips with some translatable text

* fill out key values for NullBot and SemperFi JavaScript, based on an
  AI tournament by EuPhobos (forum username: Prot) from 23 October 2018,
  when its results were archived at https://archive.fo/QtSjR

Fixes Warzone2100#419
@Forgon2100

This comment has been minimized.

Copy link
Contributor Author

commented Jul 2, 2019

[...] Unfortunately, there are no accurate tournament ratios for current SemperFi-JS. The ratios you used were from how it was in 3.2.3 and if you try current SemperFi-JS against NullBot, Cobra, or BoneCrusher! a few times you'll easily see it doesn't lose 86% of matches, 1v1 or teamed, on T1 no bases. The most accurate would be the 2018 variant, however, that has a lot less games played with. :/ [...]

Thanks. I have updated the SemperFi JavaScript data.

@KJeff01 KJeff01 added this to the 3.3.0_beta2 milestone Jul 3, 2019

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2019

Garbage character(s) are printed before the difficulty tips, both when players join a game or the player is in a challenge when using autotools and optimizations with GCC 9.1. Tested on O1, O2, and O3. No optimizations don't exhibit this.

Building with Cmake and GCC 8.3 causes something else. The cmake build keeps corrupting the tips to something different when switching between a skirmish and a challenge, and repeating the real tip by whatever player number the AI is, which was mildly interesting.

Other than that everything else seems to work as expected.

autotools + GCC 9.1 + optimizations
difficultyTip

cmake + GCC 8.3
difficultyTipCmake

@Forgon2100 Forgon2100 force-pushed the Forgon2100:ai_tooltips branch from 6e6c5ae to 8485d7d Jul 4, 2019

Forgon2100 added a commit to Forgon2100/warzone2100 that referenced this pull request Jul 4, 2019
Fix AI list position of the default AI, NullBot
The AI list begins with the default AI, NullBot. Its remaining entries
are sorted in alphabetical order of the JSON files that describe AIs.

Misspelling NullBot as "Nullbot" prevented it from being the first entry
if AI mods were added whose filenames had higher alphabetical priority,
e.g. Cobra (cobra.json comes before nb_generic.json). This in turn could
cause bugs, like wrong AI names being printed.

Refs 46efbc6
Refs ticket:4791
Fixes Warzone2100#419
Forgon2100 added a commit to Forgon2100/warzone2100 that referenced this pull request Jul 4, 2019
Fix translation of AI names and tooltips
* show translation of AI keys "name" and "tip" or warning messages if
  their values are missing

* if the game language is changed via "Options->Game Options->Language",
  reload the AI list to prevent wrong translations

Refs 509f6bc
Refs Warzone2100#281
Fixes Warzone2100#419
Forgon2100 added a commit to Forgon2100/warzone2100 that referenced this pull request Jul 4, 2019
Change AI difficulty tooltips in challenge slots
* show name of difficulty level instead of message "Difficulty locked"

Fixes Warzone2100#419
Forgon2100 added a commit to Forgon2100/warzone2100 that referenced this pull request Jul 4, 2019
Change AI difficulty tooltips in multiplayer games
* show name of difficulty level to players who join

Fixes Warzone2100#419
Forgon2100 added a commit to Forgon2100/warzone2100 that referenced this pull request Jul 4, 2019
Add optional difficulty level descriptions for AIs
* support the following keys in JSON files for AIs, by difficulty level:
  * Easy: "easy_tip"
  * Medium: "medium_tip"
  * Hard: "hard_tip"
  * Insane: "insane_tip"

* keys should contain messages explaining differences between levels and
  any cheats an AI might use (e.g. power bonuses or skipping research)

* append non-empty key values to AI difficulty tooltips in an extra line

* make key values translatable

* fill out key values for all AIs installed by default

Fixes Warzone2100#419
Forgon2100 added a commit to Forgon2100/warzone2100 that referenced this pull request Jul 4, 2019
Add optional playing strength descriptions for AIs
* support the following numerical keys in JSON files for AIs:
  * "wins"
  * "losses"
  * "draws" (games without a winner after several hours of game time)

* keys contain data about playing strength of AIs relative to eath other

* if at least one key value is non-zero, calculate percentages and print
  these data in an extra line of AI tooltips with some translatable text

* fill out key values for NullBot and SemperFi JavaScript, based on an
  AI tournament by EuPhobos (forum username: Prot) from 23 October 2018,
  when its results were archived at https://archive.fo/QtSjR

Fixes Warzone2100#419
@Forgon2100

This comment has been minimized.

Copy link
Contributor Author

commented Jul 4, 2019

Garbage character(s) are printed before the difficulty tips, both when players join a game or the player is in a challenge when using autotools and optimizations with GCC 9.1. Tested on O1, O2, and O3. No optimizations don't exhibit this.

Building with Cmake and GCC 8.3 causes something else. The cmake build keeps corrupting the tips to something different when switching between a skirmish and a challenge, and repeating the real tip by whatever player number the AI is, which was mildly interesting.

Other than that everything else seems to work as expected. [...]

Thank you for testing! Could you check whether the errors still occur?

Forgon2100 added 6 commits Jun 30, 2019
Change AI difficulty tooltips in challenge slots
* show name of difficulty level instead of message "Difficulty locked"

Fixes #419
Change AI difficulty tooltips in multiplayer games
* show name of difficulty level to players who join

Fixes #419
Fix AI list position of the default AI, NullBot
The AI list begins with the default AI, NullBot. Its remaining entries
are sorted in alphabetical order of the JSON files that describe AIs.

Misspelling NullBot as "Nullbot" prevented it from being the first entry
if AI mods were added whose filenames had higher alphabetical priority,
e.g. Cobra (cobra.json comes before nb_generic.json). This in turn could
cause bugs, like wrong AI names being printed.

Refs 46efbc6
Refs ticket:4791
Fixes #419
Fix translation of AI names and tooltips
* show translation of AI keys "name" and "tip" or warning messages if
  their values are missing

* if the game language is changed via "Options->Game Options->Language",
  reload the AI list to prevent wrong translations

Refs 509f6bc
Refs #281
Fixes #419
Add optional difficulty level descriptions for AIs
* support the following keys in JSON files for AIs, by difficulty level:
  * Easy: "easy_tip"
  * Medium: "medium_tip"
  * Hard: "hard_tip"
  * Insane: "insane_tip"

* keys should contain messages explaining differences between levels and
  any cheats an AI might use (e.g. power bonuses or skipping research)

* append non-empty key values to AI difficulty tooltips in an extra line

* make key values translatable

* fill out key values for all AIs installed by default

Fixes #419
Add optional playing strength descriptions for AIs
* support the following numerical keys in JSON files for AIs:
  * "wins"
  * "losses"
  * "draws" (games without a winner after several hours of game time)

* keys contain data about playing strength of AIs relative to eath other

* if at least one key value is non-zero, calculate percentages and print
  these data in an extra line of AI tooltips with some translatable text

* fill out key values for NullBot and SemperFi JavaScript, based on an
  AI tournament by EuPhobos (forum username: Prot) from 23 October 2018,
  when its results were archived at https://archive.fo/QtSjR

Fixes #419

@Forgon2100 Forgon2100 force-pushed the Forgon2100:ai_tooltips branch from 8485d7d to 28e75a5 Jul 4, 2019

@KJeff01

This comment has been minimized.

Copy link
Contributor

commented Jul 4, 2019

That fixed it. Will merge after all the CI checks complete.

@KJeff01 KJeff01 merged commit 887b6f6 into Warzone2100:master Jul 4, 2019

8 checks passed

LGTM analysis: C/C++ No new or fixed alerts
Details
LGTM analysis: JavaScript No new or fixed alerts
Details
LGTM analysis: Python No new or fixed alerts
Details
WIP Ready for review
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
freebsd_build FreeBSD:freebsd-11-2-release-amd64 Task Summary
Details
freebsd_build FreeBSD:freebsd-12-0-release-amd64 Task Summary
Details
KJeff01 added a commit that referenced this pull request Jul 4, 2019
Fix AI list position of the default AI, NullBot
The AI list begins with the default AI, NullBot. Its remaining entries
are sorted in alphabetical order of the JSON files that describe AIs.

Misspelling NullBot as "Nullbot" prevented it from being the first entry
if AI mods were added whose filenames had higher alphabetical priority,
e.g. Cobra (cobra.json comes before nb_generic.json). This in turn could
cause bugs, like wrong AI names being printed.

Refs 46efbc6
Refs ticket:4791
Fixes #419
KJeff01 added a commit that referenced this pull request Jul 4, 2019
Fix translation of AI names and tooltips
* show translation of AI keys "name" and "tip" or warning messages if
  their values are missing

* if the game language is changed via "Options->Game Options->Language",
  reload the AI list to prevent wrong translations

Refs 509f6bc
Refs #281
Fixes #419
KJeff01 added a commit that referenced this pull request Jul 4, 2019
Change AI difficulty tooltips in challenge slots
* show name of difficulty level instead of message "Difficulty locked"

Fixes #419
KJeff01 added a commit that referenced this pull request Jul 4, 2019
Change AI difficulty tooltips in multiplayer games
* show name of difficulty level to players who join

Fixes #419
KJeff01 added a commit that referenced this pull request Jul 4, 2019
Add optional difficulty level descriptions for AIs
* support the following keys in JSON files for AIs, by difficulty level:
  * Easy: "easy_tip"
  * Medium: "medium_tip"
  * Hard: "hard_tip"
  * Insane: "insane_tip"

* keys should contain messages explaining differences between levels and
  any cheats an AI might use (e.g. power bonuses or skipping research)

* append non-empty key values to AI difficulty tooltips in an extra line

* make key values translatable

* fill out key values for all AIs installed by default

Fixes #419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.