Exemplo n.º 1
0
        public double Run(TravelGameState state)
        {
            if (state.locations[_player] == _goal)
            {
                return(0);
            }
            TravelWorld world           = state.ToWorld();
            TravelPath  cheapPath       = world.findCheapestPath(state.locations[_player], _goal);
            var         closeToPenality = (_MaxMoves - state.totalMoves[_player]) - cheapPath.Count;
            var         res             = -cheapPath.Cost();

            if (closeToPenality <= 0)
            {
                res += 100;
            }
            return(res);
        }
Exemplo n.º 2
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());
        }