private Bitmap DrawWorstSpotsMap()
        {
            _addtoradius = 0; //init the mf
            var b = _zone.CreatePassableBitmap(_passableColor, _islandColor);

            var terminalSpots     = MissionSpot.GetTerminalSpotsFromZone(_zone);
            var spotInfos         = MissionSpot.GetMissionSpotsFromUnitsOnZone(_zone, true);
            var randomPointsInfos = MissionSpot.GetRandomPointSpotsFromTargets(_zone.Configuration, true);

            var allSpots = terminalSpots.Concat(spotInfos).Concat(randomPointsInfos).ToList();

            var spotStats = new List <MissionSpotStat>(allSpots.Count);

            foreach (var missionSpot in allSpots)
            {
                var stat = missionSpot.CountSelectableSpots(allSpots);
                spotStats.Add(stat);
            }

            WriteReportByType(MissionSpotType.randompoint, spotStats, b);
            WriteReportByType(MissionSpotType.mswitch, spotStats, b);
            WriteReportByType(MissionSpotType.kiosk, spotStats, b);
            WriteReportByType(MissionSpotType.itemsupply, spotStats, b);


            b.WithGraphics(g => g.DrawString("switch", new Font("Tahoma", 15), new SolidBrush(_switchColor), new PointF(20, 60)));
            b.WithGraphics(g => g.DrawString("item submit/kiosk", new Font("Tahoma", 15), new SolidBrush(_kioskColor), new PointF(20, 80)));
            b.WithGraphics(g => g.DrawString("item supply", new Font("Tahoma", 15), new SolidBrush(_itemSupplyColor), new PointF(20, 100)));
            b.WithGraphics(g => g.DrawString("random point", new Font("Tahoma", 15), new SolidBrush(_randomPointColor), new PointF(20, 120)));


            return(b);
        }
예제 #2
0
        private Bitmap GenerateMissionSpots(IRequest request)
        {
            //-------- kick brute force fill in

            const int fieldTerminalTargetAmount = 2500;
            const int switchTargetAmount        = 2500;
            const int kioskTargetAmount         = 2500;
            const int itemSupplyTargetAmount    = 2500;
            const int randomPointTargetAmount   = 2500;

            //----code

            Db.Query().CommandText("delete missionspotinfo where zoneid=@zoneId").SetParameter("@zoneId", _zone.Id).ExecuteNonQuery();

            var staticObjects = MissionSpot.GetStaticObjectsFromZone(_zone);

            var spotInfos = new List <MissionSpot>();



            PlaceOneType(spotInfos, MissionSpotType.fieldterminal, fieldTerminalTargetAmount, fieldTerminalDistanceInfos, staticObjects, fieldTerminalAccuracy);
            PlaceOneType(spotInfos, MissionSpotType.mswitch, switchTargetAmount, switchDistanceInfos, staticObjects, structureAccuracy);
            PlaceOneType(spotInfos, MissionSpotType.kiosk, kioskTargetAmount, kioskDistanceInfos, staticObjects, structureAccuracy);
            PlaceOneType(spotInfos, MissionSpotType.itemsupply, itemSupplyTargetAmount, itemSupplyDistanceInfos, staticObjects, structureAccuracy);
            PlaceOneType(spotInfos, MissionSpotType.randompoint, randomPointTargetAmount, randomPointDistanceInfos, staticObjects, randomPointAccuracy);

            var resultBitmap = DrawResultOnBitmap(spotInfos, staticObjects);

            SendDrawFunctionFinished(request);

            return(resultBitmap);
        }
예제 #3
0
        private Bitmap DisplaySpots()
        {
            var staticObjects = MissionSpot.GetStaticObjectsFromZone(_zone);

            var spotInfos = MissionSpot.GetMissionSpotsFromUnitsOnZone(_zone);

            var randomPointsInfos = MissionSpot.GetRandomPointSpotsFromTargets(_zone.Configuration);

            spotInfos.AddRange(randomPointsInfos);

            return(DrawResultOnBitmap(spotInfos, staticObjects));
        }
        private Bitmap GenerateRandomPointsOnly(IRequest request)
        {
            //-------- kick brute force fill in
            const int randomPointTargetAmount = 2500;

            //----code

            var deletedSpots =
                Db.Query().CommandText("delete missionspotinfo where zoneid=@zoneId and type=@spotType")
                .SetParameter("@zoneId", _zone.Id)
                .SetParameter("@spotType", (int)MissionSpotType.randompoint)
                .ExecuteNonQuery();

            Logger.Info(deletedSpots + " random point spots were deleted from zone:" + _zone.Id);

            var staticObjects = MissionSpot.GetStaticObjectsFromZone(_zone);

            var spotInfos = MissionSpot.GetMissionSpotsFromUnitsOnZone(_zone);

            PlaceOneType(spotInfos, MissionSpotType.randompoint, randomPointTargetAmount, randomPointDistanceInfos, staticObjects, randomPointAccuracy);

            var resultBitmap = DrawResultOnBitmap(spotInfos, staticObjects);

            SendDrawFunctionFinished(request);

            var randomPoints = spotInfos.Where(i => i.type == MissionSpotType.randompoint).ToList();

            Logger.Info(randomPoints.Count + " new random points were generated.");

            //-------


            var deletedTargets =
                Db.Query().CommandText("delete missiontargets where targetpositionzone=@zoneId and targettype=@targetType")
                .SetParameter("@zoneId", _zone.Id)
                .SetParameter("@targetType", (int)MissionTargetType.rnd_point)
                .ExecuteNonQuery();

            Logger.Info(deletedTargets + " mission targets were deleted.");


            foreach (var missionSpot in randomPoints)
            {
                MissionHelper.PlaceRandomPoint(_zone, missionSpot.position, (int)DistanceConstants.MISSION_RANDOM_POINT_FINDRADIUS_DEFAULT);
            }

            Logger.Info("new mission targets inserted");

            return(resultBitmap);
        }
예제 #5
0
 private static void SaveInfoAsync(MissionSpot si)
 {
     Task.Run(() => { si.Save(); });
 }
예제 #6
0
        private void PlaceOneType(List <MissionSpot> spotInfos, MissionSpotType type, int targetAmount, Dictionary <MissionSpotType, int> distanceInfos, Dictionary <MissionSpotType, List <Position> > staticObjects, AccuracyInfo accuracyInfo)
        {
            var distanceToMyType = distanceInfos[type];
            var zoneWidth        = _zone.Size.Width;
            var borderWidthMax   = zoneWidth;

            //to make it fast
            //border increase 200
            //start border 200

            var borderIncrease = accuracyInfo.borderIncrease;
            var currentBorder  = accuracyInfo.initialBorder;
            var foundTotal     = 0;

            var freePoints = new List <Point>(_zone.Configuration.Size.Width * _zone.Configuration.Size.Height);

            InitPoints(spotInfos, distanceInfos, staticObjects, freePoints);

            while (true)
            {
                if (currentBorder > borderWidthMax)
                {
                    Logger.Info("Max border reached " + type);
                    return;
                }

                Logger.Info("border:" + currentBorder);

                var maxAttempts = freePoints.Count;
                var attempts    = 0;
                while (true)
                {
                    if (freePoints.Count == 0)
                    {
                        Logger.Info("no more free points");
                        return;
                    }

                    attempts++;
                    if (attempts > maxAttempts)
                    {
                        currentBorder += borderIncrease;
                        Logger.Info("MAX attempts reached!");
                        break;
                    }

                    if (attempts % 50000 == 0)
                    {
                        Logger.Info(type + " working " + attempts);
                    }

                    var pickedIndex    = FastRandom.NextInt(freePoints.Count - 1);
                    var pickedPosition = freePoints[pickedIndex].ToPosition();



                    //super turbo mode, skips border check when it generates random points
                    //if (type != MissionSpotType.randompoint)
                    //{ is keep distance }


                    //good if the distance is kept
                    if (!IsKeepDistance(pickedPosition, spotInfos, distanceInfos, staticObjects, 0, currentBorder))
                    {
                        continue;
                    }


                    if (!CheckConditionsAroundPosition(pickedPosition, accuracyInfo.blockRadius, accuracyInfo.islandRadius))
                    {
                        freePoints.Remove(pickedPosition);
                        continue;
                    }

                    //--- yay! position found!

                    var si = new MissionSpot(type, pickedPosition, _zone.Id);

                    spotInfos.Add(si);
                    SaveInfoAsync(si);

                    foundTotal++;
                    if (foundTotal >= targetAmount)
                    {
                        Logger.Info(foundTotal + " " + type + " was found successfully. Target amount reached!");
                        return;
                    }

                    CleanUpOneSpot(pickedPosition, distanceToMyType, ref freePoints);
                    //MakeSnap(type,freeKeys);
                    Logger.Info(type + "\t\t" + foundTotal + "\tattempts:" + attempts);
                    break;
                }
            }
        }