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

Method Inst_SenseTarget

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

Sense if the organism is on a target -- put 1 in reg is so, 0 otherwise

Source from the content-addressed store, hash-verified

8521
8522// Sense if the organism is on a target -- put 1 in reg is so, 0 otherwise
8523bool cHardwareCPU::Inst_SenseTarget(cAvidaContext&)
8524{
8525 int reg_to_set = FindModifiedRegister(REG_CX);
8526 int cellid = m_organism->GetCellID();
8527
8528 if (cellid == -1) {
8529 return false;
8530 }
8531
8532 int cell_data = m_world->GetPopulation().GetCell(cellid).GetCellData();
8533 int val = 0;
8534
8535 if (cell_data > 0) {
8536 val = 1;
8537 }
8538
8539 GetRegister(reg_to_set) = val;
8540
8541 return true;
8542} //End Inst_SenseTarget()
8543
8544
8545// Sense if the cell faced is a target -- put 1 in reg is so, 0 otherwise

Callers

nothing calls this directly

Calls 3

GetCellIDMethod · 0.45
GetCellDataMethod · 0.45
GetCellMethod · 0.45

Tested by

no test coverage detected