Esempio n. 1
0
        public void NoClearWays()
        {
            TravelWorld world = new TravelWorld();

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

            Assert.IsTrue(ways.Count() == 0);
        }
Esempio n. 2
0
        private IEnumerable <ActionType> getFireActions(TravelGameState state, TravelWorld world)
        {
            List <ActionType> res = new List <ActionType>();
            var ways = world.GetClearWays(state.locations[this]);

            foreach (var way in ways)
            {
                int dest   = way.getAnotherPlace(state.locations[this]);
                var action = new ActionType(w => startAfire(w, dest));
                res.Add(action);
            }
            return(res);
        }
Esempio n. 3
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()));
        }
Esempio n. 4
0
        protected IEnumerable <ActionType> getDriveActions(TravelSearchState state, TravelWorld world)
        {
            List <ActionType>        res = new List <ActionType>();
            IEnumerable <TravelEdge> ways;

            if (state.CarryWatter)
            {
                ways = world.GetWays(state.CurrentLocation);
            }
            else
            {
                ways = world.GetClearWays(state.CurrentLocation);
            }

            foreach (var way in ways)
            {
                int dest   = way.getAnotherPlace(state.CurrentLocation);
                var action = new ActionType(w => drive(w, dest));
                res.Add(action);
            }
            return(res);
        }
Esempio n. 5
0
 public override ActionType GetNextAction(TravelWorld world)
 {
     ++numOfMoves;
     if (numOfMoves == sleepMoves)
     {
         numOfMoves = 0;
         var ways = world.GetClearWays(CurrentLocation);
         if (ways == null || ways.Count() == 0)
         {
             return(noOpertion);
         }
         else
         {
             double minDistance = ways.Min(way => world.getCostWay(way));
             ways = ways.Where(way => world.getCostWay(way) == minDistance);
             int minDest = ways.Min(way => way.getAnotherPlace(CurrentLocation));
             return(new ActionType(w => startAfire(w, minDest)));
         }
     }
     else
     {
         return(new ActionType(w => false));
     }
 }