Commit 252a0390 authored by Hubert Denkmair's avatar Hubert Denkmair
Browse files

Merge branch 'proposal/kill_size_threshold' into 'dev'

Implemented a minimum killer/victim mass ratio

See merge request GPN18Programmierspiel/gameserver!12
parents 254054ed 3133da9f
......@@ -186,10 +186,16 @@ void Field::moveAllBots(void)
std::shared_ptr<Bot> killer = job->killer;
if (killer)
{
// collision detected, convert the colliding bot to food
killBot(victim, killer);
if (killer) {
// size check on killer
double killerMass = killer->getSnake()->getMass();
double victimMass = victim->getSnake()->getMass();
if(killerMass > (victimMass * config::KILLER_MIN_MASS_RATIO)) {
// collision detected and killer is large enough
// -> convert the colliding bot to food
killBot(victim, killer);
}
} else {
// no collision, bot still alive
m_updateTracker->botMoved(victim, steps);
......
......@@ -58,6 +58,12 @@ namespace config {
// Food decay value per frame
static const real_t FOOD_DECAY_STEP = 0.002;
// Minimum mass ratio required that a bot can kill another bot. This prevents
// that very small/newly spawned snakes can kill large snakes.
// Example: 0.01 means that the killer has to have at least 1% of the victims
// mass to be successful.
static const real_t KILLER_MIN_MASS_RATIO = 0.001;
// Lua memory pool configuration
static const std::size_t LUA_MEM_POOL_SIZE_BYTES = 10 * 1024*1024;
static const std::size_t LUA_MEM_POOL_BLOCK_SIZE_BYTES = 256;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment