public void moveObject(Agent a, String direction) { XYLocation presentLocation = (XYLocation) a.getAttribute(LOCATION); XYLocation locationToMoveTo = presentLocation.locationAt(direction); if (!(isBlocked(locationToMoveTo))) { moveObjectToAbsoluteLocation(a, locationToMoveTo); } }
public ArrayList getObjectsNear(Agent agent, int radius) { ArrayList retval = new ArrayList(); XYLocation agentLocation = (XYLocation) agent.getAttribute(LOCATION); ArrayList all = getAllObjects(); foreach (ObjectWithDynamicAttributes a in all) { if (!(a.Equals(agent))) { XYLocation otherAgentLocation = (XYLocation) a .getAttribute(LOCATION); if (withinRadius(radius, agentLocation, otherAgentLocation)) { retval.Add(a); } } } return retval; }
public abstract Percept getPerceptSeenBy(Agent anAgent);
public abstract void executeAction(Agent a, String act);
public void addAgent(Agent a) { if (!(alreadyContains(a))) { agents.Add(a); } }
public void addAgent(Agent a, string attributeName, Object attributeValue) { if (!(alreadyContains(a))) { a.setAttribute(attributeName, attributeValue); agents.Add(a); } }
public bool alreadyContains(Agent anAgent) { bool retval = false; foreach (Agent agent in agents) { //if (agent.equals(anAgent)) if (agent.Equals(anAgent)) { retval = true; } } return retval; }
public void moveObjectToAbsoluteLocation(Agent a, XYLocation loc) { a.setAttribute(LOCATION, loc); }
public void addAgent(Agent a, XYLocation loc) { base.addAgent(a, LOCATION, loc); }
public override Percept getPerceptSeenBy(Agent anAgent) { return new Percept(); }
public override void executeAction(Agent a, String Action) { }