[Avida-SVN] r2122 - development/source/main
barrick at myxo.css.msu.edu
barrick at myxo.css.msu.edu
Wed Oct 3 09:19:14 PDT 2007
Author: barrick
Date: 2007-10-03 12:19:14 -0400 (Wed, 03 Oct 2007)
New Revision: 2122
Modified:
development/source/main/cPhenotype.cc
development/source/main/cPopulation.cc
Log:
Test CPU now calculates fitness correctly when MERIT_DEFAULT_BONUS is set.
Switched up an assert related to NUM_DEMES that was incorrectly being triggered.
Modified: development/source/main/cPhenotype.cc
===================================================================
--- development/source/main/cPhenotype.cc 2007-10-03 01:51:06 UTC (rev 2121)
+++ development/source/main/cPhenotype.cc 2007-10-03 16:19:14 UTC (rev 2122)
@@ -537,11 +537,9 @@
// and it will also be propagated to the child
const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
if (merit_default_bonus) {
- merit = cur_merit_base * m_world->GetConfig().DEFAULT_BONUS.Get();
+ cur_bonus = m_world->GetConfig().DEFAULT_BONUS.Get();
}
- else { // Default
- merit = cur_merit_base * cur_bonus;
- }
+ merit = cur_merit_base * cur_bonus;
//BB:TODO update energy store
SetEnergy(energy_store + cur_energy_bonus);
@@ -682,7 +680,11 @@
// Update these values as needed...
int cur_merit_base = CalcSizeMerit();
- merit = cur_merit_base * cur_bonus;
+ const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
+ if (merit_default_bonus) {
+ cur_bonus = m_world->GetConfig().DEFAULT_BONUS.Get();
+ }
+ merit = cur_merit_base * cur_bonus;
genome_length = _genome.GetSize();
(void) copied_size; // Unchanged
@@ -1440,11 +1442,9 @@
// and it will also be propagated to the child
int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
if (merit_default_bonus) {
- merit = cur_merit_base * m_world->GetConfig().DEFAULT_BONUS.Get();
+ cur_bonus = m_world->GetConfig().DEFAULT_BONUS.Get();
}
- else { // Default
- merit = cur_merit_base * cur_bonus;
- }
+ merit = cur_merit_base * cur_bonus;
// update energy store
energy_store += cur_energy_bonus;
@@ -1565,11 +1565,9 @@
// and it will also be propagated to the child
const int merit_default_bonus = m_world->GetConfig().MERIT_DEFAULT_BONUS.Get();
if (merit_default_bonus) {
- merit = cur_merit_base * m_world->GetConfig().DEFAULT_BONUS.Get();
+ cur_bonus = m_world->GetConfig().DEFAULT_BONUS.Get();
}
- else { // Defaul
- merit = cur_merit_base * cur_bonus;
- }
+ merit = cur_merit_base * cur_bonus;
//BB:TODO update energy store
SetEnergy(energy_store + cur_energy_bonus);
Modified: development/source/main/cPopulation.cc
===================================================================
--- development/source/main/cPopulation.cc 2007-10-03 01:51:06 UTC (rev 2121)
+++ development/source/main/cPopulation.cc 2007-10-03 16:19:14 UTC (rev 2122)
@@ -106,16 +106,19 @@
}
}
+ // Invalid settings should be changed to one deme
+ if (num_demes <= 0) {
+ num_demes = 1; // One population == one deme.
+ }
+
// Error checking for demes vs. non-demes setup.
#ifdef DEBUG
const int birth_method = m_world->GetConfig().BIRTH_METHOD.Get();
-#endif
- if(num_demes > 0) {
+
+ if(num_demes > 1) {
assert(birth_method != POSITION_CHILD_FULL_SOUP_ELDEST);
- } else {
- assert(birth_method != POSITION_CHILD_DEME_RANDOM);
- num_demes = 1; // One population == one deme.
}
+#endif
// Allocate the cells, resources, and market.
cell_array.ResizeClear(num_cells);
More information about the Avida-cvs
mailing list