This command should move the organism to the neighbor cell that is a target. If more than one target exists, it moves towards the last-seen one. If no target exists, the organism moves forward in its original facing. This version ignores the neighbors beind and to the side of the organism
| 8999 | // facing. This version ignores the neighbors beind and to the side of |
| 9000 | // the organism |
| 9001 | bool cHardwareCPU::Inst_MoveTargetForward3(cAvidaContext& ctx) |
| 9002 | { |
| 9003 | int num_rotations = 0; |
| 9004 | |
| 9005 | cPopulation& pop = m_world->GetPopulation(); |
| 9006 | int cellid = m_organism->GetCellID(); |
| 9007 | |
| 9008 | if (cellid == -1) { |
| 9009 | return false; |
| 9010 | } |
| 9011 | |
| 9012 | cPopulationCell& mycell = pop.GetCell(cellid); |
| 9013 | |
| 9014 | int cell_data; |
| 9015 | |
| 9016 | cPopulationCell faced = mycell.GetCellFaced(); |
| 9017 | |
| 9018 | // Find if any neighbor is a target |
| 9019 | for (int i = 0; i < mycell.ConnectionList().GetSize(); i++) { |
| 9020 | |
| 9021 | // Skip the cells behind |
| 9022 | if (i==2 || i == 3 || i == 4 || i == 5 || i == 6) { |
| 9023 | mycell.ConnectionList().CircNext(); |
| 9024 | continue; |
| 9025 | } |
| 9026 | |
| 9027 | cell_data = mycell.GetCellFaced().GetCellData(); |
| 9028 | |
| 9029 | if (cell_data > 0) { |
| 9030 | num_rotations = i; |
| 9031 | } |
| 9032 | |
| 9033 | mycell.ConnectionList().CircNext(); |
| 9034 | } |
| 9035 | |
| 9036 | // Rotate until we face the neighbor with a target. |
| 9037 | // If there was no winner, just move forward. |
| 9038 | for (int i = 0; i < num_rotations; i++) { |
| 9039 | mycell.ConnectionList().CircNext(); |
| 9040 | } |
| 9041 | |
| 9042 | m_organism->Move(ctx); |
| 9043 | |
| 9044 | return true; |
| 9045 | } // End Inst_MoveTargetForward3() |
| 9046 | |
| 9047 | |
| 9048 | bool cHardwareCPU::Inst_SuperMove(cAvidaContext& ctx) |
nothing calls this directly
no test coverage detected