Incomp. Proto. Change: breeding_key -> breeding_key1, breeding_key2

This commit is contained in:
Petr Baudis 2011-12-17 00:01:45 +01:00
parent 724cf937d7
commit 177d41cf60
4 changed files with 12 additions and 6 deletions

6
README
View file

@ -84,10 +84,14 @@ these commands instead:
<rate> between 0 and 1. <rate> between 0 and 1.
defense <rate> defense <rate>
<rate> between 0 and 1. <rate> between 0 and 1.
breeding_key <value> breeding_key1 <value>
breeding_key2 <value>
<value> is arbitrary integer number; default is 0; <value> is arbitrary integer number; default is 0;
breeding succeeds only between individuals with key breeding succeeds only between individuals with key
that is near enough (abs(key1-key2) < kappa). 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 In general, higher rate means higher energy maintenance of the
appropriate actuators. appropriate actuators.

View file

@ -106,7 +106,7 @@ agent::breed_dir(int dir_x, int dir_y, std::string info)
* a technical problem with in/out buf locking. */ * a technical problem with in/out buf locking. */
assert(a != this); 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; return false;
chenergy(world::breed_out_cost); chenergy(world::breed_out_cost);

View file

@ -36,7 +36,7 @@ public:
double move; double move;
double attack; double attack;
double defense; double defense;
long breeding_key; long breeding_key1, breeding_key2;
} attr; } attr;
int energy; int energy;
@ -50,7 +50,7 @@ public:
attr.move = 1.0; attr.move = 1.0;
attr.attack = 0.5; attr.attack = 0.5;
attr.defense = 0.5; attr.defense = 0.5;
attr.breeding_key = 0; attr.breeding_key1 = attr.breeding_key2 = 0;
energy = world::newborn_energy; energy = world::newborn_energy;
dead = false; dead = false;
}; };

View file

@ -131,8 +131,10 @@ connection::actions(class agent *agent)
sscanf(line.c_str(), "%lf", &rate); sscanf(line.c_str(), "%lf", &rate);
if (rate >= 0 && rate <= 1) if (rate >= 0 && rate <= 1)
agent->attr.defense = rate; agent->attr.defense = rate;
} else if (negotiation && !cmd.compare("breeding_key")) { } else if (negotiation && !cmd.compare("breeding_key1")) {
sscanf(line.c_str(), "%ld", &agent->attr.breeding_key); 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")) { } else if (negotiation && !cmd.compare("agent_id")) {
int id = -1; int id = -1;