mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
Support for agent death
This commit is contained in:
parent
f6221436a4
commit
64ea015a06
4 changed files with 20 additions and 5 deletions
15
agent.cc
15
agent.cc
|
@ -30,6 +30,12 @@ agent::move_dir(int dir_x, int dir_y)
|
|||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
agent::die(void)
|
||||
{
|
||||
dead = true;
|
||||
}
|
||||
|
||||
void
|
||||
agent::on_action_takes(void)
|
||||
{
|
||||
|
@ -42,7 +48,12 @@ agent::on_action_takes(void)
|
|||
void
|
||||
agent::on_tick(void)
|
||||
{
|
||||
energy += world::sun_energy;
|
||||
if (!dead) {
|
||||
energy += world::sun_energy;
|
||||
|
||||
if (energy <= 0)
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -57,7 +68,7 @@ agent::on_senses_update(void)
|
|||
tile->tile_in_dir(0, 1).symbol(),
|
||||
tile->tile_in_dir(-1, 0).symbol(),
|
||||
};
|
||||
conn->senses(tick_id, energy, around);
|
||||
conn->senses(tick_id, dead, energy, around);
|
||||
}
|
||||
|
||||
agent::~agent()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue