MCPcopy Create free account
hub / github.com/devosoft/avida / Inst_SenseTargetFaced

Method Inst_SenseTargetFaced

avida-core/source/cpu/cHardwareCPU.cc:8546–8569  ·  view source on GitHub ↗

Sense if the cell faced is a target -- put 1 in reg is so, 0 otherwise

Source from the content-addressed store, hash-verified

8544
8545// Sense if the cell faced is a target -- put 1 in reg is so, 0 otherwise
8546bool cHardwareCPU::Inst_SenseTargetFaced(cAvidaContext&)
8547{
8548 int reg_to_set = FindModifiedRegister(REG_CX);
8549
8550 cPopulation& pop = m_world->GetPopulation();
8551 int cellid = m_organism->GetCellID();
8552
8553 if (cellid == -1) {
8554 return false;
8555 }
8556
8557 cPopulationCell& mycell = pop.GetCell(cellid);
8558
8559 int cell_data = mycell.GetCellFaced().GetCellData(); //absolute id of faced cell
8560 int val = 0;
8561
8562 if (cell_data > 0) {
8563 val = 1;
8564 }
8565
8566 GetRegister(reg_to_set) = val;
8567
8568 return true;
8569} //End Inst_SenseTargetFaced()
8570
8571
8572// DoSensePheromone -- modified version of DoSense to only sense from

Callers

nothing calls this directly

Calls 4

GetCellFacedMethod · 0.80
GetCellIDMethod · 0.45
GetCellMethod · 0.45
GetCellDataMethod · 0.45

Tested by

no test coverage detected