コード例 #1
0
 private void PeriodicScan()
 {
     while (!_halt)
     {
         try {
             var status = _actions.GetStatus();
             if (!status.Available)
             {
                 continue;
             }
             SetStatus(status);
             AddUniqueMines(status.GoldMines);
             Data.LastVisionResults = status;
             SendDirEngine(status);
             var result = _currentEngine.ReceiveStatus(status);
             if (result.Present)
             {
                 _currentEngine = result.Value;
                 if (_currentEngine is ApproacherEngine)
                 {
                     Data.TargetDirection = (_currentEngine as ApproacherEngine).GetTarget();
                 }
             }
             Task.Delay(3).Wait();
         } catch {
             //f**k it, do nothing
         }
     }
 }
コード例 #2
0
 public LongRangeApproacherEngine(SurfacePosition position, IActionEngine prevEngine, IMovementClient client, string owner)
 {
     _client       = client;
     _prevEngine   = prevEngine;
     _position     = position;
     _owner        = owner;
     _attemptStart = DateTime.Now;
 }
コード例 #3
0
 private void SendLongRangeApproacher(StatusUpdateModel model)
 {
     if (CommonTools.GetRandom(100) < 10 && _currentEngine is RandomExplorerEngine)
     {
         var location        = Data.Mines.ToList()[CommonTools.GetRandom(Data.Mines.Count)];
         var longRangeEngine = new LongRangeApproacherEngine(location.Value, _currentEngine, _actions, _user);
         _currentEngine = longRangeEngine;
         longRangeEngine.Run(model);
     }
 }
コード例 #4
0
 public ApproacherEngine(SurfacePosition position, IActionEngine prevEngine, IMovementClient client, string owner)
 {
     _position     = position;
     _prevEngine   = prevEngine;
     _client       = client;
     _status       = ApproachStatus.BREAKING;
     _owner        = owner;
     _attemptStart = DateTime.Now;
     _next         = null;
 }
コード例 #5
0
        private void Run()
        {
            InitData();
            var randomEngine = new RandomExplorerEngine(_actions, this, _user);

            randomEngine.Run(_actions.GetStatus());
            _currentEngine = randomEngine;
            //run these two async
            Task.Run(() => PeriodicScan());
            Task.Run(() => PeriodicScoreboardUpdates());
        }
コード例 #6
0
        private void SendDirEngine(StatusUpdateModel model)
        {
            if (!model.Available)
            {
                return;
            }

            if (_currentEngine is RandomExplorerEngine && Data.Mines.Count > 8 && CommonTools.GetRandom(100) < Data.Mines.Count * 3)
            {
                var closestDistance = Data.Mines.Values.Where(s => s.Owner != _user)
                                      .Select(s => CommonTools.CalHypo(model.ShipStatus.XPos, s.X, model.ShipStatus.YPos, s.Y)).Distinct().OrderBy(s => s).Where(s => s < 2000).ToList();

                if (closestDistance.Count == 0)
                {
                    if (CommonTools.GetRandom(100) < 30)
                    {
                        closestDistance = Data.Mines.Values.Where(s => s.Owner != _user)
                                          .Select(s => CommonTools.CalHypo(model.ShipStatus.XPos, s.X, model.ShipStatus.YPos, s.Y)).Distinct().OrderBy(s => s).Where(s => s < 4000).ToList();
                    }
                    else
                    {
                        return;
                    }
                }

                var closestList = Data.Mines.Where(s => closestDistance.Contains(CommonTools.CalHypo(model.ShipStatus.XPos, s.Value.X, model.ShipStatus.YPos, s.Value.Y))).Distinct().ToList();

                var closest  = closestList[CommonTools.GetRandom(closestList.Count)];
                var distance = CommonTools.CalHypo(model.ShipStatus.XPos, closest.Value.X, model.ShipStatus.YPos, closest.Value.Y);

                var dirEngine = new InfluencedDirEngine(_actions, this, _user, closest.Value);
                _currentEngine       = dirEngine;
                Data.TargetDirection = closest.Value;
                dirEngine.Run(model);
            }
        }