[Avida-cvs] [Avida2-svn] r394 - in development: Avida.xcodeproj source source/main source/tools source/viewer
brysonda@myxo.css.msu.edu
brysonda at myxo.css.msu.edu
Fri Nov 11 13:59:04 PST 2005
Author: brysonda
Date: 2005-11-11 16:59:04 -0500 (Fri, 11 Nov 2005)
New Revision: 394
Added:
development/source/classification/
Removed:
development/source/modules.pri
development/source/tools/tools.pri
Modified:
development/Avida.xcodeproj/project.pbxproj
development/source/main/cFitnessMatrix.cc
development/source/viewer/cBarScreen.cc
development/source/viewer/cBarScreen.h
development/source/viewer/cEnvironmentScreen.cc
development/source/viewer/cEnvironmentScreen.h
development/source/viewer/cStatsScreen.cc
development/source/viewer/cStatsScreen.h
development/source/viewer/cView.cc
Log:
Update viewer to handle movement of cStats into cWorld. cWorld is now passed through some of the viewer classes, though it is not pervasive. Also add directory to eventually hold classification (Manager, Phenotype, Genotype, Species, etc.) classes.
Modified: development/Avida.xcodeproj/project.pbxproj
===================================================================
--- development/Avida.xcodeproj/project.pbxproj 2005-11-11 19:47:15 UTC (rev 393)
+++ development/Avida.xcodeproj/project.pbxproj 2005-11-11 21:59:04 UTC (rev 394)
@@ -269,6 +269,7 @@
70D46934085F61DA004C8409 /* trio.c in Sources */ = {isa = PBXBuildFile; fileRef = DCC3146D076253A1008F7A48 /* trio.c */; };
70D46935085F61DD004C8409 /* trionan.c in Sources */ = {isa = PBXBuildFile; fileRef = DCC31471076253A1008F7A48 /* trionan.c */; };
70D46936085F61DF004C8409 /* triostr.c in Sources */ = {isa = PBXBuildFile; fileRef = DCC31474076253A1008F7A48 /* triostr.c */; };
+ 70F7D8CE09254787009E311D /* cFitnessMatrix.cc in Sources */ = {isa = PBXBuildFile; fileRef = 70CA6EB208DB7F8200068AC2 /* cFitnessMatrix.cc */; };
DCC3166107628531008F7A48 /* avida.cc in Sources */ = {isa = PBXBuildFile; fileRef = DCC3109C0762539E008F7A48 /* avida.cc */; };
/* End PBXBuildFile section */
@@ -683,7 +684,6 @@
DCC3109C0762539E008F7A48 /* avida.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = avida.cc; sourceTree = "<group>"; };
DCC310A90762539E008F7A48 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
DCC311090762539E008F7A48 /* primitive.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = primitive.cc; sourceTree = "<group>"; };
- DCC311390762539E008F7A48 /* modules.pri */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = modules.pri; sourceTree = "<group>"; };
DCC3114B0762539E008F7A48 /* analyze.cfg */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = analyze.cfg; sourceTree = "<group>"; };
DCC3114C0762539E008F7A48 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
DCC311680762539E008F7A48 /* environment.2paths */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = environment.2paths; sourceTree = "<group>"; };
@@ -971,7 +971,6 @@
DCC31587076253A4008F7A48 /* recursive_tests_macros.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = recursive_tests_macros.hh; sourceTree = "<group>"; };
DCC315A5076253A4008F7A48 /* CMakeLists.txt */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = CMakeLists.txt; sourceTree = "<group>"; };
DCC315A6076253A4008F7A48 /* UnitTest_recursive_tests.cc */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = UnitTest_recursive_tests.cc; sourceTree = "<group>"; };
- DCC315AC076253A5008F7A48 /* tools.pri */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text; path = tools.pri; sourceTree = "<group>"; };
DCC315AD076253A5008F7A48 /* tUnitTestSuite.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tUnitTestSuite.hh; sourceTree = "<group>"; };
DCC315AE076253A5008F7A48 /* tUnitTestSuiteRecurser.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tUnitTestSuiteRecurser.hh; sourceTree = "<group>"; };
DCC315B0076253A5008F7A48 /* tVerifierSuite.hh */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.h; path = tVerifierSuite.hh; sourceTree = "<group>"; };
@@ -1068,6 +1067,13 @@
path = viewer;
sourceTree = "<group>";
};
+ 70F7D8C8092546DC009E311D /* classification */ = {
+ isa = PBXGroup;
+ children = (
+ );
+ path = classification;
+ sourceTree = "<group>";
+ };
DCC30C490762532C008F7A48 = {
isa = PBXGroup;
children = (
@@ -1083,6 +1089,7 @@
isa = PBXGroup;
children = (
70422A1B091B141000A5E67F /* analyze */,
+ 70F7D8C8092546DC009E311D /* classification */,
DCC30F7C0762539D008F7A48 /* cpu */,
DCC30FD00762539D008F7A48 /* event */,
DCC310040762539D008F7A48 /* main */,
@@ -1095,7 +1102,6 @@
DCC30F7B0762539D008F7A48 /* CMakeLists.txt */,
701384A10902A16F0087ED2E /* defs.h */,
DCC30FCF0762539D008F7A48 /* Doxyfile */,
- DCC311390762539E008F7A48 /* modules.pri */,
);
name = Source;
path = source;
@@ -1865,7 +1871,6 @@
DCC31586076253A4008F7A48 /* recursive_tests_defn_hdrs.hh */,
DCC31587076253A4008F7A48 /* recursive_tests_macros.hh */,
DCC315A0076253A4008F7A48 /* tests */,
- DCC315AC076253A5008F7A48 /* tools.pri */,
DCC315AD076253A5008F7A48 /* tUnitTestSuite.hh */,
DCC315AE076253A5008F7A48 /* tUnitTestSuiteRecurser.hh */,
DCC315B0076253A5008F7A48 /* tVerifierSuite.hh */,
@@ -2307,6 +2312,7 @@
70422A34091B141000A5E67F /* cAnalyze.cc in Sources */,
70422A3C091B141000A5E67F /* cAnalyzeGenotype.cc in Sources */,
70422A3E091B141000A5E67F /* cAnalyzeUtil.cc in Sources */,
+ 70F7D8CE09254787009E311D /* cFitnessMatrix.cc in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Modified: development/source/main/cFitnessMatrix.cc
===================================================================
--- development/source/main/cFitnessMatrix.cc 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/main/cFitnessMatrix.cc 2005-11-11 21:59:04 UTC (rev 394)
@@ -625,7 +625,7 @@
for (double error = m_error_rate_min; error <= m_error_rate_max; error += m_error_rate_step)
{
vector<double> dataVect;
- double avg_fitness = Diagonalize(dataVect, m_ham_thresh, error, log_file);
+ double avg_fitness = Diagonalize(dataVect, m_ham_thresh, error, m_world->GetDataFileOFStream("fitness_matrix.log"));
PrintFitnessVector(m_world->GetDataFileOFStream("fitness_vect.dat"), dataVect, error, avg_fitness, output_start, output_step);
Deleted: development/source/modules.pri
===================================================================
--- development/source/modules.pri 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/modules.pri 2005-11-11 21:59:04 UTC (rev 394)
@@ -1,37 +0,0 @@
-
-CPU_CC = $$AVIDA_SRC_DIR/cpu
-EVENT_CC = $$AVIDA_SRC_DIR/event
-MAIN_CC = $$AVIDA_SRC_DIR/main
-TRIO_C = $$AVIDA_SRC_DIR/third-party/trio
-TOOLS_CC = $$AVIDA_SRC_DIR/tools
-SUPPORT_CC= $$AVIDA_SRC_DIR/support
-DOC_CC = $$AVIDA_SRC_DIR/../doc
-
-CPU_HH = $$CPU_CC
-EVENT_HH = $$EVENT_CC
-MAIN_HH = $$MAIN_CC
-TRIO_H = $$TRIO_C
-TOOLS_HH = $$TOOLS_CC
-SUPPORT_HH= $$SUPPORT_CC
-DOC_HH = $$DOC_CC
-
-DEPENDPATH += ;$$AVIDA_SRC_DIR
-DEPENDPATH += ;$$CPU_HH
-DEPENDPATH += ;$$EVENT_HH
-DEPENDPATH += ;$$MAIN_HH
-DEPENDPATH += ;$$TRIO_H
-DEPENDPATH += ;$$TOOLS_HH
-DEPENDPATH += ;$$SUPPORT_HH
-DEPENDPATH += ;$$DOC_HH
-DEPENDPATH += ;.
-
-INCLUDEPATH += $$DEPENDPATH
-QMAKE_CXXFLAGS += -I.
-
-include($$CPU_CC/cpu.pri)
-include($$EVENT_CC/event.pri)
-include($$MAIN_CC/main_sub.pri)
-include($$TRIO_C/trio.pri)
-include($$TOOLS_CC/tools.pri)
-#include($$SUPPORT_CC/support.pri)
-#include($$DOC_CC/doc.pri)
Deleted: development/source/tools/tools.pri
===================================================================
--- development/source/tools/tools.pri 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/tools/tools.pri 2005-11-11 21:59:04 UTC (rev 394)
@@ -1,65 +0,0 @@
-
-tools {
- HEADERS += $$TOOLS_HH/cIndexedBlockStruct.h \
- $$TOOLS_HH/cBlockStruct.h \
- $$TOOLS_HH/cDataEntry.h \
- $$TOOLS_HH/cDataManager_Base.h \
- $$TOOLS_HH/cDataFile.h \
- $$TOOLS_HH/cFile.h \
- $$TOOLS_HH/cFixedBlock.h \
- $$TOOLS_HH/functions.h \
- $$TOOLS_HH/cMerit.h \
- $$TOOLS_HH/cMessageDisplay.h \
- $$TOOLS_HH/cMessageDisplay_headers.h \
- $$TOOLS_HH/cRandom.h \
- $$TOOLS_HH/cString.h \
- $$TOOLS_HH/cStringList.h \
- $$TOOLS_HH/cStringUtil.h \
- $$TOOLS_HH/tArray.h \
- $$TOOLS_HH/tBuffer.h \
- $$TOOLS_HH/tDictionary.h \
- $$TOOLS_HH/tList.h \
- $$TOOLS_HH/tMatrix.h \
-# $$TOOLS_HH/tMemTrack.h \
- $$TOOLS_HH/cTools.h \
- $$TOOLS_HH/tVector.h \
- $$TOOLS_HH/cUInt.h \
- $$TOOLS_HH/cWeightedIndex.h \
- $$TOOLS_HH/win32_mkdir_hack.hh
-
- SOURCES += $$TOOLS_CC/cBlockStruct.cc \
- $$TOOLS_CC/cConstSchedule.cc \
- $$TOOLS_CC/cCountTracker.cc \
- $$TOOLS_CC/cDataEntry.cc \
- $$TOOLS_CC/cDataFile.cc \
- $$TOOLS_CC/cDataFileManager.cc \
- $$TOOLS_CC/cDataManager_Base.cc \
- $$TOOLS_CC/cDefaultMessageDisplay.cc \
- $$TOOLS_CC/cDoubleSum.cc \
- $$TOOLS_CC/cFile.cc \
- $$TOOLS_CC/cFixedBlock.cc \
- $$TOOLS_CC/cGenesis.cc \
- $$TOOLS_CC/cHelpAlias.cc \
- $$TOOLS_CC/cHelpManager.cc \
- $$TOOLS_CC/cHelpType.cc \
- $$TOOLS_CC/cHistogram.cc \
- $$TOOLS_CC/cIndexedBlockStruct.cc \
- $$TOOLS_CC/cInitFile.cc \
- $$TOOLS_CC/cIntSum.cc \
- $$TOOLS_CC/cIntegratedSchedule.cc \
- $$TOOLS_CC/cIntegratedScheduleNode.cc \
- $$TOOLS_CC/cMerit.cc \
- $$TOOLS_CC/cMessageDisplay.cc \
- $$TOOLS_CC/cProbSchedule.cc \
- $$TOOLS_CC/cRandom.cc \
- $$TOOLS_CC/cRefBlock.cc \
- $$TOOLS_CC/cRunningAverage.cc \
- $$TOOLS_CC/cScaledBlock.cc \
- $$TOOLS_CC/cSchedule.cc \
- $$TOOLS_CC/cString.cc \
- $$TOOLS_CC/cStringIterator.cc \
- $$TOOLS_CC/cStringList.cc \
- $$TOOLS_CC/cStringUtil.cc \
- $$TOOLS_CC/cTools.cc \
- $$TOOLS_CC/cWeightedIndex.cc
-}
Modified: development/source/viewer/cBarScreen.cc
===================================================================
--- development/source/viewer/cBarScreen.cc 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/viewer/cBarScreen.cc 2005-11-11 21:59:04 UTC (rev 394)
@@ -58,7 +58,7 @@
void cBarScreen::Update()
{
SetBoldColor(COLOR_WHITE);
- Print(1, 11, "%d", population.GetUpdate());
+ Print(1, 11, "%d", m_world->GetStats().GetUpdate());
SetColor(COLOR_WHITE);
Refresh();
Modified: development/source/viewer/cBarScreen.h
===================================================================
--- development/source/viewer/cBarScreen.h 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/viewer/cBarScreen.h 2005-11-11 21:59:04 UTC (rev 394)
@@ -17,15 +17,11 @@
class cBarScreen : public cScreen {
protected:
- cPopulation& population;
+ cWorld* m_world;
cString prog_name;
public:
- cBarScreen(int y_size, int x_size, int y_start, int x_start,
- cViewInfo & in_info, const cString & in_name,
- cPopulation& in_pop) :
- cScreen(y_size, x_size, y_start, x_start, in_info),
- population(in_pop),
- prog_name(in_name) { ; }
+ cBarScreen(cWorld* world, int y_size, int x_size, int y_start, int x_start, cViewInfo & in_info, const cString & in_name)
+ : cScreen(y_size, x_size, y_start, x_start, in_info), m_world(world), prog_name(in_name) { ; }
~cBarScreen() { ; }
// Virtual in base screen...
Modified: development/source/viewer/cEnvironmentScreen.cc
===================================================================
--- development/source/viewer/cEnvironmentScreen.cc 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/viewer/cEnvironmentScreen.cc 2005-11-11 21:59:04 UTC (rev 394)
@@ -32,7 +32,7 @@
Print(3, 54, "[ ]ause ");
Print(4, 54, " ");
}
-
+
SetBoldColor(COLOR_CYAN);
Print(1, 55, "<");
Print(1, 73, ">");
@@ -44,7 +44,7 @@
Print(3, 55, "P");
}
Print(5, 55, "UP, DOWN");
-
+
if(mode==ENVIRONMENT_MODE_RESOURCE)
DrawResource();
else
@@ -54,10 +54,10 @@
void cEnvironmentScreen::DrawResource()
{
- const cResourceLib & res_lib = population.GetEnvironment().GetResourceLib();
-
+ const cResourceLib & res_lib = m_world->GetEnvironment().GetResourceLib();
+
SetBoldColor(COLOR_WHITE);
-
+
Print(0, 0, " --Name-- ");
Print(0, 12, "--Inflow--");
Print(0, 24, "--Outflow--");
@@ -70,11 +70,11 @@
SetBoldColor(COLOR_CYAN);
for(int i=0; i<res_lib.GetSize(); i++)
- {
- Print(i+1, 1, res_lib.GetResource(i)->GetName());
- Print(i+1, 12, "%7.2f", res_lib.GetResource(i)->GetInflow());
- Print(i+1, 24, "%7.2f", res_lib.GetResource(i)->GetOutflow());
- }
+ {
+ Print(i+1, 1, res_lib.GetResource(i)->GetName());
+ Print(i+1, 12, "%7.2f", res_lib.GetResource(i)->GetInflow());
+ Print(i+1, 24, "%7.2f", res_lib.GetResource(i)->GetOutflow());
+ }
if (info.GetPauseLevel()) {
Print(3, 58, "P");
Print(4, 55, "N");
@@ -83,20 +83,20 @@
}
Print(5, 55, "UP, DOWN");
-
+
SetColor(COLOR_WHITE);
Box(0, res_lib.GetSize()+2, Width(), Height()-res_lib.GetSize()-2);
-
+
SetBoldColor(COLOR_YELLOW);
Print(1, 58, "Resource View");
}
void cEnvironmentScreen::DrawReaction()
{
- const cReactionLib & rxn_lib = population.GetEnvironment().GetReactionLib();
-
+ const cReactionLib & rxn_lib = m_world->GetEnvironment().GetReactionLib();
+
SetBoldColor(COLOR_WHITE);
-
+
Print(0, 0, " --Name-- ");
//Print(0, 12, "--Inflow--");
//Print(0, 24, "--Outflow--");
@@ -109,15 +109,15 @@
SetBoldColor(COLOR_CYAN);
for(int i=0; i<rxn_lib.GetSize(); i++)
- {
- Print(i+1, 1, rxn_lib.GetReaction(i)->GetName());
- //Print(i+1, 12, "%7.2f", res_lib.GetResource(i)->GetInflow());
- //Print(i+1, 24, "%7.2f", res_lib.GetResource(i)->GetOutflow());
- }
-
+ {
+ Print(i+1, 1, rxn_lib.GetReaction(i)->GetName());
+ //Print(i+1, 12, "%7.2f", res_lib.GetResource(i)->GetInflow());
+ //Print(i+1, 24, "%7.2f", res_lib.GetResource(i)->GetOutflow());
+ }
+
SetColor(COLOR_WHITE);
Box(0, rxn_lib.GetSize()+2, Width(), Height()-rxn_lib.GetSize()-2);
-
+
SetBoldColor(COLOR_YELLOW);
Print(1, 58, "Reaction View");
}
@@ -133,157 +133,151 @@
void cEnvironmentScreen::UpdateResource()
{
- const cResourceLib & res_lib = population.GetEnvironment().GetResourceLib();
- const cReactionLib & rxn_lib = population.GetEnvironment().GetReactionLib();
-
+ const cResourceLib & res_lib = m_world->GetEnvironment().GetResourceLib();
+ const cReactionLib & rxn_lib = m_world->GetEnvironment().GetReactionLib();
+
SetBoldColor(COLOR_CYAN);
//int j=0;
//int last_count=0;
- for(int i=0; i<population.GetResources().GetSize(); i++)
- {
- Print(i+1, 40, "%7.2f", population.GetResources()[i]);
- //if(population.GetResources()[i]/last_count < population.GetResources()[i].
- //Print(i+2, 65, "%7.2f", population.GetResources()[i]/last_count);
- }
-
+ for(int i=0; i<m_world->GetPopulation().GetResources().GetSize(); i++)
+ {
+ Print(i+1, 40, "%7.2f", m_world->GetPopulation().GetResources()[i]);
+ }
+
SetBoldColor(COLOR_BLUE);
Print(res_selection+1, 1, res_lib.GetResource(res_selection)->GetName());
Print(res_selection+1, 12, "%7.2f", res_lib.GetResource(res_selection)->GetInflow());
Print(res_selection+1, 24, "%7.2f", res_lib.GetResource(res_selection)->GetOutflow());
- Print(res_selection+1, 40, "%7.2f", population.GetResources()[res_selection]);
-
+ Print(res_selection+1, 40, "%7.2f", m_world->GetPopulation().GetResources()[res_selection]);
+
int offset=0;
-
+
SetBoldColor(COLOR_CYAN);
for(int i=0; i<rxn_lib.GetSize(); i++)
+ {
+ for(int j=0; j<rxn_lib.GetReaction(i)->GetProcesses().GetSize(); j++)
{
- for(int j=0; j<rxn_lib.GetReaction(i)->GetProcesses().GetSize(); j++)
- {
- if(rxn_lib.GetReaction(i)->GetProcesses().GetPos(j)->GetResource()->GetName() ==
- res_lib.GetResource(res_selection)->GetName())
+ if(rxn_lib.GetReaction(i)->GetProcesses().GetPos(j)->GetResource()->GetName() ==
+ res_lib.GetResource(res_selection)->GetName())
{
- Print(population.GetResources().GetSize()+5+offset, 2,
- rxn_lib.GetReaction(i)->GetName());
+ Print(m_world->GetPopulation().GetResources().GetSize()+5+offset, 2,
+ rxn_lib.GetReaction(i)->GetName());
offset++;
}
- }
}
+ }
SetBoldColor(COLOR_WHITE);
Print(res_lib.GetSize()+3, 37, "%s", res_lib.GetResource(res_selection)->GetName().GetData());
Print(res_lib.GetSize()+3, res_lib.GetResource(res_selection)->GetName().GetSize()+37, ":");
Print(res_lib.GetSize()+3, res_lib.GetResource(res_selection)->GetName().GetSize()+38, " ");
-
+
}
void cEnvironmentScreen::UpdateReaction()
{
- const cReactionLib & rxn_lib = population.GetEnvironment().GetReactionLib();
- const cResourceLib & res_lib = population.GetEnvironment().GetResourceLib();
-
+ const cReactionLib & rxn_lib = m_world->GetEnvironment().GetReactionLib();
+ const cResourceLib & res_lib = m_world->GetEnvironment().GetResourceLib();
+
SetBoldColor(COLOR_CYAN);
- //int j=0;
- //int last_count=0;
- for(int i=0; i<population.GetStats().GetReactions().GetSize(); i++)
- {
- Print(i+1, 40, "%7.2f", population.GetStats().GetReactions()[i]);
- //if(population.GetResources()[i]/last_count < population.GetResources()[i].
- //Print(i+2, 65, "%7.2f", population.GetResources()[i]/last_count);
- }
-
+ for(int i=0; i<m_world->GetStats().GetReactions().GetSize(); i++)
+ {
+ Print(i+1, 40, "%7.2f", m_world->GetStats().GetReactions()[i]);
+ }
+
SetBoldColor(COLOR_BLUE);
Print(rxn_selection+1, 1, rxn_lib.GetReaction(rxn_selection)->GetName());
- Print(rxn_selection+1, 40, "%7.2f", population.GetStats().GetReactions()[rxn_selection]);
-
-
+ Print(rxn_selection+1, 40, "%7.2f", m_world->GetStats().GetReactions()[rxn_selection]);
+
+
int offset=0;
-
+
SetBoldColor(COLOR_CYAN);
for(int i=0; i<rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetSize(); i++)
+ {
+ Print(m_world->GetStats().GetReactions().GetSize()+5+offset, 2,
+ rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetName());
+ Print(m_world->GetStats().GetReactions().GetSize()+5+offset, 13, "%7.2f",
+ rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetInflow());
+ Print(m_world->GetStats().GetReactions().GetSize()+5+offset, 25, "%7.2f",
+ rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetOutflow());
+ for(int j=0; j<res_lib.GetSize(); j++)
{
- Print(population.GetStats().GetReactions().GetSize()+5+offset, 2,
- rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetName());
- Print(population.GetStats().GetReactions().GetSize()+5+offset, 13, "%7.2f",
- rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetInflow());
- Print(population.GetStats().GetReactions().GetSize()+5+offset, 25, "%7.2f",
- rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetOutflow());
- for(int j=0; j<res_lib.GetSize(); j++)
- {
- if(res_lib.GetResource(j)->GetName() ==
- rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetName())
- Print(population.GetStats().GetReactions().GetSize()+5+offset, 40, "%7.2f",
- population.GetResources()[j]);
- }
- offset++;
+ if(res_lib.GetResource(j)->GetName() ==
+ rxn_lib.GetReaction(rxn_selection)->GetProcesses().GetPos(i)->GetResource()->GetName())
+ Print(m_world->GetStats().GetReactions().GetSize()+5+offset, 40, "%7.2f",
+ m_world->GetPopulation().GetResources()[j]);
}
+ offset++;
+ }
SetBoldColor(COLOR_WHITE);
Print(rxn_lib.GetSize()+3, 37, "%s", rxn_lib.GetReaction(rxn_selection)->GetName().GetData());
Print(rxn_lib.GetSize()+3, rxn_lib.GetReaction(rxn_selection)->GetName().GetSize()+37, ":");
Print(rxn_lib.GetSize()+3, rxn_lib.GetReaction(rxn_selection)->GetName().GetSize()+38, " ");
-
+
}
void cEnvironmentScreen::DoInput(int in_char)
{
int last_selection;
- const cResourceLib & res_lib = population.GetEnvironment().GetResourceLib();
- const cReactionLib & rxn_lib = population.GetEnvironment().GetReactionLib();
+ const cResourceLib & res_lib = m_world->GetEnvironment().GetResourceLib();
+ const cReactionLib & rxn_lib = m_world->GetEnvironment().GetReactionLib();
SetBoldColor(COLOR_CYAN);
-
+
switch (in_char) {
- case KEY_DOWN:
- if(mode==ENVIRONMENT_MODE_RESOURCE ) {
- last_selection=res_selection;
- res_selection++;
- res_selection%=population.GetResources().GetSize();
-
- Print(last_selection+1, 1, res_lib.GetResource(last_selection)->GetName());
- Print(last_selection+1, 12, "%7.2f", res_lib.GetResource(last_selection)->GetInflow());
- Print(last_selection+1, 24, "%7.2f", res_lib.GetResource(last_selection)->GetOutflow());
- }
- else {
- last_selection=rxn_selection;
- rxn_selection++;
- rxn_selection%=population.GetStats().GetReactions().GetSize();
-
- Print(last_selection+1, 1, rxn_lib.GetReaction(last_selection)->GetName());
- //Print(last_selection+1, 12, "%7.2f", rxn_lib.GetReaction(last_selection)->GetInflow());
- //Print(last_selection+1, 24, "%7.2f", rxn_lib.GetReaction(last_selection)->GetOutflow());
- }
-
- Update();
- break;
- case KEY_UP:
- if(mode==ENVIRONMENT_MODE_RESOURCE) {
- last_selection=res_selection;
- res_selection--;
- if(res_selection < 0) res_selection=population.GetResources().GetSize()-1;
-
- Print(last_selection+1, 1, res_lib.GetResource(last_selection)->GetName());
- Print(last_selection+1, 12, "%7.2f", res_lib.GetResource(last_selection)->GetInflow());
- Print(last_selection+1, 24, "%7.2f", res_lib.GetResource(last_selection)->GetOutflow());
- }
- else {
- last_selection=rxn_selection;
- rxn_selection--;
- if(rxn_selection < 0) rxn_selection=population.GetStats().GetReactions().GetSize()-1;
-
- Print(last_selection+1, 1, rxn_lib.GetReaction(last_selection)->GetName());
- //Print(last_selection+1, 12, "%7.2f", rxn_lib.GetReaction(last_selection)->GetInflow());
- //Print(last_selection+1, 24, "%7.2f", rxn_lib.GetReaction(last_selection)->GetOutflow());
- }
-
- Update();
- break;
- case '>':
- case '<':
- if(mode==ENVIRONMENT_MODE_RESOURCE)
- mode=ENVIRONMENT_MODE_REACTION;
- else
- mode=ENVIRONMENT_MODE_RESOURCE;
- Clear();
- Draw();
- break;
- }
+ case KEY_DOWN:
+ if(mode==ENVIRONMENT_MODE_RESOURCE ) {
+ last_selection=res_selection;
+ res_selection++;
+ res_selection%=m_world->GetPopulation().GetResources().GetSize();
+
+ Print(last_selection+1, 1, res_lib.GetResource(last_selection)->GetName());
+ Print(last_selection+1, 12, "%7.2f", res_lib.GetResource(last_selection)->GetInflow());
+ Print(last_selection+1, 24, "%7.2f", res_lib.GetResource(last_selection)->GetOutflow());
+ }
+ else {
+ last_selection=rxn_selection;
+ rxn_selection++;
+ rxn_selection%=m_world->GetStats().GetReactions().GetSize();
+
+ Print(last_selection+1, 1, rxn_lib.GetReaction(last_selection)->GetName());
+ //Print(last_selection+1, 12, "%7.2f", rxn_lib.GetReaction(last_selection)->GetInflow());
+ //Print(last_selection+1, 24, "%7.2f", rxn_lib.GetReaction(last_selection)->GetOutflow());
+ }
+
+ Update();
+ break;
+ case KEY_UP:
+ if(mode==ENVIRONMENT_MODE_RESOURCE) {
+ last_selection=res_selection;
+ res_selection--;
+ if(res_selection < 0) res_selection=m_world->GetPopulation().GetResources().GetSize()-1;
+
+ Print(last_selection+1, 1, res_lib.GetResource(last_selection)->GetName());
+ Print(last_selection+1, 12, "%7.2f", res_lib.GetResource(last_selection)->GetInflow());
+ Print(last_selection+1, 24, "%7.2f", res_lib.GetResource(last_selection)->GetOutflow());
+ }
+ else {
+ last_selection=rxn_selection;
+ rxn_selection--;
+ if(rxn_selection < 0) rxn_selection=m_world->GetStats().GetReactions().GetSize()-1;
+
+ Print(last_selection+1, 1, rxn_lib.GetReaction(last_selection)->GetName());
+ //Print(last_selection+1, 12, "%7.2f", rxn_lib.GetReaction(last_selection)->GetInflow());
+ //Print(last_selection+1, 24, "%7.2f", rxn_lib.GetReaction(last_selection)->GetOutflow());
+ }
+
+ Update();
+ break;
+ case '>':
+ case '<':
+ if(mode==ENVIRONMENT_MODE_RESOURCE)
+ mode=ENVIRONMENT_MODE_REACTION;
+ else
+ mode=ENVIRONMENT_MODE_RESOURCE;
+ Clear();
+ Draw();
+ break;
+ }
}
Modified: development/source/viewer/cEnvironmentScreen.h
===================================================================
--- development/source/viewer/cEnvironmentScreen.h 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/viewer/cEnvironmentScreen.h 2005-11-11 21:59:04 UTC (rev 394)
@@ -12,9 +12,11 @@
#include "cScreen.h"
#endif
+class cWorld;
+
class cEnvironmentScreen : public cScreen {
protected:
- cPopulation & population;
+ cWorld* m_world;
int mode;
int res_selection;
int rxn_selection;
@@ -23,13 +25,12 @@
static const int ENVIRONMENT_MODE_REACTION = 1;
public:
- cEnvironmentScreen(int y_size, int x_size, int y_start, int x_start,
- cViewInfo & in_info, cPopulation & in_pop) :
- cScreen(y_size, x_size, y_start, x_start, in_info),
- population(in_pop) { mode=ENVIRONMENT_MODE_RESOURCE; res_selection=rxn_selection=0; }
- //task_rows = Height() - 16;
- // task_cols = Width() / 20;
- //}
+ cEnvironmentScreen(cWorld* world, int y_size, int x_size, int y_start, int x_start, cViewInfo& in_info)
+ : cScreen(y_size, x_size, y_start, x_start, in_info), m_world(world)
+ {
+ mode=ENVIRONMENT_MODE_RESOURCE;
+ res_selection = rxn_selection = 0;
+ }
virtual ~cEnvironmentScreen() { ; }
// Virtual in base screen...
Modified: development/source/viewer/cStatsScreen.cc
===================================================================
--- development/source/viewer/cStatsScreen.cc 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/viewer/cStatsScreen.cc 2005-11-11 21:59:04 UTC (rev 394)
@@ -57,7 +57,7 @@
int task_num = task_offset;
- const cTaskLib & task_lib = population.GetEnvironment().GetTaskLib();
+ const cTaskLib & task_lib = m_world->GetEnvironment().GetTaskLib();
for (int col_id = 3; task_num < info.GetWorld().GetNumTasks(); col_id += 20) {
if (col_id + 16 > Width()) break;
for (int row_id = 15;
@@ -86,11 +86,11 @@
void cStatsScreen::Update()
{
- cGenotype * best_gen = population.GetGenebank().GetBestGenotype();
+ cGenotype * best_gen = m_world->GetPopulation().GetGenebank().GetBestGenotype();
SetBoldColor(COLOR_CYAN);
- cStats & stats = population.GetStats();
+ cStats& stats = m_world->GetStats();
Print(1, 13, "%7d", stats.GetNumBirths());
Print(2, 13, "%7d", stats.GetBreedTrue());
Modified: development/source/viewer/cStatsScreen.h
===================================================================
--- development/source/viewer/cStatsScreen.h 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/viewer/cStatsScreen.h 2005-11-11 21:59:04 UTC (rev 394)
@@ -11,20 +11,20 @@
#ifndef cScreen_h
#include "cScreen.h"
#endif
+class cWorld;
class cStatsScreen : public cScreen {
protected:
- cPopulation & population;
+ cWorld* m_world;
int task_offset;
int task_rows;
int task_cols;
public:
- cStatsScreen(int y_size, int x_size, int y_start, int x_start,
- cViewInfo & in_info, cPopulation & in_pop) :
- cScreen(y_size, x_size, y_start, x_start, in_info),
- population(in_pop), task_offset(0) {
- task_rows = Height() - 16;
- task_cols = Width() / 20;
+ cStatsScreen(cWorld* world, int y_size, int x_size, int y_start, int x_start, cViewInfo& in_info)
+ : m_world(world), cScreen(y_size, x_size, y_start, x_start, in_info), task_offset(0)
+ {
+ task_rows = Height() - 16;
+ task_cols = Width() / 20;
}
virtual ~cStatsScreen() { ; }
Modified: development/source/viewer/cView.cc
===================================================================
--- development/source/viewer/cView.cc 2005-11-11 19:47:15 UTC (rev 393)
+++ development/source/viewer/cView.cc 2005-11-11 21:59:04 UTC (rev 394)
@@ -41,11 +41,11 @@
Setup("Avida");
map_screen = new cMapScreen (0,0,3,0,info, world->GetPopulation());
- stats_screen = new cStatsScreen (0,0,3,0,info, world->GetPopulation());
+ stats_screen = new cStatsScreen (world, 0, 0, 3, 0, info);
hist_screen = new cHistScreen (0,0,3,0,info, world->GetPopulation());
options_screen = new cOptionsScreen (0,0,3,0,info);
zoom_screen = new cZoomScreen (0,0,3,0,info, world->GetPopulation());
- environment_screen = new cEnvironmentScreen (0,0,3,0,info, world->GetPopulation());
+ environment_screen = new cEnvironmentScreen (world, 0, 0, 3, 0, info);
info.SetActiveCell( &( world->GetPopulation().GetCell(0) ) );
}
@@ -70,7 +70,7 @@
StartProg();
- bar_screen = new cBarScreen(3, 0, 0, 0, info, in_name, info.GetPopulation());
+ bar_screen = new cBarScreen(&info.GetWorld(), 3, 0, 0, 0, info, in_name);
base_window = new cTextWindow(0,0,3,0);
bar_screen->Draw();
}
@@ -305,7 +305,7 @@
void cView::CloneSoup()
{
cString filename;
- filename.Set("clone.%d", info.GetPopulation().GetUpdate());
+ filename.Set("clone.%d", info.GetWorld().GetStats().GetUpdate());
ofstream fp(filename());
info.GetPopulation().SaveClone(fp);
cString message;
More information about the Avida-cvs
mailing list