Ejemplo n.º 1
0
        public MapMatrix(IEnumerable <FortCacheItem> forts, FortCacheItem fortToStart, int fortsToVisit = 0, bool nearestNeigh = true)
        {
            Forts             = forts.ToArray();
            _size             = Forts.Length;
            _nearestNeigh     = nearestNeigh;
            _fortsDistance    = new double[_size, _size];
            _newFortsDistance = new double[_size, _size];
            for (var i = 0; i < Forts.Length; i++)
            {
                for (var j = 0; j < Forts.Length; j++)
                {
                    if (i != j)
                    {
                        _fortsDistance[j, i] = _fortsDistance[i, j] = LocationUtils.CalculateDistanceInMeters(Forts[i].Latitude,
                                                                                                              Forts[i].Longitude,
                                                                                                              Forts[j].Latitude, Forts[j].Longitude);
                    }
                    else
                    {
                        _fortsDistance[j, i] = PositiveInfinity;
                    }
                }
            }
            if (_fortsToVisit < _size - 1)
            {
                _fortsToVisit = fortsToVisit;
            }

            _opt    = LimitedVisit ? new int[_fortsToVisit] : new int[_size];
            _opt[0] = Forts.ToList().IndexOf(fortToStart);
            _opt    = ResetOpt(_opt, 1);
        }
Ejemplo n.º 2
0
        public static List <GeoCoordinate> GetBestRoute(FortCacheItem startingPokestop,
                                                        IEnumerable <FortCacheItem> pokestopsList, int amountToVisit)
        {
            var result = new List <GeoCoordinate>();
            var map    = new MapMatrix(pokestopsList, startingPokestop, amountToVisit);
            var route  = map.Optimize();

            foreach (var wp in route)
            {
                result.Add(new GeoCoordinate(wp.Latitude, wp.Longitude));
            }
            return(result);
        }
Ejemplo n.º 3
0
 private static async Task MoveToPokestop(ISession session, CancellationToken cancellationToken, FortCacheItem pokeStop, List <GeoCoordinate> waypoints, EggWalker eggWalker)
 {
     await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude),
                                   session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax,
                                   async() =>
     {
         if (session.LogicSettings.CatchWildPokemon)
         {
             // Catch normal map Pokemon
             await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
             //Catch Incense Pokemon
             await CatchIncensePokemonsTask.Execute(session, cancellationToken);
         }
         return(true);
     },
                                   async() =>
     {
         await UseNearbyPokestopsTask.Execute(session, cancellationToken);
         return(true);
     }, cancellationToken, session, waypointsToVisit : waypoints, eggWalker : eggWalker);
 }
Ejemplo n.º 4
0
 private static async Task MoveToPokestop(ISession session, CancellationToken cancellationToken, FortCacheItem pokeStop)
 {
     await session.Navigation.Move(new GeoCoordinate(pokeStop.Latitude, pokeStop.Longitude),
                                   session.LogicSettings.WalkingSpeedMin, session.LogicSettings.WalkingSpeedMax,
                                   async() =>
     {
         // Catch normal map Pokemon
         await CatchNearbyPokemonsTask.Execute(session, cancellationToken);
         //Catch Incense Pokemon
         await CatchIncensePokemonsTask.Execute(session, cancellationToken);
         return(true);
     },
                                   async() =>
     {
         await UseNearbyPokestopsTask.Execute(session, cancellationToken);
         return(true);
     }, cancellationToken, session);
 }