This method will handle the actual execution of an instruction within a single process, once that function has been finalized.
| 1060 | // This method will handle the actual execution of an instruction |
| 1061 | // within a single process, once that function has been finalized. |
| 1062 | bool cHardwareCPU::SingleProcess_ExecuteInst(cAvidaContext& ctx, const Instruction& cur_inst) |
| 1063 | { |
| 1064 | // Copy Instruction locally to handle stochastic effects |
| 1065 | Instruction actual_inst = cur_inst; |
| 1066 | |
| 1067 | // Get a pointer to the corresponding method... |
| 1068 | int inst_idx = m_inst_set->GetLibFunctionIndex(actual_inst); |
| 1069 | |
| 1070 | // instruction execution count incremented |
| 1071 | m_organism->GetPhenotype().IncCurInstCount(actual_inst.GetOp()); |
| 1072 | |
| 1073 | // And execute it. |
| 1074 | const bool exec_success = (this->*(m_functions[inst_idx]))(ctx); |
| 1075 | |
| 1076 | // NOTE: Organism may be dead now if instruction executed killed it (such as some divides, "die", or "explode") |
| 1077 | |
| 1078 | // Add in a cycle cost for switching which task is performed |
| 1079 | if (m_world->GetConfig().TASK_SWITCH_PENALTY_TYPE.Get()) { |
| 1080 | if (m_organism->GetPhenotype().GetNumNewUniqueReactions()) { |
| 1081 | int cost = m_organism->GetPhenotype().GetNumNewUniqueReactions() * m_world->GetConfig().TASK_SWITCH_PENALTY.Get(); |
| 1082 | IncrementTaskSwitchingCost(cost); |
| 1083 | |
| 1084 | m_organism->GetPhenotype().ResetNumNewUniqueReactions(); |
| 1085 | } |
| 1086 | } |
| 1087 | |
| 1088 | // Decrement if the instruction was not executed successfully. |
| 1089 | if (exec_success == false) { |
| 1090 | m_organism->GetPhenotype().DecCurInstCount(actual_inst.GetOp()); |
| 1091 | } |
| 1092 | |
| 1093 | return exec_success; |
| 1094 | } |
| 1095 | |
| 1096 | |
| 1097 | void cHardwareCPU::ProcessBonusInst(cAvidaContext& ctx, const Instruction& inst) |
nothing calls this directly
no test coverage detected