Search in sources :

Example 1 with MockAgent

use of aima.test.core.unit.agent.impl.MockAgent 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 2 with MockAgent

use of aima.test.core.unit.agent.impl.MockAgent in project aima-java by aimacode.

the class XYEnvironmentTest method testAddObjectTwice.

@Test
public void testAddObjectTwice() {
    Assert.assertEquals(1, env.getAgents().size());
    XYLocation loc = new XYLocation(5, 5);
    AbstractAgent b = new MockAgent();
    env.addObjectToLocation(b, loc);
    Assert.assertEquals(2, env.getAgents().size());
    Assert.assertEquals(loc, env.getCurrentLocationFor(b));
}
Also used : MockAgent(aima.test.core.unit.agent.impl.MockAgent) XYLocation(aima.core.util.datastructure.XYLocation) AbstractAgent(aima.core.agent.impl.AbstractAgent) Test(org.junit.Test)

Example 3 with MockAgent

use of aima.test.core.unit.agent.impl.MockAgent in project aima-java by aimacode.

the class XYEnvironmentTest method testGetObjectsNear.

@Test
public void testGetObjectsNear() {
    XYLocation loc = new XYLocation(5, 5);
    env.moveObjectToAbsoluteLocation(a, loc);
    AbstractAgent b = new MockAgent();
    AbstractAgent c = new MockAgent();
    Wall w1 = new Wall();
    env.addObjectToLocation(b, new XYLocation(7, 4));
    env.addObjectToLocation(c, new XYLocation(5, 7));
    env.addObjectToLocation(w1, new XYLocation(3, 10));
    // at this point agent A should be able to see B and C but not the wall
    // with a "vision radius" of 3
    Set<EnvironmentObject> visibleToA = env.getObjectsNear(a, 3);
    Assert.assertEquals(2, visibleToA.size());
    // agent B should be able to see A only
    Set<EnvironmentObject> visibleToB = env.getObjectsNear(b, 3);
    Assert.assertEquals(1, visibleToB.size());
    // move B South
    env.moveObject(b, XYLocation.Direction.South);
    // at this point both a and c should be visible to b
    visibleToB = env.getObjectsNear(b, 3);
    Assert.assertEquals(2, visibleToB.size());
    // move c near the wall
    env.moveObjectToAbsoluteLocation(c, new XYLocation(3, 11));
    // only the wall should be visible
    Set<EnvironmentObject> visibleToC = env.getObjectsNear(c, 3);
    Assert.assertEquals(1, visibleToC.size());
}
Also used : MockAgent(aima.test.core.unit.agent.impl.MockAgent) EnvironmentObject(aima.core.agent.EnvironmentObject) Wall(aima.core.environment.xyenv.Wall) XYLocation(aima.core.util.datastructure.XYLocation) AbstractAgent(aima.core.agent.impl.AbstractAgent) Test(org.junit.Test)

Example 4 with MockAgent

use of aima.test.core.unit.agent.impl.MockAgent in project aima-java by aimacode.

the class XYEnvironmentTest method testGetObjectsAt.

@Test
public void testGetObjectsAt() {
    XYLocation loc = new XYLocation(5, 7);
    env.moveObjectToAbsoluteLocation(a, loc);
    Assert.assertEquals(1, env.getObjectsAt(loc).size());
    AbstractAgent b = new MockAgent();
    env.addObjectToLocation(b, loc);
    Assert.assertEquals(2, env.getObjectsAt(loc).size());
}
Also used : MockAgent(aima.test.core.unit.agent.impl.MockAgent) XYLocation(aima.core.util.datastructure.XYLocation) AbstractAgent(aima.core.agent.impl.AbstractAgent) Test(org.junit.Test)

Example 5 with MockAgent

use of aima.test.core.unit.agent.impl.MockAgent in project aima-java by aimacode.

the class XYEnvironmentTest method setUp.

@Before
public void setUp() {
    env = new XYEnvironment(10, 12);
    a = new MockAgent();
    env.addObjectToLocation(a, new XYLocation(3, 4));
}
Also used : MockAgent(aima.test.core.unit.agent.impl.MockAgent) XYEnvironment(aima.core.environment.xyenv.XYEnvironment) XYLocation(aima.core.util.datastructure.XYLocation) Before(org.junit.Before)

Aggregations

MockAgent (aima.test.core.unit.agent.impl.MockAgent)5 XYLocation (aima.core.util.datastructure.XYLocation)4 AbstractAgent (aima.core.agent.impl.AbstractAgent)3 Test (org.junit.Test)3 Before (org.junit.Before)2 Action (aima.core.agent.Action)1 EnvironmentObject (aima.core.agent.EnvironmentObject)1 Percept (aima.core.agent.Percept)1 DynamicAction (aima.core.agent.impl.DynamicAction)1 DynamicPercept (aima.core.agent.impl.DynamicPercept)1 NoOpAction (aima.core.agent.impl.NoOpAction)1 TableDrivenAgentProgram (aima.core.agent.impl.aprog.TableDrivenAgentProgram)1 Wall (aima.core.environment.xyenv.Wall)1 XYEnvironment (aima.core.environment.xyenv.XYEnvironment)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1