[Avida-SVN] r1047 - in development: . source source/analyze source/main source/tools
ofria at myxo.css.msu.edu
ofria at myxo.css.msu.edu
Sun Oct 15 19:55:46 PDT 2006
Author: ofria
Date: 2006-10-15 22:55:45 -0400 (Sun, 15 Oct 2006)
New Revision: 1047
Modified:
development/KNOWN_BUGS
development/source/analyze/cAnalyze.cc
development/source/defs.h
development/source/main/cAvidaConfig.h
development/source/main/cBirthChamber.cc
development/source/main/cPopulation.cc
development/source/main/cPopulationCell.h
development/source/tools/cMerit.h
Log:
Added a new BIRTH_METHOD (7) that allows a parent to choose where it wants
its offspring to be placed, based on that parent's facing.
Changed some defaults in avida.cfg:
WORLD_X 60 (was 100)
WORLD_Y 60 (was 100)
VIEW_MODE 1 (to make the text viewer start in map mode; was 0, blank screen).
BIRTH_METHOD 0 (Random in a structured environment; was 4 - mass action)
Minor code cleanups:
Fixed an unsigned int to int comparison in cMerit that was throwing a warning
during compilation.
Fixed an assignment-in-while-condition warning in cAnalyze.cc (added an extra
set of parentheses around the assignment, as the compiler requested).
Updated KNOWN_BUGS list with some more, useful cleanups that will need to wait
until we're willing to break backward compatibility of config files again.
Modified: development/KNOWN_BUGS
===================================================================
--- development/KNOWN_BUGS 2006-10-16 00:22:11 UTC (rev 1046)
+++ development/KNOWN_BUGS 2006-10-16 02:55:45 UTC (rev 1047)
@@ -6,3 +6,8 @@
it gives birth, but currently it is not treated like a second child, so
the genotype will not be changed, and in general it cannot act with many
other settings (like mutation reversions)
+
+-- Not bugs, per-se, but ugly coding that should be cleaned up
+* BIRTH_METHOD 7 is currently a local birth method, but not grouped with the
+ rest of them. This required a special condition in cBirthChamber.cc for
+ local recombination and in cPopulation.cc for offspring facing parent.
Modified: development/source/analyze/cAnalyze.cc
===================================================================
--- development/source/analyze/cAnalyze.cc 2006-10-16 00:22:11 UTC (rev 1046)
+++ development/source/analyze/cAnalyze.cc 2006-10-16 02:55:45 UTC (rev 1047)
@@ -1593,7 +1593,7 @@
tListIterator<cAnalyzeGenotype> batch_it(batch[cur_batch].List());
cAnalyzeGenotype* genotype = NULL;
- while (genotype = batch_it.Next()) {
+ while ((genotype = batch_it.Next())) {
if (found) {
batch_it.Remove();
delete genotype;
Modified: development/source/defs.h
===================================================================
--- development/source/defs.h 2006-10-16 00:22:11 UTC (rev 1046)
+++ development/source/defs.h 2006-10-16 02:55:45 UTC (rev 1047)
@@ -129,7 +129,8 @@
POSITION_CHILD_EMPTY,
POSITION_CHILD_FULL_SOUP_RANDOM,
POSITION_CHILD_FULL_SOUP_ELDEST,
- POSITION_CHILD_DEME_RANDOM
+ POSITION_CHILD_DEME_RANDOM,
+ POSITION_CHILD_PARENT_FACING
};
const int NUM_LOCAL_POSITION_CHILD = POSITION_CHILD_FULL_SOUP_RANDOM;
Modified: development/source/main/cAvidaConfig.h
===================================================================
--- development/source/main/cAvidaConfig.h 2006-10-16 00:22:11 UTC (rev 1046)
+++ development/source/main/cAvidaConfig.h 2006-10-16 02:55:45 UTC (rev 1047)
@@ -153,13 +153,13 @@
#else
CONFIG_ADD_GROUP(GENERAL_GROUP, "General Settings");
CONFIG_ADD_VAR(ANALYZE_MODE, int, 0, "0 = Disabled\n1 = Enabled\n2 = Interactive");
- CONFIG_ADD_VAR(VIEW_MODE, int, 0, "Initial viewer screen");
+ CONFIG_ADD_VAR(VIEW_MODE, int, 1, "Initial viewer screen");
CONFIG_ADD_VAR(CLONE_FILE, cString, "-", "Clone file to load");
CONFIG_ADD_VAR(VERBOSITY, int, 1, "Control output verbosity");
CONFIG_ADD_GROUP(ARCH_GROUP, "Architecture Variables");
- CONFIG_ADD_VAR(WORLD_X, int, 100, "Width of the Avida world");
- CONFIG_ADD_VAR(WORLD_Y, int, 100, "Height of the Avida world");
+ CONFIG_ADD_VAR(WORLD_X, int, 60, "Width of the Avida world");
+ CONFIG_ADD_VAR(WORLD_Y, int, 60, "Height of the Avida world");
CONFIG_ADD_VAR(WORLD_GEOMETRY, int, 2, "1 = Bounded Grid\n2 = Torus");
CONFIG_ADD_VAR(NUM_DEMES, int, 0, "Number of independed groups in the population; 0=off");
CONFIG_ADD_VAR(RANDOM_SEED, int, 0, "Random number seed (0 for based on time)");
@@ -174,7 +174,7 @@
CONFIG_ADD_VAR(START_CREATURE, cString, "default-classic.org", "Organism to seed the soup");
CONFIG_ADD_GROUP(REPRODUCTION_GROUP, "Birth and Death");
- CONFIG_ADD_VAR(BIRTH_METHOD, int, 4, "0 = Replace random organism in neighborhood\n1 = Replace oldest organism in neighborhood\n2 = Replace largest Age/Merit in neighborhood\n3 = Place only in empty cells in neighborhood\n4 = Replace random from population (Mass Action)\n5 = Replace oldest in entire population (like Tierra)\n6 = Replace random within deme");
+ CONFIG_ADD_VAR(BIRTH_METHOD, int, 0, "Which organism should be replaced on birth?\n0 = Random organism in neighborhood\n1 = Oldest in neighborhood\n2 = Largest Age/Merit in neighborhood\n3 = None (use only empty cells in neighborhood)\n4 = Random from population (Mass Action)\n5 = Oldest in entire population\n6 = Random within deme\n7 = Organism faced by parent");
CONFIG_ADD_VAR(PREFER_EMPTY, int, 1, "Give empty cells preference in offsping placement?");
CONFIG_ADD_VAR(DEATH_METHOD, int, 2, "0 = Never die of old age.\n1 = Die when inst executed = AGE_LIMIT (+deviation)\n2 = Die when inst executed = length*AGE_LIMIT (+dev)");
CONFIG_ADD_VAR(AGE_LIMIT, int, 20, "Modifies DEATH_METHOD");
Modified: development/source/main/cBirthChamber.cc
===================================================================
--- development/source/main/cBirthChamber.cc 2006-10-16 00:22:11 UTC (rev 1046)
+++ development/source/main/cBirthChamber.cc 2006-10-16 02:55:45 UTC (rev 1047)
@@ -462,8 +462,11 @@
child_genotype->IncDeferAdjust();
}
-bool cBirthChamber::SubmitOffspring(cAvidaContext& ctx, const cGenome& child_genome, cOrganism& parent,
- tArray<cOrganism*>& child_array, tArray<cMerit>& merit_array)
+bool cBirthChamber::SubmitOffspring(cAvidaContext& ctx,
+ const cGenome& child_genome,
+ cOrganism& parent,
+ tArray<cOrganism*>& child_array,
+ tArray<cMerit>& merit_array)
{
cPhenotype& parent_phenotype = parent.GetPhenotype();
@@ -479,7 +482,8 @@
// Find a waiting entry (locally or globally)
cBirthEntry * old_entry = NULL;
// First check if the birth method is one of the local ones...
- if (birth_method < NUM_LOCAL_POSITION_CHILD) {
+ if (birth_method < NUM_LOCAL_POSITION_CHILD ||
+ birth_method == POSITION_CHILD_PARENT_FACING) {
old_entry = FindSexLocalWaiting(ctx, child_genome, parent);
}
// ... then check if population is split into demes
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2006-10-16 00:22:11 UTC (rev 1046)
+++ development/source/main/cPopulation.cc 2006-10-16 02:55:45 UTC (rev 1047)
@@ -318,7 +318,9 @@
schedule->Adjust(parent_cell.GetID(), parent_phenotype.GetMerit());
// In a local run, face the child toward the parent.
- if (m_world->GetConfig().BIRTH_METHOD.Get() < NUM_LOCAL_POSITION_CHILD) {
+ const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
+ if (birth_method < NUM_LOCAL_POSITION_CHILD ||
+ birth_method == POSITION_CHILD_PARENT_FACING) {
for (int i = 0; i < child_array.GetSize(); i++) {
GetCell(target_cells[i]).Rotate(parent_cell);
}
@@ -1010,7 +1012,12 @@
deme_birth_count[cur_deme]++;
return GetCell(out_pos);
}
-
+ else if (birth_method == POSITION_CHILD_PARENT_FACING) {
+ return parent_cell.GetCellFaced();
+ }
+
+ // All remaining methods require us to choose among mulitple local positions.
+
// Construct a list of equally viable locations to place the child...
tList<cPopulationCell> found_list;
Modified: development/source/main/cPopulationCell.h
===================================================================
--- development/source/main/cPopulationCell.h 2006-10-16 00:22:11 UTC (rev 1046)
+++ development/source/main/cPopulationCell.h 2006-10-16 02:55:45 UTC (rev 1047)
@@ -58,6 +58,7 @@
cOrganism* GetOrganism() const { return organism; }
tList<cPopulationCell> & ConnectionList() { return connection_list; }
+ cPopulationCell & GetCellFaced() { return *(connection_list.GetFirst()); }
const cMutationRates & MutationRates() const { return *mutation_rates; }
cMutationRates & MutationRates() { return *mutation_rates; }
int GetInput();
Modified: development/source/tools/cMerit.h
===================================================================
--- development/source/tools/cMerit.h 2006-10-16 00:22:11 UTC (rev 1046)
+++ development/source/tools/cMerit.h 2006-10-16 02:55:45 UTC (rev 1047)
@@ -69,9 +69,10 @@
double GetDouble() const { return value; }
- int GetBit(unsigned int bit_num) const {
- return ( bit_num >= offset && bit_num < (unsigned int)bits ) ?
- ( base >> (bit_num-offset) ) & 1 : 0; }
+ int GetBit(int bit_num) const {
+ assert(bit_num >= 0);
+ return ( bit_num >= offset && bit_num < bits ) ?
+ ( base >> (bit_num-offset) ) & 1 : 0; }
int GetNumBits() const { return bits; }
More information about the Avida-cvs
mailing list