Introduce pheromones

This commit is contained in:
Petr Baudis 2011-12-07 23:54:03 +01:00
parent 61cc3ef015
commit a821e72661
9 changed files with 133 additions and 1 deletions

35
pheromone.h Normal file
View file

@ -0,0 +1,35 @@
#ifndef BRMLIFE__PHEROMONE_H
#define BRMLIFE__PHEROMONE_H
/* Pheromone spectrum in a particular state. */
#include <list>
#define PH_COUNT 65536
class pheromone {
public:
int id;
double val;
pheromone(int id_ = 0, double val_ = 0)
: id (id_), val (val_) {};
};
class pheromones {
public:
std::list<class pheromone> spectrum;
/* Add a pheromone to the spectrum. */
void secrete(class pheromone &p);
/* Merge slight trail of spectrum to another spectrum (transfer
* by touching). Pheromones with lower index are transmitted
* better than those with higher index:
* v' = v * (alpha / i + beta) */
void seep(class pheromones &to, double alpha, double beta);
/* Decay the spectrum, multiplying each value by gamma and
* then reducing it by delta. */
void decay(double gamma, double delta);
};
#endif