public void Move(Car self, World world, Game game, Move move) { TimerStart(); MyStrategy.world = world; Const.Game = game; this.move = move; this.self = self; Initialize(); #if DEBUG while (Visualizer.Pause) { // pause here } Visualizer.CreateForm(world.Cars.Count(x => x.IsTeammate)); #endif if (!self.IsFinishedTrack) { All = null; MyTeam = null; _move(); if (OpponentsCars != null) { var myTeam = new List <ACar[]>(); if (!ComputedPath.ContainsKey(self.Id)) { ComputedPath[self.Id] = new int[MagicConst.OpponentsTicksPrediction].Select(x => new ACar(self)).ToArray(); } myTeam.Add(ComputedPath[self.Id]); if (TeammateCar != null) { myTeam.Add(TeammateCar); } MyTeam = myTeam.ToArray(); All = MyTeam.Concat(OpponentsCars).ToArray(); TimerStart(); if (CheckUseProjectile()) { move.IsThrowProjectile = true; } if (CheckUseOil()) { move.IsSpillOil = true; } TimerEndLog("CheckUseProjectile", 2); } } else if (_finishTime == Infinity) { _finishTime = world.Tick; } if (_finishTime < Infinity) { Log(_finishTime); } #if DEBUG if (move.IsBrake) { Visualizer.CircleFillQueue.Add(new Tuple <Brush, ACircularUnit>(Brushes.Red, new ACircularUnit { X = self.X, Y = self.Y, Radius = 30 })); } TimerEndLog("All"); if (Brutes != null) { for (var i = 0; i < Brutes.Length; i++) { var info = Brutes[i].GetMaxTicksInfo(); if (info == null) { continue; } Console.Write(i + ": "); foreach (var a in info) { Console.Write(" " + a); } Console.WriteLine("(" + Brutes[i].SelectedCount + ")"); } } Console.WriteLine(); Visualizer.Draw(); Thread.Sleep(12); #endif }
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); } }