Ejemplo n.º 1
0
        //Example 2
        public void RivalsGame()
        {
            TravelWorld world = CommonWorld();

            Human human = CommonHuman();

            var agent = new CompetetiveAgent(1, 3, human, 2, 10);

            agent.costs = CommonCosts();

            world.AddPlayer(human);
            world.AddPlayer(agent);

            //set fire to 2
            agent.GetNextAction(world)(world);
            Assert.AreEqual(2, agent.CurrentLocation);
            Assert.IsTrue(!world.isClear(2, 1));

            human.pickupWater(world);

            //set fire to 3
            agent.GetNextAction(world)(world);
            Assert.AreEqual(3, agent.CurrentLocation);
            Assert.IsTrue(!world.isClear(2, 3));

            human.drive(world, 3);

            Assert.AreEqual(3, agent.TotalCost - human.TotalCost);
        }
Ejemplo n.º 2
0
        public void setFireOnce()
        {
            Pyromaniac agent = new Pyromaniac(1, 1);

            //set fire to (1,2)
            (agent.GetNextAction(world)).Invoke(world);
            Assert.IsFalse(world.isClear(1, 2));
            Assert.AreEqual(agent.CurrentLocation, 2);
            Assert.AreEqual(agent.TotalCost, 0);
        }
Ejemplo n.º 3
0
        //Example1
        public void CoperativeGame()
        {
            TravelWorld world = CommonWorld();

            Human human = CommonHuman();

            var agent = new CoopertiveAgent(1, 3, human, 2, 10);

            agent.costs = CommonCosts();

            world.AddPlayer(human);
            world.AddPlayer(agent);

            //pickupwater
            agent.GetNextAction(world)(world);
            Assert.AreEqual(1, agent.CurrentLocation);
            Assert.IsTrue(!world.HaveWater(1));

            human.noOpertion(world);
            //drive to 3
            agent.GetNextAction(world)(world);
            Assert.AreEqual(3, agent.CurrentLocation);
            Assert.IsTrue(world.isClear(1, 3));

            human.drive(world, 3);

            Assert.AreEqual(3, agent.CurrentLocation);
            Assert.AreEqual(3, agent.TotalCost);
            Assert.AreEqual(1.05, human.TotalCost);
        }
Ejemplo n.º 4
0
        public void stopFire()
        {
            TravelWorld world = new TravelWorld();

            world.AddPlaces(1, 2, 3);
            world.AddWay(1, 2, 2);
            world.AddWay(3, 2, 2);
            world.AddWay(3, 1, 10);
            world.SetFire(2, 3);
            world.PutWater(2);

            FireFighter agent = new FireFighter(1);

            //go to the place with water
            (agent.GetNextAction(world))(world);
            Assert.AreEqual(agent.CurrentLocation, 2);
            Assert.AreEqual(agent.TotalCost, 2);
            double lastCost = agent.TotalCost;

            //PickWater
            (agent.GetNextAction(world)).Invoke(world);
            Assert.AreEqual(agent.CurrentLocation, 2);
            Assert.AreEqual(agent.TotalCost - lastCost, Costs.Instance.Pickup);
            Assert.IsFalse(world.HaveWater(2));
            lastCost = agent.TotalCost;

            //stop fire
            (agent.GetNextAction(world))(world);
            Assert.AreEqual(agent.CurrentLocation, 3);
            Assert.AreEqual(agent.TotalCost - lastCost, 2 * world.getCostWay(2, 3));
            Assert.IsFalse(agent.CarryWater);
            Assert.IsTrue(world.isClear(2, 3));
        }
Ejemplo n.º 5
0
        public void FireTest()
        {
            TravelWorld world = new TravelWorld();

            world.AddPlaces(1, 2);
            world.AddWay(1, 2, 1);
            world.SetFire(1, 2);
            Assert.IsFalse(world.isClear(1, 2));
        }
Ejemplo n.º 6
0
        public void SetFireTest()
        {
            TravelWorld world = new TravelWorld();

            world.AddPlaces(1, 2, 3);
            world.AddWay(1, 3, 1);
            world.SetFire(1, 3);
            world.StopFire(1, 3);
            Assert.IsTrue(world.isClear(1, 3));
        }
Ejemplo n.º 7
0
        public void NaturalGame()
        {
            TravelWorld world = new TravelWorld();

            world.AddPlaces(2, 3, 4);
            world.AddWay(3, 2, 2);
            world.AddWay(3, 4, 2);
            world.AddWay(2, 4, 10);
            world.SetFire(2, 4);


            Human human = new Human(2);

            human.costs.Fire   = 1;
            human.costs.Pickup = 5;
            human.Goal         = 4;

            BasicCuttof cuttOf = new BasicCuttof();

            agent              = new NeutralAgent(2, 4, human, 3, 10);
            agent.costs.Fire   = 10;
            agent.costs.Pickup = 5;

            world.AddPlayer(human);
            world.AddPlayer(agent);

            //eval.SetParams(agent, human, 10);
            cuttOf.SetParams(agent, 3);

            agent.GetNextAction(world)(world);
            Assert.AreEqual(3, agent.CurrentLocation);
            Assert.IsTrue(world.isClear(2, 3));

            agent.GetNextAction(world)(world);
            Assert.AreEqual(4, agent.CurrentLocation);
            Assert.IsTrue(world.isClear(4, 3));
        }
Ejemplo n.º 8
0
        public void clearWays()
        {
            TravelWorld world = new TravelWorld();

            world.AddPlaces(1, 2, 3);
            world.AddWay(1, 2, 1);
            world.AddWay(1, 3, 1);
            world.AddWay(3, 2, 1);
            world.SetFire(1, 3);
            world.SetFire(2, 3);
            var ways = world.GetClearWays(1);

            Assert.AreEqual(ways.Count(), 1);
            Assert.IsFalse(!world.isClear(ways.First()));
        }