aima.core.probability.mdp.impl.LookupPolicy 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.
The newest version!
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
//
}