Search in sources :

Example 6 with DynamicPercept

use of aima.core.agent.impl.DynamicPercept 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 7 with DynamicPercept

use of aima.core.agent.impl.DynamicPercept 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 8 with DynamicPercept

use of aima.core.agent.impl.DynamicPercept in project aima-java by aimacode.

the class SimpleMapAgent method updateState.

//
// PROTECTED METHODS
//
@Override
protected void updateState(Percept p) {
    DynamicPercept dp = (DynamicPercept) p;
    state.setAttribute(DynAttributeNames.AGENT_LOCATION, dp.getAttribute(DynAttributeNames.PERCEPT_IN));
}
Also used : DynamicPercept(aima.core.agent.impl.DynamicPercept)

Example 9 with DynamicPercept

use of aima.core.agent.impl.DynamicPercept in project aima-java by aimacode.

the class DynamicPerceptTest method testEquals.

@Test
public void testEquals() {
    DynamicPercept p1 = new DynamicPercept();
    DynamicPercept p2 = new DynamicPercept();
    Assert.assertEquals(p1, p2);
    p1 = new DynamicPercept("key1", "value1");
    Assert.assertNotSame(p1, p2);
    p2 = new DynamicPercept("key1", "value1");
    Assert.assertEquals(p1, p2);
}
Also used : DynamicPercept(aima.core.agent.impl.DynamicPercept) Test(org.junit.Test)

Example 10 with DynamicPercept

use of aima.core.agent.impl.DynamicPercept 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

DynamicPercept (aima.core.agent.impl.DynamicPercept)12 Test (org.junit.Test)9 EQUALCondition (aima.core.agent.impl.aprog.simplerule.EQUALCondition)4 Rule (aima.core.agent.impl.aprog.simplerule.Rule)4 Percept (aima.core.agent.Percept)3 ArrayList (java.util.ArrayList)3 Action (aima.core.agent.Action)1 DynamicAction (aima.core.agent.impl.DynamicAction)1 NoOpAction (aima.core.agent.impl.NoOpAction)1 TableDrivenAgentProgram (aima.core.agent.impl.aprog.TableDrivenAgentProgram)1 ANDCondition (aima.core.agent.impl.aprog.simplerule.ANDCondition)1 NOTCondition (aima.core.agent.impl.aprog.simplerule.NOTCondition)1 ORCondition (aima.core.agent.impl.aprog.simplerule.ORCondition)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