use of aima.core.agent.Percept in project aima-java by aimacode.
the class PerceptSequenceTest method testEquals.
@Test
public void testEquals() {
List<Percept> ps1 = new ArrayList<Percept>();
List<Percept> ps2 = new ArrayList<Percept>();
Assert.assertEquals(ps1, ps2);
ps1.add(new DynamicPercept("key1", "value1"));
Assert.assertNotSame(ps1, ps2);
ps2.add(new DynamicPercept("key1", "value1"));
Assert.assertEquals(ps1, ps2);
}
use of aima.core.agent.Percept in project aima-java by aimacode.
the class TableDrivenAgentProgramTest method setUp.
@Before
public void setUp() {
Map<List<Percept>, Action> perceptSequenceActions = new HashMap<List<Percept>, Action>();
perceptSequenceActions.put(createPerceptSequence(new DynamicPercept("key1", "value1")), ACTION_1);
perceptSequenceActions.put(createPerceptSequence(new DynamicPercept("key1", "value1"), new DynamicPercept("key1", "value2")), ACTION_2);
perceptSequenceActions.put(createPerceptSequence(new DynamicPercept("key1", "value1"), new DynamicPercept("key1", "value2"), new DynamicPercept("key1", "value3")), ACTION_3);
agent = new MockAgent(new TableDrivenAgentProgram(perceptSequenceActions));
}
use of aima.core.agent.Percept in project aima-java by aimacode.
the class AbstractEnvironment method step.
/**
* Central template method for controlling agent simulation. The concrete
* behavior is determined by the primitive operations
* {@link #getPerceptSeenBy(Agent)}, {@link #executeAction(Agent, Action)},
* and {@link #createExogenousChange()}.
*/
public void step() {
for (Agent agent : agents) {
if (agent.isAlive()) {
Percept percept = getPerceptSeenBy(agent);
Action anAction = agent.execute(percept);
executeAction(agent, anAction);
notifyEnvironmentViews(agent, percept, anAction);
}
}
createExogenousChange();
}
use of aima.core.agent.Percept in project aima-java by aimacode.
the class PerceptSequenceTest method testToString.
@Test
public void testToString() {
List<Percept> ps = new ArrayList<Percept>();
ps.add(new DynamicPercept("key1", "value1"));
Assert.assertEquals("[Percept[key1==value1]]", ps.toString());
ps.add(new DynamicPercept("key1", "value1", "key2", "value2"));
Assert.assertEquals("[Percept[key1==value1], Percept[key1==value1, key2==value2]]", ps.toString());
}
Aggregations