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

getCurrentLocationFor() public method

public getCurrentLocationFor ( EnvironmentObject eo ) : XYLocation
eo EnvironmentObject
return AIMA.Core.Util.DataStructure.XYLocation
        public XYLocation getCurrentLocationFor(EnvironmentObject eo)
        {
            foreach (XYLocation loc in objsAtLocation.keySet())
            {
                if (objsAtLocation.get(loc).contains(eo))
                {
                    return loc;
                }
            }
            return null;
        }

Usage Example

Beispiel #1
0
        public void moveObject(EnvironmentObject eo, XYLocation.Direction direction)
        {
            XYLocation presentLocation = envState.getCurrentLocationFor(eo);

            if (null != presentLocation)
            {
                XYLocation locationToMoveTo = presentLocation.locationAt(direction);
                if (!(isBlocked(locationToMoveTo)))
                {
                    moveObjectToAbsoluteLocation(eo, locationToMoveTo);
                }
            }
        }