use of aima.core.environment.wumpusworld.AgentPercept in project aima-java by aimacode.
the class WumpusKnowledgeBaseTest method testAskCurrentPosition.
@Test
public void testAskCurrentPosition() {
// Create very small cave in order to make inference for tests faster.
WumpusKnowledgeBase KB = new WumpusKnowledgeBase(dpll, 2);
// NOTE: in the 2x2 cave for this set of assertion tests,
// we are going to have no pits and the wumpus in [2,2]
// this needs to be correctly set up in order to keep the KB consistent.
int t = 0;
AgentPosition current;
step(KB, new AgentPercept(false, false, false, false, false), t);
current = KB.askCurrentPosition(t);
Assert.assertEquals(new AgentPosition(1, 1, AgentPosition.Orientation.FACING_EAST), current);
KB.makeActionSentence(new Forward(current), t);
t++;
step(KB, new AgentPercept(true, false, false, false, false), t);
current = KB.askCurrentPosition(t);
Assert.assertEquals(new AgentPosition(2, 1, AgentPosition.Orientation.FACING_EAST), current);
KB.makeActionSentence(new TurnLeft(current.getOrientation()), t);
t++;
step(KB, new AgentPercept(true, false, false, false, false), t);
current = KB.askCurrentPosition(t);
Assert.assertEquals(new AgentPosition(2, 1, AgentPosition.Orientation.FACING_NORTH), current);
KB.makeActionSentence(new TurnLeft(current.getOrientation()), t);
t++;
step(KB, new AgentPercept(true, false, false, false, false), t);
current = KB.askCurrentPosition(t);
Assert.assertEquals(new AgentPosition(2, 1, AgentPosition.Orientation.FACING_WEST), current);
KB.makeActionSentence(new Forward(current), t);
t++;
step(KB, new AgentPercept(false, false, false, false, false), t);
current = KB.askCurrentPosition(t);
Assert.assertEquals(new AgentPosition(1, 1, AgentPosition.Orientation.FACING_WEST), current);
KB.makeActionSentence(new Forward(current), t);
t++;
step(KB, new AgentPercept(false, false, false, true, false), t);
current = KB.askCurrentPosition(t);
Assert.assertEquals(new AgentPosition(1, 1, AgentPosition.Orientation.FACING_WEST), current);
}
use of aima.core.environment.wumpusworld.AgentPercept in project aima-java by aimacode.
the class WumpusKnowledgeBaseTest method testAskNotUnsafeRooms.
@SuppressWarnings("serial")
@Test
public void testAskNotUnsafeRooms() {
WumpusKnowledgeBase KB;
int t = 0;
KB = new WumpusKnowledgeBase(dpll, 2);
step(KB, new AgentPercept(false, false, false, false, false), t);
Assert.assertEquals(new HashSet<Room>() {
{
add(new Room(1, 1));
add(new Room(1, 2));
add(new Room(2, 1));
}
}, KB.askNotUnsafeRooms(t));
KB = new WumpusKnowledgeBase(dpll, 2);
step(KB, new AgentPercept(true, false, false, false, false), t);
Assert.assertEquals(new HashSet<Room>() {
{
add(new Room(1, 1));
add(new Room(1, 2));
add(new Room(2, 1));
add(new Room(2, 2));
}
}, KB.askNotUnsafeRooms(t));
}
use of aima.core.environment.wumpusworld.AgentPercept in project aima-java by aimacode.
the class WumpusKnowledgeBaseTest method testAskGlitter.
@Test
public void testAskGlitter() {
WumpusKnowledgeBase KB = new WumpusKnowledgeBase(dpll, 2);
step(KB, new AgentPercept(false, false, false, false, false), 0);
Assert.assertFalse(KB.askGlitter(0));
step(KB, new AgentPercept(false, false, false, false, false), 1);
Assert.assertFalse(KB.askGlitter(1));
step(KB, new AgentPercept(false, false, true, false, false), 2);
Assert.assertTrue(KB.askGlitter(2));
step(KB, new AgentPercept(false, false, false, false, false), 3);
Assert.assertFalse(KB.askGlitter(3));
}
Aggregations