[Avida-SVN] r2547 - in branches/energy/source: cpu main
connel42 at myxo.css.msu.edu
connel42 at myxo.css.msu.edu
Tue Apr 22 12:17:40 PDT 2008
Author: connel42
Date: 2008-04-22 15:17:40 -0400 (Tue, 22 Apr 2008)
New Revision: 2547
Modified:
branches/energy/source/cpu/cHardwareCPU.cc
branches/energy/source/main/cAvidaConfig.h
Log:
* fixed rotation in explore
Modified: branches/energy/source/cpu/cHardwareCPU.cc
===================================================================
--- branches/energy/source/cpu/cHardwareCPU.cc 2008-04-22 02:40:38 UTC (rev 2546)
+++ branches/energy/source/cpu/cHardwareCPU.cc 2008-04-22 19:17:40 UTC (rev 2547)
@@ -3250,7 +3250,7 @@
// out here so that non-pheromone moves are recorded.
if( (m_world->GetConfig().LOG_PHEROMONE.Get() == 1) &&
(m_world->GetStats().GetUpdate() >= m_world->GetConfig().MOVETARGET_LOG_START.Get()) ) {
- cString tmpfilename = cStringUtil::Stringf("movetarget_movelog.dat");
+ cString tmpfilename = cStringUtil::Stringf("movelog.dat");
cDataFile& df = m_world->GetDataFile(tmpfilename);
int rel_srcid = deme.GetRelativeCellID(fromcellID);
@@ -3266,7 +3266,7 @@
pher_amount = 0;
}
- cString UpdateStr = cStringUtil::Stringf("%d %d %d %d %d %f %d", m_world->GetStats().GetUpdate(), organism->GetID(), deme.GetDemeID(), rel_srcid, rel_destid, pher_amount, drop_mode);
+ cString UpdateStr = cStringUtil::Stringf("%d,%d,%d,%d,%d,%f,%d,1", m_world->GetStats().GetUpdate(), organism->GetID(), deme.GetDemeID(), rel_srcid, rel_destid, pher_amount, drop_mode);
df.WriteRaw(UpdateStr);
}
@@ -3302,7 +3302,9 @@
// Rotate randomly. Code taken from tumble.
const int num_neighbors = organism->GetNeighborhoodSize();
- organism->Rotate(ctx.GetRandom().GetUInt(num_neighbors));
+ for(int i = 0; i < ctx.GetRandom().GetUInt(num_neighbors); i++) {
+ organism->Rotate(1); // Rotate doesn't rotate N times, just once.
+ }
// Move to the faced cell
@@ -3359,7 +3361,7 @@
// out here so that non-pheromone moves are recorded.
if( (m_world->GetConfig().LOG_PHEROMONE.Get() == 1) &&
(m_world->GetStats().GetUpdate() >= m_world->GetConfig().EXPLORE_LOG_START.Get()) ) {
- cString tmpfilename = cStringUtil::Stringf("explore_movelog.dat");
+ cString tmpfilename = cStringUtil::Stringf("movelog.dat");
cDataFile& df = m_world->GetDataFile(tmpfilename);
int rel_srcid = deme.GetRelativeCellID(fromcellID);
@@ -3375,7 +3377,7 @@
pher_amount = 0;
}
- cString UpdateStr = cStringUtil::Stringf("%d %d %d %d %d %f %d", m_world->GetStats().GetUpdate(), organism->GetID(), deme.GetDemeID(), rel_srcid, rel_destid, pher_amount, drop_mode);
+ cString UpdateStr = cStringUtil::Stringf("%d,%d,%d,%d,%d,%f,%d,2", m_world->GetStats().GetUpdate(), organism->GetID(), deme.GetDemeID(), rel_srcid, rel_destid, pher_amount, drop_mode);
df.WriteRaw(UpdateStr);
}
@@ -3491,7 +3493,7 @@
// out here so that non-pheromone moves are recorded.
if( (m_world->GetConfig().LOG_PHEROMONE.Get() == 1) &&
(m_world->GetStats().GetUpdate() >= m_world->GetConfig().EXPLOIT_LOG_START.Get()) ) {
- cString tmpfilename = cStringUtil::Stringf("exploit_movelog.dat");
+ cString tmpfilename = cStringUtil::Stringf("movelog.dat");
cDataFile& df = m_world->GetDataFile(tmpfilename);
int rel_srcid = deme.GetRelativeCellID(fromcellID);
@@ -3507,7 +3509,7 @@
pher_amount = 0;
}
- cString UpdateStr = cStringUtil::Stringf("%d %d %d %d %d %f %d", m_world->GetStats().GetUpdate(), organism->GetID(), deme.GetDemeID(), rel_srcid, rel_destid, pher_amount, drop_mode);
+ cString UpdateStr = cStringUtil::Stringf("%d,%d,%d,%d,%d,%f,%d,3", m_world->GetStats().GetUpdate(), organism->GetID(), deme.GetDemeID(), rel_srcid, rel_destid, pher_amount, drop_mode);
df.WriteRaw(UpdateStr);
}
@@ -3589,8 +3591,30 @@
}
*/
deme.AddPheromone(cellid, pher_amount);
-//GEEZ
+
+ // Write some logging information if LOG_PHEROMONE is set. This is done
+ // out here so that non-pheromone moves are recorded.
+ if( (m_world->GetConfig().LOG_PHEROMONE.Get() == 1) &&
+ (m_world->GetStats().GetUpdate() >= m_world->GetConfig().PHEROMONE_LOG_START.Get()) ) {
+ cString tmpfilename = cStringUtil::Stringf("drop-pheromone-log.dat");
+ cDataFile& df = m_world->GetDataFile(tmpfilename);
+ int rel_cellid = deme.GetRelativeCellID(cellid);
+ double pher_amount;
+ const int drop_mode = m_world->GetConfig().PHEROMONE_DROP_MODE.Get();
+
+ // By columns: update ID, org ID, source cell (relative), destination cell (relative), amount dropped, drop mode
+ if( (m_world->GetConfig().PHEROMONE_ENABLED.Get() == 1) &&
+ (organism->GetPheromoneStatus() == true) ) {
+ pher_amount = m_world->GetConfig().PHEROMONE_AMOUNT.Get();
+ } else {
+ pher_amount = 0;
+ }
+
+ cString UpdateStr = cStringUtil::Stringf("%d,%d,%d,%d,%f,%d", m_world->GetStats().GetUpdate(), organism->GetID(), deme.GetDemeID(), rel_cellid, pher_amount, drop_mode);
+ df.WriteRaw(UpdateStr);
+ }
+
} //End laying pheromone
return true;
Modified: branches/energy/source/main/cAvidaConfig.h
===================================================================
--- branches/energy/source/main/cAvidaConfig.h 2008-04-22 02:40:38 UTC (rev 2546)
+++ branches/energy/source/main/cAvidaConfig.h 2008-04-22 19:17:40 UTC (rev 2547)
@@ -515,6 +515,7 @@
CONFIG_ADD_VAR(PHEROMONE_AMOUNT, double, 1.0, "Amount of pheromone to add per drop");
CONFIG_ADD_VAR(PHEROMONE_DROP_MODE, int, 0, "Where to drop pheromone\n0 = Half amount at src, half at dest\n1=All at source\n2 = All at dest");
CONFIG_ADD_VAR(LOG_PHEROMONE, bool, 0, "Log pheromone drops. 0/1 (off/on)");
+ CONFIG_ADD_VAR(PHEROMONE_LOG_START, int, 0, "Update at which to start logging pheromone drops");
CONFIG_ADD_VAR(EXPLOIT_LOG_START, int, 0, "Update at which to start logging exploit moves");
CONFIG_ADD_VAR(EXPLORE_LOG_START, int, 0, "Update at which to start logging explore moves");
CONFIG_ADD_VAR(MOVETARGET_LOG_START, int, 0, "Update at which to start logging movetarget moves");
More information about the Avida-cvs
mailing list