示例#1
0
	public void testAlreadyAtGoal() {
		MapEnvironment me = new MapEnvironment(aMap);
		OnlineDFSAgent agent = new OnlineDFSAgent(new OnlineSearchProblem(
				MapFunctionFactory.getActionsFunction(aMap),
				new DefaultGoalTest("A"), new MapStepCostFunction(aMap)),
				MapFunctionFactory.getPerceptToStateFunction());
		me.addAgent(agent, "A");
		me.addEnvironmentView(new TestEnvironmentView());
		me.stepUntilDone();

		Assert.assertEquals("Action[name==NoOp]->", envChanges.ToString());
	}
示例#2
0
        public void testNoPath()
        {
            MapEnvironment me = new MapEnvironment(aMap);
            SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, new UniformCostSearch <string, MoveToAction>(), new string[] { "A" });

            me.addAgent(ma, "E");
            me.AddEnvironmentView(new TestEnvironmentView(envChanges));
            me.StepUntilDone();

            Assert.AreEqual(
                "CurrentLocation=In(E), Goal=In(A):Action[name==NoOp]:METRIC[nodesExpanded]=1:METRIC[queueSize]=0:METRIC[maxQueueSize]=1:METRIC[pathCost]=0:Action[name==NoOp]:",
                envChanges.ToString());
        }
示例#3
0
	public void testNoPath() {
		MapEnvironment me = new MapEnvironment(aMap);
		MapAgent ma = new MapAgent(me.getMap(), me, new UniformCostSearch(),
				new String[] { "A" });
		me.addAgent(ma, "E");
		me.addEnvironmentView(new TestEnvironmentView());
		me.stepUntilDone();

		Assert
				.assertEquals(
						"CurrentLocation=In(E), Goal=In(A):Action[name==NoOp]:METRIC[pathCost]=0:METRIC[maxQueueSize]=1:METRIC[queueSize]=0:METRIC[nodesExpanded]=1:Action[name==NoOp]:",
						envChanges.ToString());
	}
示例#4
0
        public void testNormalSearchGraphSearchMinFrontier()
        {
            MapEnvironment me = new MapEnvironment(aMap);
            UniformCostSearch <string, MoveToAction> ucSearch = new UniformCostSearch <string, MoveToAction>(new GraphSearchReducedFrontier <string, MoveToAction>());

            SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, ucSearch, new string[] { "D" });

            me.addAgent(ma, "A");
            me.AddEnvironmentView(new TestEnvironmentView(envChanges));
            me.StepUntilDone();

            Assert.AreEqual(
                "CurrentLocation=In(A), Goal=In(D):Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:METRIC[nodesExpanded]=3:METRIC[queueSize]=1:METRIC[maxQueueSize]=2:METRIC[pathCost]=13:Action[name==NoOp]:",
                envChanges.ToString());
        }
        public void test_A_StartingAtGoal()
        {
            ExtendableMap aMap = new ExtendableMap();

            MapEnvironment me = new MapEnvironment(aMap);
            SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new string[] { "A" });

            me.addAgent(ma, "A");
            me.AddEnvironmentView(new BDSEnvironmentView(envChanges));
            me.StepUntilDone();

            Assert.AreEqual(
                "CurrentLocation=In(A), Goal=In(A):Action[name==NoOp]:METRIC[nodesExpanded]=0:METRIC[queueSize]=0:METRIC[maxQueueSize]=0:METRIC[pathCost]=0:Action[name==NoOp]:",
                envChanges.ToString());
        }
        public void test_AB_BothWaysPath()
        {
            ExtendableMap aMap = new ExtendableMap();

            aMap.addBidirectionalLink("A", "B", 5.0);

            MapEnvironment me = new MapEnvironment(aMap);
            SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new string[] { "B" });

            me.addAgent(ma, "A");
            me.AddEnvironmentView(new BDSEnvironmentView(envChanges));
            me.StepUntilDone();

            Assert.AreEqual(
                "CurrentLocation=In(A), Goal=In(B):Action[name==moveTo, location==B]:METRIC[nodesExpanded]=1:METRIC[queueSize]=1:METRIC[maxQueueSize]=2:METRIC[pathCost]=5:Action[name==NoOp]:",
                envChanges.ToString());
        }
示例#7
0
	public void testNoPath() {
		aMap = new ExtendableMap();
		aMap.addBidirectionalLink("A", "B", 1.0);
		MapEnvironment me = new MapEnvironment(aMap);
		OnlineDFSAgent agent = new OnlineDFSAgent(new OnlineSearchProblem(
				MapFunctionFactory.getActionsFunction(aMap),
				new DefaultGoalTest("X"), new MapStepCostFunction(aMap)),
				MapFunctionFactory.getPerceptToStateFunction());
		me.addAgent(agent, "A");
		me.addEnvironmentView(new TestEnvironmentView());

		me.stepUntilDone();

		Assert
				.assertEquals(
						"Action[name==moveTo, location==B]->Action[name==moveTo, location==A]->Action[name==moveTo, location==B]->Action[name==moveTo, location==A]->Action[name==NoOp]->",
						envChanges.ToString());
	}
        public void test_ABCDEF_ReverseFirstButNotFromOriginal()
        {
            ExtendableMap aMap = new ExtendableMap();

            aMap.addBidirectionalLink("A", "B", 5.0);
            aMap.addBidirectionalLink("B", "C", 5.0);
            aMap.addBidirectionalLink("C", "D", 5.0);
            aMap.addBidirectionalLink("D", "E", 5.0);
            aMap.addBidirectionalLink("E", "F", 5.0);
            aMap.addUnidirectionalLink("E", "A", 5.0);

            MapEnvironment me = new MapEnvironment(aMap);
            SimpleMapAgent ma = new SimpleMapAgent(me.getMap(), me, search, new string[] { "F" });

            me.addAgent(ma, "A");
            me.AddEnvironmentView(new BDSEnvironmentView(envChanges));
            me.StepUntilDone();

            Assert.AreEqual(
                "CurrentLocation=In(A), Goal=In(F):Action[name==moveTo, location==B]:Action[name==moveTo, location==C]:Action[name==moveTo, location==D]:Action[name==moveTo, location==E]:Action[name==moveTo, location==F]:METRIC[nodesExpanded]=6:METRIC[queueSize]=1:METRIC[maxQueueSize]=2:METRIC[pathCost]=25:Action[name==NoOp]:",
                envChanges.ToString());
        }
示例#9
0
 public void testAddAgent()
 {
     me.addAgent(ma, "E");
     Assert.AreEqual(me.getAgentLocation(ma), "E");
 }