This function processes the very next command in the genome, and is made to be as optimized as possible. This is the heart of avida.
| 203 | // This function processes the very next command in the genome, and is made |
| 204 | // to be as optimized as possible. This is the heart of avida. |
| 205 | bool cHardwareTransSMT::SingleProcess(cAvidaContext& ctx, bool speculative) |
| 206 | { |
| 207 | if (speculative) return false; |
| 208 | |
| 209 | // Mark this organism as running... |
| 210 | m_organism->SetRunning(true); |
| 211 | |
| 212 | cPhenotype& phenotype = m_organism->GetPhenotype(); |
| 213 | phenotype.IncTimeUsed(); |
| 214 | |
| 215 | const int num_inst_exec = (m_world->GetConfig().THREAD_SLICING_METHOD.Get() == 1) ? m_threads.GetSize() : 1; |
| 216 | |
| 217 | for (int i = 0; i < num_inst_exec; i++) { |
| 218 | double parasiteVirulence; |
| 219 | // Setup the hardware for the next instruction to be executed. |
| 220 | m_cur_thread++; |
| 221 | //Ignore incremeting the thread, set it to be the parasite, unless we draw something lower thean 0.8 |
| 222 | //Then set it to the parasite |
| 223 | if (m_threads.GetSize() > 1 && m_threads[1].owner->UnitSource().transmission_type == Systematics::HORIZONTAL) |
| 224 | { |
| 225 | Apto::SmartPtr<cParasite, Apto::InternalRCObject> parasite; |
| 226 | parasite.DynamicCastFrom(m_threads[1].owner); |
| 227 | //Virulence can be from parasite or host |
| 228 | if (m_world->GetConfig().VIRULENCE_SOURCE.Get() == 2) { |
| 229 | //Host controls threads donated to parasite @AEJ |
| 230 | parasiteVirulence = m_organism->GetParaDonate(); |
| 231 | } else { |
| 232 | //Parasite inherited virulence |
| 233 | parasiteVirulence = parasite->GetVirulence(); |
| 234 | } |
| 235 | } |
| 236 | else |
| 237 | { |
| 238 | parasiteVirulence = m_world->GetConfig().PARASITE_VIRULENCE.Get(); |
| 239 | } |
| 240 | |
| 241 | //Parasites steal CPU cycles only if threads execute one at a time. |
| 242 | if (parasiteVirulence != -1 && m_world->GetConfig().THREAD_SLICING_METHOD.Get() == 0) { |
| 243 | |
| 244 | double probThread = ctx.GetRandom().GetDouble(); |
| 245 | |
| 246 | //Default to the first thread |
| 247 | m_cur_thread = 0; |
| 248 | if (probThread < parasiteVirulence) |
| 249 | { |
| 250 | //LZ- this only works for MAX_THREADS 2 right now |
| 251 | m_cur_thread = 1; |
| 252 | } |
| 253 | }; |
| 254 | |
| 255 | //If we don't have a parasite, this will fix it. |
| 256 | if (m_cur_thread >= m_threads.GetSize()) |
| 257 | { |
| 258 | m_cur_thread = 0; |
| 259 | } |
| 260 | |
| 261 | if(m_threads[m_cur_thread].skipExecution) |
| 262 | m_cur_thread++; |
nothing calls this directly
no test coverage detected