Ejemplo n.º 1
0
        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
        }