| 3361 | } |
| 3362 | |
| 3363 | bool cHardwareCPU::Inst_Repro(cAvidaContext& ctx) |
| 3364 | { |
| 3365 | // check if repro can replace an existing organism |
| 3366 | if (m_world->GetConfig().REPRO_METHOD.Get() == 0 && m_organism->IsNeighborCellOccupied()) { |
| 3367 | return false; |
| 3368 | } |
| 3369 | |
| 3370 | if (m_organism->GetPhenotype().GetCurBonus() < m_world->GetConfig().REQUIRED_BONUS.Get()) { |
| 3371 | return false; |
| 3372 | } |
| 3373 | |
| 3374 | // Setup child |
| 3375 | m_organism->OffspringGenome() = m_organism->GetGenome(); |
| 3376 | InstructionSequencePtr offspring_seq; |
| 3377 | offspring_seq.DynamicCastFrom(m_organism->OffspringGenome().Representation()); |
| 3378 | |
| 3379 | ConstInstructionSequencePtr org_seq; |
| 3380 | org_seq.DynamicCastFrom(m_organism->GetGenome().Representation()); |
| 3381 | |
| 3382 | // Do transposon movement and copying before other mutations |
| 3383 | Divide_DoTransposons(ctx); |
| 3384 | |
| 3385 | // Perform Copy Mutations... |
| 3386 | if (m_organism->GetCopyMutProb() > 0) { // Skip this if no mutations.... |
| 3387 | for (int i = 0; i < offspring_seq->GetSize(); i++) { |
| 3388 | //Need to check no_mut_insts for head to head kaboom experiments |
| 3389 | bool in_list = false; |
| 3390 | char test_inst = (*offspring_seq)[i].GetSymbol()[0]; |
| 3391 | cString no_mut_list = m_world->GetConfig().NO_MUT_INSTS.Get(); |
| 3392 | for (int j = 0; j < (int)strlen(no_mut_list); j++) { |
| 3393 | if ((char) no_mut_list[j] == test_inst) in_list = true; |
| 3394 | } |
| 3395 | if (m_organism->TestCopyMut(ctx) && !(in_list)) { |
| 3396 | (*offspring_seq)[i] = m_inst_set->GetRandomInst(ctx); |
| 3397 | } |
| 3398 | } |
| 3399 | } |
| 3400 | |
| 3401 | //Perform divide mutations... |
| 3402 | Divide_DoMutations(ctx); |
| 3403 | |
| 3404 | // Check viability |
| 3405 | bool viable = Divide_CheckViable(ctx, org_seq->GetSize(), offspring_seq->GetSize(), 1); |
| 3406 | if (!viable) { return false; } |
| 3407 | |
| 3408 | // Many tests will require us to run the offspring through a test CPU; |
| 3409 | // this is, for example, to see if mutations need to be reverted or if |
| 3410 | // lineages need to be updated. |
| 3411 | Divide_TestFitnessMeasures(ctx); |
| 3412 | |
| 3413 | if (m_world->GetConfig().DIVIDE_METHOD.Get() != DIVIDE_METHOD_OFFSPRING) { |
| 3414 | // reset first time instruction costs |
| 3415 | for (int i = 0; i < m_inst_ft_cost.GetSize(); i++) { |
| 3416 | m_inst_ft_cost[i] = m_inst_set->GetFTCost(Instruction(i)); |
| 3417 | } |
| 3418 | } |
| 3419 | |
| 3420 | if (m_world->GetConfig().DIVIDE_METHOD.Get() == DIVIDE_METHOD_SPLIT) m_advance_ip = false; |
nothing calls this directly
no test coverage detected