mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-02 18:03:37 +02:00
Incomp. Proto. Change: breeding_key -> breeding_key1, breeding_key2
This commit is contained in:
parent
724cf937d7
commit
177d41cf60
4 changed files with 12 additions and 6 deletions
6
README
6
README
|
@ -84,10 +84,14 @@ these commands instead:
|
|||
<rate> between 0 and 1.
|
||||
defense <rate>
|
||||
<rate> between 0 and 1.
|
||||
breeding_key <value>
|
||||
breeding_key1 <value>
|
||||
breeding_key2 <value>
|
||||
<value> is arbitrary integer number; default is 0;
|
||||
breeding succeeds only between individuals with key
|
||||
that is near enough (abs(key1-key2) < kappa).
|
||||
key1 is used as the initiator's key, key2 as the
|
||||
receiver's key. (I.e., use different keys for
|
||||
sexually reproducing species.)
|
||||
|
||||
In general, higher rate means higher energy maintenance of the
|
||||
appropriate actuators.
|
||||
|
|
2
agent.cc
2
agent.cc
|
@ -106,7 +106,7 @@ agent::breed_dir(int dir_x, int dir_y, std::string info)
|
|||
* a technical problem with in/out buf locking. */
|
||||
assert(a != this);
|
||||
|
||||
if (abs(a->attr.breeding_key - attr.breeding_key) > world::breeding_kappa)
|
||||
if (abs(attr.breeding_key1 - a->attr.breeding_key2) > world::breeding_kappa)
|
||||
return false;
|
||||
|
||||
chenergy(world::breed_out_cost);
|
||||
|
|
4
agent.h
4
agent.h
|
@ -36,7 +36,7 @@ public:
|
|||
double move;
|
||||
double attack;
|
||||
double defense;
|
||||
long breeding_key;
|
||||
long breeding_key1, breeding_key2;
|
||||
} attr;
|
||||
|
||||
int energy;
|
||||
|
@ -50,7 +50,7 @@ public:
|
|||
attr.move = 1.0;
|
||||
attr.attack = 0.5;
|
||||
attr.defense = 0.5;
|
||||
attr.breeding_key = 0;
|
||||
attr.breeding_key1 = attr.breeding_key2 = 0;
|
||||
energy = world::newborn_energy;
|
||||
dead = false;
|
||||
};
|
||||
|
|
|
@ -131,8 +131,10 @@ connection::actions(class agent *agent)
|
|||
sscanf(line.c_str(), "%lf", &rate);
|
||||
if (rate >= 0 && rate <= 1)
|
||||
agent->attr.defense = rate;
|
||||
} else if (negotiation && !cmd.compare("breeding_key")) {
|
||||
sscanf(line.c_str(), "%ld", &agent->attr.breeding_key);
|
||||
} else if (negotiation && !cmd.compare("breeding_key1")) {
|
||||
sscanf(line.c_str(), "%ld", &agent->attr.breeding_key1);
|
||||
} else if (negotiation && !cmd.compare("breeding_key2")) {
|
||||
sscanf(line.c_str(), "%ld", &agent->attr.breeding_key2);
|
||||
|
||||
} else if (negotiation && !cmd.compare("agent_id")) {
|
||||
int id = -1;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue