Exemplo n.º 1
0
        public void cheapestWaterPathWithFire()
        {
            TravelWorld world = new TravelWorld();

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


            var paths = world.findCheapestWaterPaths(2);

            if (paths.Count() != 1)
            {
                Assert.Fail();
            }
            var path    = paths.First();
            var resPath = new TravelPath();

            resPath.Add(1, 10);
            Assert.AreEqual(path, resPath);
        }
Exemplo n.º 2
0
        private TravelPath findWaterPath(TravelWorld world)
        {
            var paths = world.findCheapestWaterPaths(CurrentLocation);

            if (paths == null || paths.Count() == 0)
            {
                return(null);
            }

            return(findMinDest(paths));
        }
Exemplo n.º 3
0
        public double takeWaterHuristic(TravelSearchState state)
        {
            if (state.CarryWatter)
            {
                return(0);
            }
            TravelWorld world = state.ToWorld();

            if (world.HaveWater(state.CurrentLocation))
            {
                return(1);
            }

            var paths = world.findCheapestWaterPaths(state.CurrentLocation);

            if (paths == null || paths.Count() == 0)
            {
                return(double.MaxValue);
            }

            TravelPath path = paths.First();

            return(path.Cost());
        }