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

Only update Snake size after consuming all Food

parent bf59e926
......@@ -146,6 +146,8 @@ void Field::consumeFood(void)
}
}
}
b->getSnake()->ensureSizeMatchesMass();
}
createStaticFood(newStaticFood);
updateMaxSegmentRadius();
......@@ -205,6 +207,9 @@ void Field::moveAllBots(void)
killBot(victim, victim);
}
}
// adjust size to new mass
victim->getSnake()->ensureSizeMatchesMass();
}
}
......
......@@ -65,7 +65,6 @@ real_t Snake::maxRotationPerStep(void)
void Snake::consume(const Food& food)
{
m_mass += food.getValue();
ensureSizeMatchesMass();
}
std::size_t Snake::move(real_t targetAngle, bool boost)
......@@ -212,8 +211,6 @@ void Snake::dropFood(real_t value)
if(m_mass < 1e-6) {
m_mass = 1e-6;
}
ensureSizeMatchesMass();
}
real_t Snake::getConsumeRadius()
......
......@@ -48,11 +48,6 @@ class Snake
real_t m_boostedLastMove = false; //!< Track if the snake boosted during the last move
/*!
* Updates the length of m_segments and calculates the current m_segmentRadius
*/
void ensureSizeMatchesMass(void);
public:
/*!
* Construct a unit snake (1 segment at 0/0, heading 0°).
......@@ -62,6 +57,11 @@ class Snake
Snake(Field *field, const Vector2D &start_pos, real_t start_mass,
real_t start_heading);
/*!
* Updates the length of m_segments and calculates the current m_segmentRadius
*/
void ensureSizeMatchesMass(void);
/*!
* Consume the given food piece.
*/
......
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