mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
Introduce pheromones
This commit is contained in:
parent
61cc3ef015
commit
a821e72661
9 changed files with 133 additions and 1 deletions
13
agent.cc
13
agent.cc
|
@ -91,6 +91,15 @@ agent::attack_dir(int dir_x, int dir_y)
|
|||
return attack_roll >= defense_roll;
|
||||
}
|
||||
|
||||
bool
|
||||
agent::secrete(int id, double intensity)
|
||||
{
|
||||
pheromone p(id, intensity);
|
||||
pheromones.secrete(p);
|
||||
chenergy(intensity * world::pheromone_cost);
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
agent::chenergy(int delta)
|
||||
{
|
||||
|
@ -129,9 +138,13 @@ agent::on_action_takes(void)
|
|||
void
|
||||
agent::on_tick(void)
|
||||
{
|
||||
pheromones.decay(world::phdecay_gamma, world::phdecay_delta);
|
||||
|
||||
if (!tile)
|
||||
return;
|
||||
|
||||
pheromones.seep(tile->pheromones, world::phseep_alpha, world::phseep_beta);
|
||||
|
||||
if (!dead) {
|
||||
chenergy(world::sun_energy);
|
||||
chenergy(attr.move * world::move_idle_cost);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue