[Avida-SVN] r2873 - branches/vo/source/viewer-core
michaelvo at myxo.css.msu.edu
michaelvo at myxo.css.msu.edu
Fri Oct 24 08:03:27 PDT 2008
Author: michaelvo
Date: 2008-10-24 11:03:26 -0400 (Fri, 24 Oct 2008)
New Revision: 2873
Added:
branches/vo/source/viewer-core/cCoreView_Text.h
Log:
I accidentally screwed something up.
Added: branches/vo/source/viewer-core/cCoreView_Text.h
===================================================================
--- branches/vo/source/viewer-core/cCoreView_Text.h (rev 0)
+++ branches/vo/source/viewer-core/cCoreView_Text.h 2008-10-24 15:03:26 UTC (rev 2873)
@@ -0,0 +1,113 @@
+/*
+ * cCoreView_Text.h
+ *
+ *
+ * Created by Michael Vo on 7/1/08.
+ * Copyright 2008 __MyCompanyName__. All rights reserved.
+ *
+ */
+
+
+// This class helps manage the map object in the user inteface.
+
+#ifndef cCoreView_Text_h
+#define cCoreView_Text_h
+
+#include "cString.h"
+
+#include "tArray.h"
+
+
+#include "cGenotype.h"
+#include "cHardwareBase.h"
+#include "cHardwareManager.h"
+#include "cOrganism.h"
+#include "cPopulation.h"
+#include "cPopulationCell.h"
+#include "cStats.h"
+#include "cWorld.h"
+#include "cEnvironment.h"
+
+class cCoreView_Text {
+public:
+ cCoreView_Text(cWorld* in_world) : m_world(in_world) {};
+
+ int GetOrganismID(int x, int y)
+ {
+ return x + y * m_world->GetPopulation().GetWorldX();
+ }
+ tArray< cString > GetOrganismInstructions(int x, int y)
+ {
+ tArray< cString > inst;
+
+ // get the organism ID based on (x, y)
+ int org_id= GetOrganismID(x, y);
+
+ // if that organism doesn't exist, return an empty array
+ if(m_world->GetPopulation().GetCell(org_id).GetOrganism()==NULL) return inst;
+
+ // otherwise, get the organism's genome and get the instructions using the
+ // hardware manager's inst set
+ cGenome orgGenome = m_world->GetPopulation().GetCell(org_id).GetOrganism()->GetGenome();
+
+ for(int n=0; n<orgGenome.AsString().GetSize(); n++)
+ {
+ inst.Push(m_world->GetHardwareManager().GetInstSet().GetName(orgGenome[n]));
+ }
+ return inst;
+ }
+
+ int GetGenotypeID(int x, int y)
+ {
+ if(m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()==NULL) return -1;
+ return m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()->GetGenotype()->GetID();
+ }
+
+ cString GetGenotypeName(int x, int y)
+ {
+ if(m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()==NULL) return "";
+ return m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()->GetGenotype()->GetName();
+ }
+
+ double GetEnergy(int x, int y)
+ {
+ if(m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()==NULL) return -1;
+ return m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()->GetPhenotype().GetStoredEnergy();
+ }
+
+ int GetFaults(int x, int y)
+ {
+ if(m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()==NULL) return -1;
+ return m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()->GetPhenotype().GetCurNumErrors();
+ }
+
+ int GetOffspring(int x, int y)
+ {
+ if(m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()==NULL) return -1;
+ return m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()->GetPhenotype().GetNumDivides();
+ }
+
+ int GetRegister(int x, int y, int reg_id)
+ {
+ if(m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()==NULL) return -1;
+ return m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()->GetHardware().GetRegister(reg_id);
+ }
+
+ int GetStack(int x, int y, int stack_id)
+ {
+ if(m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()==NULL) return -1;
+ return m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()->GetHardware().GetStack(stack_id);
+ }
+
+ int GetInputs(int x, int y, int inputs_id)
+ {
+ if(m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetOrganism()==NULL) return -1;
+ return m_world->GetPopulation().GetCell(GetOrganismID(x, y)).GetInput(inputs_id);
+ }
+
+
+private:
+ cWorld* m_world;
+};
+
+#endif
More information about the Avida-cvs
mailing list