Search in sources :

Example 1 with Percept

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);
}
Also used : DynamicPercept(aima.core.agent.impl.DynamicPercept) Percept(aima.core.agent.Percept) DynamicPercept(aima.core.agent.impl.DynamicPercept) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with Percept

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));
}
Also used : MockAgent(aima.test.core.unit.agent.impl.MockAgent) NoOpAction(aima.core.agent.impl.NoOpAction) Action(aima.core.agent.Action) DynamicAction(aima.core.agent.impl.DynamicAction) DynamicPercept(aima.core.agent.impl.DynamicPercept) Percept(aima.core.agent.Percept) DynamicPercept(aima.core.agent.impl.DynamicPercept) HashMap(java.util.HashMap) TableDrivenAgentProgram(aima.core.agent.impl.aprog.TableDrivenAgentProgram) ArrayList(java.util.ArrayList) List(java.util.List) Before(org.junit.Before)

Example 3 with Percept

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();
}
Also used : Agent(aima.core.agent.Agent) Action(aima.core.agent.Action) Percept(aima.core.agent.Percept)

Example 4 with Percept

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());
}
Also used : DynamicPercept(aima.core.agent.impl.DynamicPercept) Percept(aima.core.agent.Percept) DynamicPercept(aima.core.agent.impl.DynamicPercept) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Aggregations

Percept (aima.core.agent.Percept)4 DynamicPercept (aima.core.agent.impl.DynamicPercept)3 ArrayList (java.util.ArrayList)3 Action (aima.core.agent.Action)2 Test (org.junit.Test)2 Agent (aima.core.agent.Agent)1 DynamicAction (aima.core.agent.impl.DynamicAction)1 NoOpAction (aima.core.agent.impl.NoOpAction)1 TableDrivenAgentProgram (aima.core.agent.impl.aprog.TableDrivenAgentProgram)1 MockAgent (aima.test.core.unit.agent.impl.MockAgent)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Before (org.junit.Before)1