[Avida-SVN] r2121 - branches/dkdev/source/main
dknoester at myxo.css.msu.edu
dknoester at myxo.css.msu.edu
Tue Oct 2 18:51:16 PDT 2007
Author: dknoester
Date: 2007-10-02 21:51:06 -0400 (Tue, 02 Oct 2007)
New Revision: 2121
Modified:
branches/dkdev/source/main/cStats.cc
branches/dkdev/source/main/cStats.h
branches/dkdev/source/main/cTaskLib.cc
Log:
Split the region task into 4 different parts - one that gives no bonus for incorrecness, and then 3 different levels of task quality based on behavior.
Modified: branches/dkdev/source/main/cStats.cc
===================================================================
--- branches/dkdev/source/main/cStats.cc 2007-10-03 01:42:28 UTC (rev 2120)
+++ branches/dkdev/source/main/cStats.cc 2007-10-03 01:51:06 UTC (rev 2121)
@@ -96,9 +96,11 @@
, num_own_used(0)
, _topo_connected(0)
, _deme_repl_count(0)
- , _two_cells_latched(0)
+ , _two_cells_incorrect(0)
+ , _two_cells_inside(0)
+ , _two_cells_outside(0)
+ , _two_cells_partial(0)
, _two_cells_unlatched(0)
- , _two_cells_correct(0)
{
task_cur_count.Resize( m_world->GetNumTasks() );
task_last_count.Resize( m_world->GetNumTasks() );
@@ -1060,13 +1062,27 @@
}
-void cStats::TwoCellsRegionLatched(bool correct) {
- ++_two_cells_latched;
- if(correct) ++_two_cells_correct;
+void cStats::TwoCellsIncorrectRegion() {
+ ++_two_cells_incorrect;
}
-void cStats::TwoCellsRegionUnlatched() {
+void cStats::TwoCellsInsideRegion() {
+ ++_two_cells_inside;
+}
+
+
+void cStats::TwoCellsOutsideRegion() {
+ ++_two_cells_outside;
+}
+
+
+void cStats::TwoCellsPartialRegion() {
+ ++_two_cells_partial;
+}
+
+
+void cStats::TwoCellsUnlatched() {
++_two_cells_unlatched;
}
@@ -1076,14 +1092,18 @@
df.WriteComment("Two-cells path finding data");
df.WriteTimeStamp();
df.Write(GetUpdate(), "update [update]");
- df.Write(_two_cells_latched, "count of orgs that latched their region and called IO [latched]");
- df.Write(_two_cells_unlatched, "count of orgs that did not latch their region but called IO [unlatched]");
- df.Write(_two_cells_correct, "count of orgs that correctly latched their region [correct]");
+ df.Write(_two_cells_incorrect, "Count of individuals that declared their region incorrectly [incorrect]");
+ df.Write(_two_cells_inside, "Count of individuals that correctly declared themselves inside the region [inside]");
+ df.Write(_two_cells_outside, "Count of individuals that correctly declared themselves outside the region [outside]");
+ df.Write(_two_cells_partial, "Count of individuals that were partially correct [partial]");
+ df.Write(_two_cells_unlatched, "Count of individuals that have not latched a decision [unlatched]");
df.Endl();
-
- _two_cells_latched = 0;
+
+ _two_cells_incorrect = 0;
+ _two_cells_inside = 0;
+ _two_cells_outside = 0;
+ _two_cells_partial = 0;
_two_cells_unlatched = 0;
- _two_cells_correct = 0;
}
Modified: branches/dkdev/source/main/cStats.h
===================================================================
--- branches/dkdev/source/main/cStats.h 2007-10-03 01:42:28 UTC (rev 2120)
+++ branches/dkdev/source/main/cStats.h 2007-10-03 01:51:06 UTC (rev 2121)
@@ -620,15 +620,21 @@
// Two-cells related statistics
//
public:
- void TwoCellsRegionLatched(bool correct);
- void TwoCellsRegionUnlatched();
+ void TwoCellsIncorrectRegion();
+ void TwoCellsInsideRegion();
+ void TwoCellsOutsideRegion();
+ void TwoCellsPartialRegion();
+ void TwoCellsUnlatched();
+
void PrintTwoCellsData(const cString& filename);
void PrintTwoCellsLocations(const cString& filename);
private:
- int _two_cells_latched; //!< Count of organisms that have latched their region and called IO.
- int _two_cells_unlatched; //!< Count of organisms that have not latched their region and called IO.
- int _two_cells_correct; //!< Count of organisms that latched their region correctly.
+ int _two_cells_incorrect; //!< Count of individuals that declared their region incorrectly.
+ int _two_cells_inside; //!< Count of individuals that correctly declared themselves inside the region.
+ int _two_cells_outside; //!< Count of individuals that correctly declared themselces outside the region.
+ int _two_cells_partial; //!< Count of individuals that were partially correct.
+ int _two_cells_unlatched; //!< Count of individuals that have not latched a decision.
};
Modified: branches/dkdev/source/main/cTaskLib.cc
===================================================================
--- branches/dkdev/source/main/cTaskLib.cc 2007-10-03 01:42:28 UTC (rev 2120)
+++ branches/dkdev/source/main/cTaskLib.cc 2007-10-03 01:51:06 UTC (rev 2121)
@@ -1866,34 +1866,52 @@
use compete demes with this approach. */
double cTaskLib::Task_CorrectRegion(cTaskContext* ctx) const {
cOrganism* organism = ctx->GetOrganism();
- if(organism->IsRegionLatched()) {
- // get the data that we need to check if this cell is within the region described
- // by the two randomly selected cells.
- cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
- cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
- std::pair<int,int> one_xy = deme.GetCellPosition(deme.GetCellsToLink().first);
- std::pair<int,int> two_xy = deme.GetCellPosition(deme.GetCellsToLink().second);
+
+ // Did the organism even make a decision?
+ if(!organism->IsRegionLatched()) {
+ m_world->GetStats().TwoCellsUnlatched();
+ return 0.0;
+ }
- // get the region
- std::pair<int,int> x_range = std::make_pair(std::min(one_xy.first, two_xy.first), std::max(one_xy.first, two_xy.first));
- std::pair<int,int> y_range = std::make_pair(std::min(one_xy.second, two_xy.second), std::max(one_xy.second, two_xy.second));
-
- // and test if this organism has selected the correct region.
- std::pair<int,int> self_xy = deme.GetCellPosition(organism->GetCellID());
- bool correct = false;
- if((self_xy.first >= x_range.first)
- && (self_xy.first <= x_range.second)
- && (self_xy.second >= y_range.first)
- && (self_xy.second <= y_range.second)) {
- // within region
- correct = (organism->GetRegion() == 1);
- } else {
- correct = (organism->GetRegion() == 0);
- }
-
- m_world->GetStats().TwoCellsRegionLatched(correct);
- return correct;
+ // get the data that we need to check if this cell is within the region described
+ // by the two randomly selected cells.
+ cPopulationCell& cell = m_world->GetPopulation().GetCell(organism->GetCellID());
+ cDeme& deme = m_world->GetPopulation().GetDeme(cell.GetDemeID());
+ std::pair<int,int> one_xy = deme.GetCellPosition(deme.GetCellsToLink().first);
+ std::pair<int,int> two_xy = deme.GetCellPosition(deme.GetCellsToLink().second);
+ std::pair<int,int> self_xy = deme.GetCellPosition(organism->GetCellID());
+
+ // create the region
+ std::pair<int,int> x_range = std::make_pair(std::min(one_xy.first, two_xy.first), std::max(one_xy.first, two_xy.first));
+ std::pair<int,int> y_range = std::make_pair(std::min(one_xy.second, two_xy.second), std::max(one_xy.second, two_xy.second));
+
+ // Is this organism in a dead zone, and yet declaring itself to be in the region?
+ if(((self_xy.first < x_range.first) || (self_xy.first > x_range.second))
+ && ((self_xy.second < y_range.first) || (self_xy.second > y_range.second))
+ && organism->GetRegion()) {
+ m_world->GetStats().TwoCellsIncorrectRegion();
+ return 0.0;
}
- m_world->GetStats().TwoCellsRegionUnlatched();
- return 0.0;
+
+ // Is this organism correctly declaring itself to be in the region?
+ if((self_xy.first >= x_range.first)
+ && (self_xy.first <= x_range.second)
+ && (self_xy.second >= y_range.first)
+ && (self_xy.second <= y_range.second)
+ && organism->GetRegion()) {
+ m_world->GetStats().TwoCellsInsideRegion();
+ return 3.0;
+ }
+
+ // Is this organism correctly declaring itself to be outside the region?
+ if(((self_xy.first < x_range.first) || (self_xy.first > x_range.second))
+ && ((self_xy.second < y_range.first) || (self_xy.second > y_range.second))
+ && !organism->GetRegion()) {
+ m_world->GetStats().TwoCellsOutsideRegion();
+ return 2.0;
+ }
+
+ // Partial reward - It's not entirely wrong or right.
+ m_world->GetStats().TwoCellsPartialRegion();
+ return 1.0;
}
More information about the Avida-cvs
mailing list