Give a boosted AI to some AI karts in races and GP

This commit is contained in:
Alayan 2018-09-22 22:02:11 +02:00
parent c8305012f8
commit 46c2c88461
4 changed files with 34 additions and 3 deletions

View File

@ -1063,7 +1063,6 @@ void SkiddingAI::evaluateItems(const Item *item, Vec3 kart_aim_direction,
* Level 2 to 5 AI : strategy detailed before each item
* Each successive level is overall stronger (5 the strongest, 2 the weakest of
* non-random strategies), but two levels may share a strategy for a given item.
* (level 5 is not yet used ; meant for SuperTux GP preferred karts or boss races)
* \param dt Time step size.
* STATE: shield on -> avoid usage of offensive items (with certain tolerance)
* STATE: swatter on -> avoid usage of shield

View File

@ -229,8 +229,8 @@ void World::init()
global_player_id, race_manager->getKartType(i),
race_manager->getPlayerDifficulty(i));
}
new_kart->setBoostAI(race_manager->hasBoostedAI(i));
m_karts.push_back(new_kart);
} // for i
// Load other custom models if needed

View File

@ -511,6 +511,31 @@ void RaceManager::startNextRace()
}
} // not first race
// set boosted AI status for AI karts
int boosted_ai_count = std::min<int>(m_ai_kart_list.size(),
(m_kart_status.size()-2)/4 + 1);
if (boosted_ai_count > 4) boosted_ai_count = 4;
int ai_count = m_ai_kart_list.size();
for (unsigned int i=0;i<m_kart_status.size();i++)
{
if (m_kart_status[i].m_kart_type == KT_AI)
{
if (boosted_ai_count > 0 &&
(UserConfigParams::m_gp_most_points_first ||
ai_count == boosted_ai_count))
{
m_kart_status[i].m_boosted_ai = true;
boosted_ai_count--;
}
else
{
m_kart_status[i].m_boosted_ai = false;
}
ai_count--;
}
}
// the constructor assigns this object to the global
// variable world. Admittedly a bit ugly, but simplifies
// handling of objects which get created in the constructor

View File

@ -276,6 +276,8 @@ public:
/** In GPs, at the end, will hold the overall rank of this kart
* (0<=m_gp_rank < num_karts-1). */
int m_gp_rank;
/** Boosted status (AI only). */
bool m_boosted_ai;
/** The difficulty for this player. */
PerPlayerDifficulty m_difficulty;
@ -289,7 +291,7 @@ public:
m_local_player_id(local_player_id),
m_global_player_id(global_player_id),
m_gp_rank(init_gp_rank), m_difficulty(difficulty)
{}
{ m_boosted_ai = false; }
}; // KartStatus
private:
@ -643,6 +645,11 @@ public:
return m_kart_status[kart].m_difficulty;
} // getPlayerDifficulty
// ------------------------------------------------------------------------
float hasBoostedAI(int kart) const
{
return m_kart_status[kart].m_boosted_ai;
} // getKartRaceTime
// ------------------------------------------------------------------------
int getCoinTarget() const { return m_coin_target; }
// ------------------------------------------------------------------------
float getTimeTarget() const { return m_time_target; }