Skip to content
Permalink
Browse files

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
  • Loading branch information...
Forgon2100 committed Jun 30, 2019
1 parent 3bee689 commit 8485d7d75e99152902b900bb681d4086acd25dc5
Showing with 24 additions and 3 deletions.
  1. +4 −1 data/mp/multiplay/skirmish/nb_generic.json
  2. +4 −1 data/mp/multiplay/skirmish/semperfi-js.json
  3. +16 −1 src/multiint.cpp
@@ -4,6 +4,9 @@
"name": "NullBot",
"tip": "Adaptive AI with multiple personalities",
"easy_tip": "Gets ~ 25% less power from each oil derrick\nResearch is not focused on a specific weapon branch",
"insane_tip": "Gets ~ 100% more power from each oil derrick\nStarts with defensive structures and oil derricks"
"insane_tip": "Gets ~ 100% more power from each oil derrick\nStarts with defensive structures and oil derricks",
"wins": 18927,
"losses": 12773,
"draws": 261
}
}
@@ -4,6 +4,9 @@
"name": "SemperFi JavaScript",
"tip": "Prototypical JavaScript AI focusing on rockets/missiles",
"easy_tip": "Gets ~ 25% less power from each oil derrick",
"insane_tip": "Gets ~ 100% more power from each oil derrick\nStarts with defensive structures and oil derricks"
"insane_tip": "Gets ~ 100% more power from each oil derrick\nStarts with defensive structures and oil derricks",
"wins": 1806,
"losses": 2355,
"draws": 23
}
}
@@ -275,7 +275,7 @@ struct AIDATA
char slo[MAX_LEN_AI_NAME];
char vlo[MAX_LEN_AI_NAME];
char js[MAX_LEN_AI_NAME];
char tip[255];
char tip[255 + 128]; // may contain optional AI tournament data
char difficultyTips[4][255]; // optional difficulty level info
int assigned; ///< How many AIs have we assigned of this type
};
@@ -811,6 +811,21 @@ void readAIs()
sstrcpy(ai.tip, _("MISSING AI DESCRIPTION"));
}

int wins = aiconf.value("wins", 0).toInt();
int losses = aiconf.value("losses", 0).toInt();
int draws = aiconf.value("draws", 0).toInt();
int total = wins + losses + draws;
if (total)
{
float win_percentage = static_cast<float>(wins) / total * 100;
float loss_percentage = static_cast<float>(losses) / total * 100;
float draw_percentage = static_cast<float>(draws) / total * 100;
sstrcat(ai.tip, "\n");
char statistics[127];
ssprintf(statistics, _("AI tournament: %3.1f%% wins, %3.1f%% losses, %3.1f%% draws"), win_percentage, loss_percentage, draw_percentage);
sstrcat(ai.tip, statistics);
}

if (strcmp(*i, "nb_generic.json") == 0)
{
aidata.insert(aidata.begin(), ai);

0 comments on commit 8485d7d

Please sign in to comment.
You can’t perform that action at this time.