aima.core.probability.mdp.impl.LookupPolicy Maven / Gradle / Ivy
package aima.core.probability.mdp.impl;
import java.util.HashMap;
import java.util.Map;
import aima.core.agent.Action;
import aima.core.probability.mdp.Policy;
/**
* Default implementation of the Policy interface using an underlying Map to
* look up an action associated with a state.
*
* @param
* the state type.
* @param
* the action type.
*
* @author Ciaran O'Reilly
*/
public class LookupPolicy implements Policy {
private Map policy = new HashMap();
public LookupPolicy(Map aPolicy) {
policy.putAll(aPolicy);
}
//
// START-Policy
@Override
public A action(S s) {
return policy.get(s);
}
// END-Policy
//
}