NOTE: This method assumes that the organism is a fresh creation.
| 142 | |
| 143 | // NOTE: This method assumes that the organism is a fresh creation. |
| 144 | bool cTestCPU::ProcessGestation(cAvidaContext& ctx, cCPUTestInfo& test_info, int cur_depth) |
| 145 | { |
| 146 | assert(test_info.org_array[cur_depth] != NULL); |
| 147 | |
| 148 | cOrganism & organism = *( test_info.org_array[cur_depth] ); |
| 149 | |
| 150 | // Determine how long this organism should be tested for... |
| 151 | ConstInstructionSequencePtr seq; |
| 152 | seq.DynamicCastFrom(organism.UnitGenome().Representation()); |
| 153 | int time_allocated = m_world->GetConfig().TEST_CPU_TIME_MOD.Get() * seq->GetSize(); |
| 154 | time_allocated += m_res_cpu_cycle_offset; // If the resource offset has us starting at a different time, adjust @JEB |
| 155 | |
| 156 | // Prepare the inputs... |
| 157 | cur_input = 0; |
| 158 | cur_receive = 0; |
| 159 | |
| 160 | // Prepare the resources |
| 161 | InitResources(ctx, test_info.m_res_method, test_info.m_res, test_info.m_res_update, test_info.m_res_cpu_cycle_offset); |
| 162 | |
| 163 | |
| 164 | // This way of keeping track of time is only used to update resources... |
| 165 | int time_used = m_res_cpu_cycle_offset; // Note: the offset is zero by default if no resources being used @JEB |
| 166 | |
| 167 | organism.GetHardware().SetTrace(test_info.GetTracer()); |
| 168 | while (time_used < time_allocated && organism.GetPhenotype().GetNumDivides() == 0 && !organism.IsDead()) |
| 169 | { |
| 170 | time_used++; |
| 171 | |
| 172 | // @CAO Need to watch out for parasites. |
| 173 | |
| 174 | // Resources will be updated as if each update takes a number of cpu cycles equal to the average time slice |
| 175 | UpdateResources(ctx, time_used); |
| 176 | |
| 177 | organism.GetHardware().SingleProcess(ctx); |
| 178 | } |
| 179 | |
| 180 | organism.GetHardware().SetTrace(HardwareTracerPtr(NULL)); |
| 181 | |
| 182 | // Print out some final info in trace... |
| 183 | if (test_info.GetTracer()) test_info.GetTracer()->TraceTestCPU(time_used, time_allocated, organism); |
| 184 | |
| 185 | // For now, always return true. |
| 186 | return true; |
| 187 | } |
| 188 | |
| 189 | |
| 190 | bool cTestCPU::TestGenome(cAvidaContext& ctx, cCPUTestInfo& test_info, const Genome& genome) |
nothing calls this directly
no test coverage detected