diff --git a/README b/README index d29cfe1..7de38c7 100644 --- a/README +++ b/README @@ -84,10 +84,14 @@ these commands instead: between 0 and 1. defense between 0 and 1. - breeding_key + breeding_key1 + breeding_key2 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. diff --git a/agent.cc b/agent.cc index 277d81a..2b117ce 100644 --- a/agent.cc +++ b/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); diff --git a/agent.h b/agent.h index 5a33611..747c8bf 100644 --- a/agent.h +++ b/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; }; diff --git a/connection.cc b/connection.cc index 9df4ac0..64b9403 100644 --- a/connection.cc +++ b/connection.cc @@ -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;