
aima.core.environment.map.MapEnvironmentState Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aima-core Show documentation
Show all versions of aima-core Show documentation
AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.
package aima.core.environment.map;
import java.util.HashMap;
import aima.core.agent.Agent;
import aima.core.agent.EnvironmentState;
import aima.core.util.datastructure.Pair;
/**
* @author Ciaran O'Reilly
*
*/
public class MapEnvironmentState implements EnvironmentState {
private java.util.Map> agentLocationAndTravelDistance = new HashMap>();
public MapEnvironmentState() {
}
public String getAgentLocation(Agent a) {
Pair locAndTDistance = agentLocationAndTravelDistance
.get(a);
if (null == locAndTDistance) {
return null;
}
return locAndTDistance.getFirst();
}
public Double getAgentTravelDistance(Agent a) {
Pair locAndTDistance = agentLocationAndTravelDistance
.get(a);
if (null == locAndTDistance) {
return null;
}
return locAndTDistance.getSecond();
}
public void setAgentLocationAndTravelDistance(Agent a, String location,
Double travelDistance) {
agentLocationAndTravelDistance.put(a, new Pair(
location, travelDistance));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy