mgr: enable balancing bot difficulty on interval instead of on new round (closes #400)
This commit is contained in:
parent
cb115b1881
commit
7c76c57974
3 changed files with 21 additions and 17 deletions
|
|
@ -58,6 +58,7 @@ private:
|
||||||
float m_timeRoundEnd {};
|
float m_timeRoundEnd {};
|
||||||
float m_timeRoundMid {};
|
float m_timeRoundMid {};
|
||||||
|
|
||||||
|
float m_difficultyBalanceTime {}; // time to balance difficulties ?
|
||||||
float m_autoKillCheckTime {}; // time to kill all the bots ?
|
float m_autoKillCheckTime {}; // time to kill all the bots ?
|
||||||
float m_maintainTime {}; // time to maintain bot creation
|
float m_maintainTime {}; // time to maintain bot creation
|
||||||
float m_quotaMaintainTime {}; // time to maintain bot quota
|
float m_quotaMaintainTime {}; // time to maintain bot quota
|
||||||
|
|
|
||||||
|
|
@ -398,6 +398,9 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) {
|
||||||
// keep bot number up to date
|
// keep bot number up to date
|
||||||
bots.maintainQuota ();
|
bots.maintainQuota ();
|
||||||
|
|
||||||
|
// balance bot difficulties
|
||||||
|
bots.balanceBotDifficulties ();
|
||||||
|
|
||||||
// flush print queue to users
|
// flush print queue to users
|
||||||
ctrl.flushPrintQueue ();
|
ctrl.flushPrintQueue ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ ConVar cv_difficulty ("yb_difficulty", "3", "All bots difficulty level. Changing
|
||||||
ConVar cv_difficulty_min ("yb_difficulty_min", "-1", "Lower bound of random difficulty on bot creation. Only affects newly created bots. -1 means yb_difficulty only used.", true, -1.0f, 4.0f);
|
ConVar cv_difficulty_min ("yb_difficulty_min", "-1", "Lower bound of random difficulty on bot creation. Only affects newly created bots. -1 means yb_difficulty only used.", true, -1.0f, 4.0f);
|
||||||
ConVar cv_difficulty_max ("yb_difficulty_max", "-1", "Upper bound of random difficulty on bot creation. Only affects newly created bots. -1 means yb_difficulty only used.", true, -1.0f, 4.0f);
|
ConVar cv_difficulty_max ("yb_difficulty_max", "-1", "Upper bound of random difficulty on bot creation. Only affects newly created bots. -1 means yb_difficulty only used.", true, -1.0f, 4.0f);
|
||||||
ConVar cv_difficulty_auto ("yb_difficulty_auto", "0", "Enables each bot balances own difficulty based kd-ratio of team.", true, 0.0f, 1.0f);
|
ConVar cv_difficulty_auto ("yb_difficulty_auto", "0", "Enables each bot balances own difficulty based kd-ratio of team.", true, 0.0f, 1.0f);
|
||||||
|
ConVar cv_difficulty_auto_balance_interval ("yb_difficulty_auto_balance_interval", "30", "Interval in which bots will balance theird difficulty.", true, 30.0f, 240.0f);
|
||||||
|
|
||||||
ConVar cv_show_avatars ("yb_show_avatars", "1", "Enables or disables displaying bot avatars in front of their names in scoreboard. Note, that is currently you can see only avatars of your steam friends.");
|
ConVar cv_show_avatars ("yb_show_avatars", "1", "Enables or disables displaying bot avatars in front of their names in scoreboard. Note, that is currently you can see only avatars of your steam friends.");
|
||||||
ConVar cv_show_latency ("yb_show_latency", "2", "Enables latency display in scoreboard.\nAllowed values: '0', '1', '2'.\nIf '0', there is nothing displayed.\nIf '1', there is a 'BOT' is displayed.\nIf '2' fake ping is displayed.", true, 0.0f, 2.0f);
|
ConVar cv_show_latency ("yb_show_latency", "2", "Enables latency display in scoreboard.\nAllowed values: '0', '1', '2'.\nIf '0', there is nothing displayed.\nIf '1', there is a 'BOT' is displayed.\nIf '2' fake ping is displayed.", true, 0.0f, 2.0f);
|
||||||
|
|
@ -65,6 +66,7 @@ BotManager::BotManager () {
|
||||||
m_autoKillCheckTime = 0.0f;
|
m_autoKillCheckTime = 0.0f;
|
||||||
m_maintainTime = 0.0f;
|
m_maintainTime = 0.0f;
|
||||||
m_quotaMaintainTime = 0.0f;
|
m_quotaMaintainTime = 0.0f;
|
||||||
|
m_difficultyBalanceTime = 0.0f;
|
||||||
|
|
||||||
m_bombPlanted = false;
|
m_bombPlanted = false;
|
||||||
m_botsCanPause = false;
|
m_botsCanPause = false;
|
||||||
|
|
@ -818,7 +820,7 @@ float BotManager::getAverageTeamKPD (bool calcForBots) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (calc.second > 0) {
|
if (calc.second > 0) {
|
||||||
return calc.first / static_cast <float> (calc.second);
|
return calc.first / static_cast <float> (cr::max (1, calc.second));
|
||||||
}
|
}
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
}
|
}
|
||||||
|
|
@ -917,6 +919,7 @@ void BotManager::balanceBotDifficulties () {
|
||||||
bot->m_difficulty = cr::clamp (static_cast <Difficulty> (bot->m_difficulty + offset), Difficulty::Noob, Difficulty::Expert);
|
bot->m_difficulty = cr::clamp (static_cast <Difficulty> (bot->m_difficulty + offset), Difficulty::Noob, Difficulty::Expert);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (cv_difficulty_auto.bool_ () && m_difficultyBalanceTime < game.time ()) {
|
||||||
auto ratioPlayer = getAverageTeamKPD (false);
|
auto ratioPlayer = getAverageTeamKPD (false);
|
||||||
auto ratioBots = getAverageTeamKPD (true);
|
auto ratioBots = getAverageTeamKPD (true);
|
||||||
|
|
||||||
|
|
@ -932,6 +935,8 @@ void BotManager::balanceBotDifficulties () {
|
||||||
updateDifficulty (bot.get (), -1);
|
updateDifficulty (bot.get (), -1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_difficultyBalanceTime = game.time () + cv_difficulty_auto_balance_interval.float_ ();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotManager::destroy () {
|
void BotManager::destroy () {
|
||||||
|
|
@ -1892,11 +1897,6 @@ void BotManager::initRound () {
|
||||||
m_timeRoundStart = game.time () + mp_freezetime.float_ ();
|
m_timeRoundStart = game.time () + mp_freezetime.float_ ();
|
||||||
m_timeRoundMid = m_timeRoundStart + mp_roundtime.float_ () * 60.0f * 0.5f;
|
m_timeRoundMid = m_timeRoundStart + mp_roundtime.float_ () * 60.0f * 0.5f;
|
||||||
m_timeRoundEnd = m_timeRoundStart + mp_roundtime.float_ () * 60.0f;
|
m_timeRoundEnd = m_timeRoundStart + mp_roundtime.float_ () * 60.0f;
|
||||||
|
|
||||||
// update difficulty balance, if needed
|
|
||||||
if (cv_difficulty_auto.bool_ ()) {
|
|
||||||
balanceBotDifficulties ();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotManager::setBombPlanted (bool isPlanted) {
|
void BotManager::setBombPlanted (bool isPlanted) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue