GP: New difficulty increase algorithm

Before, it did level up based on how much the status quo was messed up (if a loser bot got pushed in front, or a rival bot got pushed ahead).

Now, bots will additionally level up based on the best of the 4 players' overall performance, and the performance of the human player that beat them. This means that back of the pack bots will level up more often and the rival won't level up if you place poorly.

The new formula ensures ALL bots are guaranteed at least 1 level up if you come in first place, whereas the old formula had a decent chance of not leveling up some bots. However, loser Chao getting boosted from 12th into 1st, or your rival getting sent to 7th, will still wildly piss them off :B
This commit is contained in:
Sally Coolatta 2023-05-15 06:13:01 -04:00
parent a7f27948f3
commit c43fc4e924

View file

@ -469,8 +469,22 @@ static UINT8 K_BotExpectedStanding(player_t *bot)
--------------------------------------------------*/
void K_IncreaseBotDifficulty(player_t *bot)
{
UINT8 expectedstanding;
INT16 standingdiff;
UINT8 playerCount = 0;
UINT8 wonCount = 0;
UINT8 humanThatBeatUs = 0;
INT16 beatenDelta = 0;
UINT8 winnerHuman = UINT8_MAX;
INT16 winnerDelta = 0;
UINT8 statusQuo = 1;
INT16 disruptDelta = 0;
INT16 increase = 1;
size_t i = SIZE_MAX;
bot->botvars.diffincrease = 0;
if (bot->botvars.difficulty >= MAXBOTDIFFICULTY)
{
@ -478,33 +492,65 @@ void K_IncreaseBotDifficulty(player_t *bot)
return;
}
// Increment bot difficulty based on what position you were meant to come in!
expectedstanding = K_BotExpectedStanding(bot);
standingdiff = expectedstanding - bot->position;
// Increment bot difficulty based on
// how much they were beaten by a player!
if (standingdiff >= -2)
// Find the worst-placing player that still beat us.
for (i = 0; i < MAXPLAYERS; i++)
{
UINT8 increase;
player_t *other = NULL;
if (standingdiff > 5)
if (playeringame[i] == false)
{
increase = 3;
}
else if (standingdiff > 2)
{
increase = 2;
}
else
{
increase = 1;
continue;
}
bot->botvars.diffincrease = increase;
other = &players[i];
if (other->spectator == true)
{
continue;
}
playerCount++;
if (other->bot == true)
{
continue;
}
if (other->position <= bot->position && other->position > humanThatBeatUs)
{
humanThatBeatUs = other->position;
}
if (other->position < winnerHuman)
{
winnerHuman = other->position;
}
}
else
wonCount = playerCount / 2;
if (playerCount & 1)
{
bot->botvars.diffincrease = 0;
// Round up
wonCount++;
}
statusQuo = K_BotExpectedStanding(bot);
// How many levels they gain depends on how hard they beat us,
// and how much the status quo was disturbed.
beatenDelta = bot->position - humanThatBeatUs;
winnerDelta = wonCount - winnerHuman;
disruptDelta = abs(statusQuo - bot->position);
increase = (beatenDelta + winnerDelta + disruptDelta - 2) / 3;
if (increase <= 0)
{
// No increase...
return;
}
bot->botvars.diffincrease = increase;
}
/*--------------------------------------------------