All Downloads are FREE. Search and download functionalities are using the official Maven repository.

aima.core.environment.map.MapEnvironmentState Maven / Gradle / Ivy

Go to download

AIMA-Java Core Algorithms from the book Artificial Intelligence a Modern Approach 3rd Ed.

The newest version!
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 - 2024 Weber Informatics LLC | Privacy Policy