Beispiel #1
0
        void AlternativeMove(Points pts)
        {
            var car = new ACar(self);

            var backBruteRes = _doAndSelectBrute(BackBrutes, pts);

            if (backBruteRes.Item1 != -1)
            {
                BackBrutes[backBruteRes.Item1].SelectThis();
                var mv = backBruteRes.Item2[backBruteRes.Item1];
                if (mv.Count > 0)
                {
                    mv[0].Apply(move, new ACar(self));
                    ComputedPath[self.Id] = GetCarPath(self, mv);
#if DEBUG
                    Visualizer.DrawWays(self, backBruteRes.Item2, backBruteRes.Item1);
#endif
                    return;
                }
            }

            // change points
            pts = GetAlternativeWaySegments(self);
            var turnCenter = pts[1];

            var tmp = new ACar(self);
            var aa  = tmp + tmp.Speed;
            if (Math.Abs(tmp.GetAngleTo(aa)) > Math.PI / 2)
            {
                move.EnginePower = 1;
                move.WheelTurn  *= -1;
                return;
            }


            move.EnginePower = 1.0;

            if (car.GetDistanceTo(turnCenter) < 1.6 * Const.TileSize)
            {
                move.EnginePower = 0.8;
            }

            if (car.GetDistanceTo(turnCenter) < 1.0 * Const.TileSize)
            {
                if (GetSpeed(self) > 11)
                {
                    move.IsBrake = true;
                }
            }
            move.WheelTurn = car.GetAngleTo(turnCenter);

            if (BAD_TESTING_STRATEGY)
            {
                if (turnCenter.GetDistanceTo(self) >= 7 * Const.TileSize &&
                    Math.Abs(car.GetAngleTo(turnCenter)) < Math.PI / 6)
                {
                    move.IsUseNitro = true;
                }
            }
        }
Beispiel #2
0
        private void _move()
        {
            var pts = GetWaySegments(self);

            if (world.Tick > Const.Game.InitialFreezeDurationTicks)
            {
                PositionsHistory.Add(new Point(self));
            }

            if (!DurabilityObserver.IsActive(self))
            {
                return;
            }

            if (CheckBackMove(pts[1]))
            {
                return;
            }

            InitBrutes();

            if (world.Tick < Const.Game.InitialFreezeDurationTicks)
            {
                var nextCell   = DijkstraNextCell(GetCell(self), GetNextWayPoint(self), new Cell[] {});
                var nextCenter = GetCenter(nextCell);
                move.EnginePower = self.GetAngleTo(nextCenter.X, nextCenter.Y) < Math.PI / 2 ? 1 : -1;
                return;
            }

            if (BAD_TESTING_STRATEGY)
            {
                AlternativeMove(pts);
                return;
            }

            // если еду назад, то запускать только первый перебор
            // если маленькая скорость, то 1-й и 2-й
            var bruteRes =
                _doAndSelectBrute(
                    self.EnginePower < 0
                        ? new[] { Brutes[0] }
                        : (GetSpeed(self) < 5 ? new[] { Brutes[0], Brutes[1] } : Brutes), pts);

            var sel            = bruteRes.Item1;
            var bestMoveStacks = bruteRes.Item2;

            if (sel != -1 && bestMoveStacks[sel].Count > 0)
            {
                Brutes[sel].SelectThis();
                bestMoveStacks[sel][0].Apply(move, new ACar(self));
                ComputedPath[self.Id] = GetCarPath(self, bestMoveStacks[sel]);
#if DEBUG
                Visualizer.DrawWays(self, bestMoveStacks, sel);
#endif
            }
            else
            {
                TimerStart();
                AlternativeMove(pts);
                TimerEndLog("AlternativeMove", 30);
            }
        }