Commit bf59e926 authored by Thomas Kolb's avatar Thomas Kolb
Browse files

Make Snakes loose mass over time even without boosting

parent c384c788
......@@ -160,6 +160,8 @@ std::size_t Snake::move(real_t targetAngle, bool boost)
m_boostedLastMove = boost;
m_mass *= (1.0 - config::SNAKE_SURVIVAL_LOSS_FACTOR);
return m_segments.size(); // == number of new segments at head
}
......@@ -199,7 +201,7 @@ void Snake::convertToFood(const std::shared_ptr<Bot> &hunter) const
}
}
void Snake::dropFood(float_t value)
void Snake::dropFood(real_t value)
{
Vector2D dropOffset = (m_segments.end() - 1)->pos() - (m_segments.end() - 2)->pos();
Vector2D dropPos = (m_segments.end() - 1)->pos() + dropOffset.normalized() * 5;
......
......@@ -48,6 +48,12 @@ namespace config {
// Part of Snake's mass to drop in every frame the boost is on.
static const real_t SNAKE_BOOST_LOSS_FACTOR = 1e-3;
// Snakes continuously loose mass. This parameter adjust the part of mass
// lost every movement (==frame). The mass is not dropped, but simply lost.
// 1e-5 means that a mass 100k-Snake has to eat food of value 1 on average every
// frame to keep its mass.
static const real_t SNAKE_SURVIVAL_LOSS_FACTOR = 1e-5;
// Mass below which Snake dies through starvation
static const real_t SNAKE_SELF_KILL_MASS_THESHOLD = 1.0;
......
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