public double[] calculatePredatorSensors(Predator predator)
{
// Agents are sensed by predators, plus they have 1 velocity sensor
double[] sensors = new double[SENSORS_PER_OBJECT_TYPE + 1];
sensors[0] = predator.Velocity / predator.MaxVelocity;
// For every plant
foreach (var agent in Agents)
{
// if the plant isn't available for eating then we do not activate the sensors
if (agent.HidingMode == predator.AttackType)
continue;
// Calculate the distance to the pred from the predator
int[] distanceAndOrientation = _sensorDictionary.getDistanceAndOrientation((int)predator.X, (int)predator.Y, (int)agent.X, (int)agent.Y);
int dist = distanceAndOrientation[0];
int pos = distanceAndOrientation[1];
// If it's too far away for the predator to see
if (dist > AgentHorizon)
continue;
// Identify the appropriate sensor
int sIdx = getSensorIndex(predator, 1, pos);
if (sIdx == -1)
continue;
// Add the signal strength for this plant to the sensor
sensors[sIdx] += 1.0 - dist / AgentHorizon;
}
return sensors;
}