Bot difficulty and grading tweaks

This commit is contained in:
Antonio Martinez 2025-06-07 17:49:11 -04:00
parent 2459affaa3
commit cd439be74c
7 changed files with 44 additions and 26 deletions

View file

@ -402,7 +402,7 @@ struct botvars_t
botStyle_e style; // Training mode-style CPU mode botStyle_e style; // Training mode-style CPU mode
UINT8 difficulty; // Bot's difficulty setting UINT8 difficulty; // Bot's difficulty setting
UINT8 diffincrease; // In GP: bot difficulty will increase this much next round INT16 diffincrease; // In GP: bot difficulty will increase this much next round
boolean rival; // If true, they're the GP rival boolean rival; // If true, they're the GP rival
// All entries above persist between rounds and must be recorded in demos // All entries above persist between rounds and must be recorded in demos

View file

@ -319,7 +319,7 @@ void G_ReadDemoExtraData(void)
if (players[p].bot) if (players[p].bot)
{ {
players[p].botvars.difficulty = READUINT8(demobuf.p); players[p].botvars.difficulty = READUINT8(demobuf.p);
players[p].botvars.diffincrease = READUINT8(demobuf.p); // needed to avoid having to duplicate logic players[p].botvars.diffincrease = READINT16(demobuf.p); // needed to avoid having to duplicate logic
players[p].botvars.rival = (boolean)READUINT8(demobuf.p); players[p].botvars.rival = (boolean)READUINT8(demobuf.p);
} }
} }
@ -495,7 +495,7 @@ void G_WriteDemoExtraData(void)
if (players[i].bot) if (players[i].bot)
{ {
WRITEUINT8(demobuf.p, players[i].botvars.difficulty); WRITEUINT8(demobuf.p, players[i].botvars.difficulty);
WRITEUINT8(demobuf.p, players[i].botvars.diffincrease); // needed to avoid having to duplicate logic WRITEINT16(demobuf.p, players[i].botvars.diffincrease); // needed to avoid having to duplicate logic
WRITEUINT8(demobuf.p, (UINT8)players[i].botvars.rival); WRITEUINT8(demobuf.p, (UINT8)players[i].botvars.rival);
} }
} }
@ -2109,7 +2109,7 @@ void G_BeginRecording(void)
if (i & DEMO_BOT) if (i & DEMO_BOT)
{ {
WRITEUINT8(demobuf.p, player->botvars.difficulty); WRITEUINT8(demobuf.p, player->botvars.difficulty);
WRITEUINT8(demobuf.p, player->botvars.diffincrease); // needed to avoid having to duplicate logic WRITEINT16(demobuf.p, player->botvars.diffincrease); // needed to avoid having to duplicate logic
WRITEUINT8(demobuf.p, (UINT8)player->botvars.rival); WRITEUINT8(demobuf.p, (UINT8)player->botvars.rival);
} }
@ -3220,7 +3220,7 @@ void G_DoPlayDemoEx(const char *defdemoname, lumpnum_t deflumpnum)
if ((players[p].bot = bot) == true) if ((players[p].bot = bot) == true)
{ {
players[p].botvars.difficulty = READUINT8(demobuf.p); players[p].botvars.difficulty = READUINT8(demobuf.p);
players[p].botvars.diffincrease = READUINT8(demobuf.p); // needed to avoid having to duplicate logic players[p].botvars.diffincrease = READINT16(demobuf.p); // needed to avoid having to duplicate logic
players[p].botvars.rival = (boolean)READUINT8(demobuf.p); players[p].botvars.rival = (boolean)READUINT8(demobuf.p);
} }

View file

@ -2265,7 +2265,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps)
INT16 steering; INT16 steering;
angle_t playerangleturn; angle_t playerangleturn;
UINT8 botdiffincrease; INT16 botdiffincrease;
boolean botrival; boolean botrival;
boolean cangrabitems; boolean cangrabitems;

View file

@ -117,6 +117,8 @@ void K_SetBot(UINT8 newplayernum, UINT8 skinnum, UINT8 difficulty, botStyle_e st
playernode[newplayernum] = servernode; playernode[newplayernum] = servernode;
CONS_Printf("addbot diff %d\n", difficulty);
// this will permit unlocks // this will permit unlocks
memcpy(&players[newplayernum].availabilities, R_GetSkinAvailabilities(false, skinnum), MAXAVAILABILITY*sizeof(UINT8)); memcpy(&players[newplayernum].availabilities, R_GetSkinAvailabilities(false, skinnum), MAXAVAILABILITY*sizeof(UINT8));

View file

@ -90,6 +90,14 @@ UINT8 K_GetGPPlayerCount(UINT8 humans)
return std::clamp<UINT8>(humans * 4, 8, MAXPLAYERS); return std::clamp<UINT8>(humans * 4, 8, MAXPLAYERS);
} }
// Kind of hate unsigned types
static UINT8 K_GetOffsetStartingDifficulty(const UINT8 startingdifficulty, UINT8 offset)
{
if (offset >= startingdifficulty)
return 1;
return startingdifficulty - offset;
}
/*-------------------------------------------------- /*--------------------------------------------------
void K_InitGrandPrixBots(void) void K_InitGrandPrixBots(void)
@ -139,22 +147,22 @@ void K_InitGrandPrixBots(void)
else else
{ {
// init difficulty levels list // init difficulty levels list
difficultylevels[ 0] = std::max<UINT8>(1, startingdifficulty); difficultylevels[ 0] = startingdifficulty;
difficultylevels[ 1] = std::max<UINT8>(1, startingdifficulty-1); difficultylevels[ 1] = K_GetOffsetStartingDifficulty(startingdifficulty, 1);
difficultylevels[ 2] = std::max<UINT8>(1, startingdifficulty-2); difficultylevels[ 2] = K_GetOffsetStartingDifficulty(startingdifficulty, 2);
difficultylevels[ 3] = std::max<UINT8>(1, startingdifficulty-3); difficultylevels[ 3] = K_GetOffsetStartingDifficulty(startingdifficulty, 3);
difficultylevels[ 4] = std::max<UINT8>(1, startingdifficulty-3); difficultylevels[ 4] = K_GetOffsetStartingDifficulty(startingdifficulty, 3);
difficultylevels[ 5] = std::max<UINT8>(1, startingdifficulty-4); difficultylevels[ 5] = K_GetOffsetStartingDifficulty(startingdifficulty, 4);
difficultylevels[ 6] = std::max<UINT8>(1, startingdifficulty-4); difficultylevels[ 6] = K_GetOffsetStartingDifficulty(startingdifficulty, 4);
difficultylevels[ 7] = std::max<UINT8>(1, startingdifficulty-4); difficultylevels[ 7] = K_GetOffsetStartingDifficulty(startingdifficulty, 4);
difficultylevels[ 8] = std::max<UINT8>(1, startingdifficulty-5); difficultylevels[ 8] = K_GetOffsetStartingDifficulty(startingdifficulty, 5);
difficultylevels[ 9] = std::max<UINT8>(1, startingdifficulty-5); difficultylevels[ 9] = K_GetOffsetStartingDifficulty(startingdifficulty, 5);
difficultylevels[10] = std::max<UINT8>(1, startingdifficulty-5); difficultylevels[10] = K_GetOffsetStartingDifficulty(startingdifficulty, 5);
difficultylevels[11] = std::max<UINT8>(1, startingdifficulty-6); difficultylevels[11] = K_GetOffsetStartingDifficulty(startingdifficulty, 6);
difficultylevels[12] = std::max<UINT8>(1, startingdifficulty-6); difficultylevels[12] = K_GetOffsetStartingDifficulty(startingdifficulty, 6);
difficultylevels[13] = std::max<UINT8>(1, startingdifficulty-7); difficultylevels[13] = K_GetOffsetStartingDifficulty(startingdifficulty, 7);
difficultylevels[14] = std::max<UINT8>(1, startingdifficulty-7); difficultylevels[14] = K_GetOffsetStartingDifficulty(startingdifficulty, 7);
difficultylevels[15] = std::max<UINT8>(1, startingdifficulty-8); difficultylevels[15] = K_GetOffsetStartingDifficulty(startingdifficulty, 8);
} }
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
@ -381,6 +389,10 @@ void K_UpdateGrandPrixBots(void)
if (players[i].botvars.diffincrease) if (players[i].botvars.diffincrease)
{ {
CONS_Printf("in %d inc %d", players[i].botvars.difficulty, players[i].botvars.diffincrease);
if (players[i].botvars.diffincrease < 0)
players[i].botvars.difficulty = std::max(1, players[i].botvars.difficulty - players[i].botvars.diffincrease);
else
players[i].botvars.difficulty += players[i].botvars.diffincrease; players[i].botvars.difficulty += players[i].botvars.diffincrease;
if (players[i].botvars.difficulty > MAXBOTDIFFICULTY) if (players[i].botvars.difficulty > MAXBOTDIFFICULTY)
@ -388,6 +400,8 @@ void K_UpdateGrandPrixBots(void)
players[i].botvars.difficulty = MAXBOTDIFFICULTY; players[i].botvars.difficulty = MAXBOTDIFFICULTY;
} }
CONS_Printf(" out %d\n", players[i].botvars.difficulty);
players[i].botvars.diffincrease = 0; players[i].botvars.diffincrease = 0;
} }
@ -628,6 +642,8 @@ void K_IncreaseBotDifficulty(player_t *bot)
increase += rankNudge; increase += rankNudge;
CONS_Printf("raising %d by %d - %d\n", bot->botvars.difficulty, increase, bot->botvars.difficulty + increase);
if (increase <= 0) if (increase <= 0)
{ {
// TYRON: We want to allow SMALL bot rank downs if a player gets rolled but still squeaks by. // TYRON: We want to allow SMALL bot rank downs if a player gets rolled but still squeaks by.

View file

@ -96,8 +96,8 @@ extern "C" {
#define RANK_WEIGHT_PRISONS (100) #define RANK_WEIGHT_PRISONS (100)
#define RANK_WEIGHT_RINGS (50) #define RANK_WEIGHT_RINGS (50)
#define RANK_CONTINUE_PENALTY_DIV (20) // 5% of the total grade #define RANK_CONTINUE_PENALTY_DIV (10) // 10% of the total grade
#define RANK_CONTINUE_PENALTY_START (2) #define RANK_CONTINUE_PENALTY_START (0)
/*-------------------------------------------------- /*--------------------------------------------------
void K_InitGrandPrixRank(gpRank_t *rankData); void K_InitGrandPrixRank(gpRank_t *rankData);

View file

@ -247,7 +247,7 @@ INT32 level_tally_t::CalculateGrade(void)
case TALLY_BONUS_EXP: case TALLY_BONUS_EXP:
{ {
const fixed_t frac = std::min(FRACUNIT, ((exp-15) * FRACUNIT) / std::max(1, static_cast<int>(totalExp))); const fixed_t frac = std::min(FRACUNIT, ((exp-15) * FRACUNIT) / std::max(1, static_cast<int>(totalExp)));
ours += Easing_Linear(frac, 0, bonusWeights[i]); ours += Easing_InQuint(frac, 0, bonusWeights[i]);
break; break;
} }
case TALLY_BONUS_PRISON: case TALLY_BONUS_PRISON: