[Avida-SVN] r2063 - branches/energy/source/main
beckma24 at myxo.css.msu.edu
beckma24 at myxo.css.msu.edu
Thu Sep 6 13:28:03 PDT 2007
Author: beckma24
Date: 2007-09-06 16:28:03 -0400 (Thu, 06 Sep 2007)
New Revision: 2063
Added:
branches/energy/source/main/cDemeCellEvent.cc
branches/energy/source/main/cDemeCellEvent.h
Modified:
branches/energy/source/main/cDeme.cc
Log:
Fixing my local mistake
Modified: branches/energy/source/main/cDeme.cc
===================================================================
--- branches/energy/source/main/cDeme.cc 2007-09-06 18:55:35 UTC (rev 2062)
+++ branches/energy/source/main/cDeme.cc 2007-09-06 20:28:03 UTC (rev 2063)
@@ -73,7 +73,7 @@
m_world->GetPopulation().GetCell(GetCellID(eventCell)).SetCellData(event.GetEventID());
eventCell = event.GetNextEventCellID();
}
- } else if(event.GetDelay()+event.DetDuration() == _age) {
+ } else if(event.GetDelay()+event.GetDuration() == _age) {
int eventCell = event.GetNextEventCellID();
while(eventCell != -1) {
if(event.GetEventID() == m_world->GetPopulation().GetCell(GetCellID(eventCell)).GetCellData()) { // eventID == CellData
Added: branches/energy/source/main/cDemeCellEvent.cc
===================================================================
--- branches/energy/source/main/cDemeCellEvent.cc (rev 0)
+++ branches/energy/source/main/cDemeCellEvent.cc 2007-09-06 20:28:03 UTC (rev 2063)
@@ -0,0 +1,42 @@
+#include "cDemeCellEvent.h"
+#include "cWorld.h"
+
+cDemeCellEvent::cDemeCellEvent(int x1, int y1, int x2, int y2, int delay, int duration, int width, cWorld* m_world) :
+ m_delay(delay)
+ , m_duration(duration)
+ , m_iter(-1)
+ , m_active(false)
+{
+ assert(x1 <= x2);
+ assert(y1 <= y2);
+ assert(y1 < width && y2 < width);
+ assert(delay >= 0);
+ assert(duration >= 0);
+
+ m_world->GetRandom().GetInt(0x7FFFFFFF);
+ m_event_cells.ResizeClear((x2-x1+1) * (y2-y1+1));
+
+ int i = 0;
+ for(int j = y1; j <= y2; j++) {
+ for(int k = x1; k <= x2; k++) {
+ m_event_cells[i] = j*width+k;
+ i++;
+ }
+ }
+}
+
+int cDemeCellEvent::GetNextEventCellID() {
+ if(m_active && m_iter < m_event_cells.GetSize()) {
+ return m_event_cells[m_iter++];
+ }
+ m_iter = 0;
+ return -1;
+}
+
+void cDemeCellEvent::ActivateEvent() {
+ m_active = true;
+}
+
+void cDemeCellEvent::DeactivateEvent() {
+ m_active = false;
+}
Added: branches/energy/source/main/cDemeCellEvent.h
===================================================================
--- branches/energy/source/main/cDemeCellEvent.h (rev 0)
+++ branches/energy/source/main/cDemeCellEvent.h 2007-09-06 20:28:03 UTC (rev 2063)
@@ -0,0 +1,24 @@
+#ifndef cDemeCellEvent_h
+#define cDemeCellEvent_h
+
+#include "tArray.h"
+class cWorld;
+
+class cDemeCellEvent {
+private:
+ tArray<int> m_event_cells;
+ int m_delay, m_duration, m_eventID, m_iter;
+ bool m_active;
+
+public:
+ cDemeCellEvent() { cDemeCellEvent(-1, -1, -1, -1, 0, 0, 0, NULL); }
+ cDemeCellEvent(int x1, int y1, int x2, int y2, int delay, int duration, int width, cWorld* m_world);
+ int GetNextEventCellID();
+ int GetDelay() { return m_delay; }
+ int GetDuration() { return m_duration; }
+ int GetEventID() { return m_eventID; }
+
+ void ActivateEvent();
+ void DeactivateEvent();
+};
+#endif
More information about the Avida-cvs
mailing list