AIMA.Core.Environment.XYEnv.XYEnvironmentState.getObjectsNear C# (CSharp) Method

getObjectsNear() public method

public getObjectsNear ( Agent agent, int radius ) : HashSet
agent Agent
radius int
return HashSet
        public HashSet<EnvironmentObject> getObjectsNear(Agent agent, int radius)
        {
            HashSet<EnvironmentObject> objsNear = new LinkedHashSet<EnvironmentObject>();

            XYLocation agentLocation = getCurrentLocationFor(agent);
            foreach (XYLocation loc in objsAtLocation.keySet())
            {
                if (withinRadius(radius, agentLocation, loc))
                {
                    objsNear.AddRange(objsAtLocation.get(loc));
                }
            }
            // Ensure the 'agent' is not included in the Set of
            // objects near
            objsNear.remove(agent);

            return objsNear;
        }

Usage Example

Beispiel #1
0
 public HashSet <EnvironmentObject> getObjectsNear(Agent agent, int radius)
 {
     return(envState.getObjectsNear(agent, radius));
 }