1 ////////////////////////////////////////////////////////////////////////////// 2 // Copyright (C) 1993 - 2001 California Institute of Technology // 3 // // 4 // Read the COPYING and README files, or contact 'avida@alife.org', // 5 // before continuing. SOME RESTRICTIONS MAY APPLY TO USE OF THIS FILE. // 6 ////////////////////////////////////////////////////////////////////////////// 7 8 #ifndef cViewInfo_h 9 #define cViewInfo_h 10 11 #include "avida/Avida.h" 12 13 #include "cBioGroup.h" 14 #include "cInstSet.h" 15 #include "cMerit.h" 16 #include "cTextWindow.h" 17 #include "cView_Base.h" 18 #include "cWorld.h" 19 20 class cEnvironment; 21 class cPopulation; 22 class cPopulationCell; 23 class cOrganism; 24 25 #define NUM_SYMBOLS 12 26 #define SYMBOL_THRESHOLD 10 27 28 #define PAUSE_OFF 0 29 #define PAUSE_ON 1 30 #define PAUSE_ADVANCE_STEP 2 31 #define PAUSE_ADVANCE_UPDATE 3 32 #define PAUSE_ADVANCE_GESTATION 4 33 34 35 #define MAP_BASIC 0 36 #define MAP_BREED_TRUE 1 37 #define MAP_PARASITE 2 38 #define MAP_FORAGER 3 39 #define MAP_AVATAR 4 40 #define MAP_TERRITORIES 5 41 #define MAP_MUTATIONS 6 42 #define MAP_THREAD 7 43 #define MAP_INJECT 8 44 #define MAP_LINEAGE 9 45 #define NUM_MAPS 10 46 47 // Other map modes currently inactive... 48 #define MAP_COMBO 11 49 #define MAP_RESOURCE 12 50 #define MAP_AGE 13 51 #define NUM_MAP_MODES 14 52 53 struct sGenotypeViewInfo 54 { 55 char symbol; 56 sGenotypeViewInfosGenotypeViewInfo57 sGenotypeViewInfo() : symbol(0) { ; } 58 }; 59 60 class cViewInfo { 61 private: 62 cWorld* m_world; 63 cView_Base* m_view; 64 cPopulationCell * active_cell; 65 66 int pause_level; 67 int thread_lock; 68 int step_organism_id; 69 int map_mode; 70 71 // Instruction Libraries. 72 cInstSet const * saved_inst_set; 73 74 // Symbol information 75 cBioGroup * genotype_chart[NUM_SYMBOLS]; 76 char symbol_chart[NUM_SYMBOLS]; 77 78 tArray<char> map; 79 tArray<char> color_map; 80 81 inline bool InGenChart(cBioGroup * in_gen); 82 void AddGenChart(cBioGroup * in_gen); 83 84 public: 85 cViewInfo(cWorld* world, cView_Base * view); ~cViewInfo()86 ~cViewInfo() { ; } 87 88 void UpdateSymbols(); 89 void SetupSymbolMaps(int map_mode, bool use_color); GetMap()90 tArray<char> & GetMap() { return map; } GetColorMap()91 tArray<char> & GetColorMap() { return color_map; } MapSymbol(int pos)92 char & MapSymbol(int pos) { return map[pos]; } ColorSymbol(int pos)93 char & ColorSymbol(int pos) { return color_map[pos]; } GetMapMode()94 int GetMapMode() { return map_mode; } IncMapMode()95 void IncMapMode() { ++map_mode%=NUM_MAPS; } 96 void DecMapMode(); 97 98 void EngageStepMode(); 99 void DisEngageStepMode(); 100 GetPopulation()101 cPopulation & GetPopulation() { return m_world->GetPopulation(); } GetConfig()102 cAvidaConfig& GetConfig() { return m_world->GetConfig(); } GetRandom()103 cRandom& GetRandom() { return m_world->GetRandom(); } GetWorld()104 cWorld& GetWorld() { return *m_world; } GetView()105 cView_Base& GetView() { return *m_view; } 106 GetNumSymbols()107 int GetNumSymbols() { return NUM_SYMBOLS; } GetGenotype(int index)108 cBioGroup * GetGenotype(int index) { return genotype_chart[index]; } 109 GetActiveCell()110 cPopulationCell * GetActiveCell() { return active_cell; } 111 112 cBioGroup * GetActiveGenotype(); 113 cString GetActiveName(); 114 115 int GetActiveID(); 116 int GetActiveGenotypeID(); 117 SetActiveCell(cPopulationCell * in_cell)118 void SetActiveCell(cPopulationCell * in_cell) { active_cell = in_cell; } 119 GetPauseLevel()120 int GetPauseLevel() { return pause_level; } GetThreadLock()121 int GetThreadLock() { return thread_lock; } GetStepOrganism()122 int GetStepOrganism() { return step_organism_id; } 123 SetPauseLevel(int in_level)124 void SetPauseLevel(int in_level) { pause_level = in_level; } SetThreadLock(int in_lock)125 void SetThreadLock(int in_lock) { thread_lock = in_lock; } SetStepOrganism(int in_id)126 void SetStepOrganism(int in_id) { step_organism_id = in_id; } 127 128 private: 129 sGenotypeViewInfo* getViewInfo(cBioGroup* bg); 130 }; 131 132 DecMapMode()133inline void cViewInfo::DecMapMode() 134 { 135 map_mode+=NUM_MAPS; 136 --map_mode %= NUM_MAPS; 137 } 138 InGenChart(cBioGroup * in_gen)139inline bool cViewInfo::InGenChart(cBioGroup * in_gen) 140 { 141 for (int i = 0; i < NUM_SYMBOLS; i++) { 142 if (genotype_chart[i] == in_gen) return true; 143 } 144 return false; 145 } 146 147 #endif 148