diff --git a/agent.cc b/agent.cc index 054db38..0677865 100644 --- a/agent.cc +++ b/agent.cc @@ -94,6 +94,8 @@ void agent::chenergy(int delta) { energy += delta; + if (energy > world::max_energy) + energy = world::max_energy; if (energy <= 0) die(); } diff --git a/world.h b/world.h index 4381044..47a3b81 100644 --- a/world.h +++ b/world.h @@ -4,6 +4,7 @@ struct world { const static int newborn_energy = 5000; const static int herb_energy = 1000; + const static int max_energy = 20000; const static int move_cost = -50; const static int attack_cost = -400;