Exemplo n.º 1
0
        public override ActionType GetNextAction(TravelWorld world)
        {
            if (CurrentLocation == _targetPlace)
            {
                return(noOpertion);
            }

            TravelPath path = world.ShortestClearPath(CurrentLocation, _targetPlace);

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

            int nextPlace = path.First();

            return(new ActionType(w => drive(w, nextPlace)));
        }
Exemplo n.º 2
0
        private ActionType actionToFindWater(TravelWorld currWorld)
        {
            if (currWorld.HaveWater(CurrentLocation))
            {
                return(new ActionType(world => { return pickupWater(world); }));
            }

            if (_waterPath == null || _waterPath.Count() == 0 || currWorld.isPathClear(_waterPath))
            {
                _waterPath = findWaterPath(currWorld);
            }


            if (_waterPath != null && _waterPath.Count > 0)
            {
                int nextPlace = _waterPath.TakeNextStep();
                return(new ActionType(world => { return drive(world, nextPlace); }));
            }
            else
            {
                return(noOpertion);
            }
        }