mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
world::max_energy: Implement upper limit for agent's energy
This commit is contained in:
parent
a5745ea516
commit
04a475efbe
2 changed files with 3 additions and 0 deletions
2
agent.cc
2
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();
|
||||
}
|
||||
|
|
1
world.h
1
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue