コード例 #1
0
        static void Main(string[] args)
        {
            string rawinputs;
            CSBPod PodMyG  = new CSBPod();
            CSBPod PodMyH  = new CSBPod();
            CSBPod PodHisG = new CSBPod();
            CSBPod PodHisH = new CSBPod();

            // read Track
            int      laps            = int.Parse(Console.ReadLine());
            int      checkpointCount = int.Parse(Console.ReadLine());
            CSBTrack Track           = new CSBTrack(laps, checkpointCount);

            for (int i = 0; i < Track.CPNumber; i++)
            {
                rawinputs = Console.ReadLine();
                Track.AddCheckPoint(i, rawinputs);
            }
            // game loop
            while (true)
            {
                // read Pods
                rawinputs = Console.ReadLine();
                PodMyG.Update(rawinputs, Track);
                rawinputs = Console.ReadLine();
                PodMyH.Update(rawinputs, Track);
                rawinputs = Console.ReadLine();
                PodHisG.Update(rawinputs, Track);
                rawinputs = Console.ReadLine();
                PodHisH.Update(rawinputs, Track);

                // Write an action using Console.WriteLine()
                // To debug: Console.Error.WriteLine("Debug messages...");

                // Console.Error.WriteLine("### FMCAS A");
                PodMyG.FMCAS(PodMyH, PodHisG, PodHisH);
                // PodMyG.Debug();

                // Console.Error.WriteLine("### FMCAS B");
                PodMyH.FMCAS(PodMyG, PodHisG, PodHisH);
                // PodMyH.Debug();

                // Console.Error.WriteLine("### AFCSMOVE A");
                Console.WriteLine(PodMyG.AFCSMOVE());
                // Console.Error.WriteLine("### AFCSMOVE B");
                Console.WriteLine(PodMyH.AFCSMOVE());
            }
        }
コード例 #2
0
        public void Update(string rawinputs, CSBTrack Track)
        {
            string[] inputs = rawinputs.Split(' ');
            if (p_PosPod.X == -1 && p_PosPod.Y == -1)
            {
                p_PrevPosMe.Update(int.Parse(inputs[0]), int.Parse(inputs[1]));
            }
            else
            {
                p_PrevPosMe.Update(p_PosPod);
            }
            p_PosPod.Update(int.Parse(inputs[0]), int.Parse(inputs[1]));
            p_PosMySpeed.Update(int.Parse(inputs[2]), int.Parse(inputs[3]));
            p_DegAngleOrgHead      = int.Parse(inputs[4]);
            p_PosEastAngleOrigin.Y = p_PosPod.Y;

            // Next 3 CP from Track
            p_nextTRACKCPID = int.Parse(inputs[5]);
            Next3CPRoute.Update(Track.CPTable[p_nextTRACKCPID].Position, Track.CPTable[(p_nextTRACKCPID + 1) % Track.CPNumber].Position, Track.CPTable[(p_nextTRACKCPID + 2) % Track.CPNumber].Position);

            // Speed
            p_NextPosEstimated.X = p_PosPod.X + p_PosMySpeed.X;
            p_NextPosEstimated.Y = p_PosPod.Y + p_PosMySpeed.Y;
            p_DistMySpeed        = CSBCompute.DistAB(p_PosPod, p_NextPosEstimated);

            // Angles
            p_RadAngleOrgTrack  = CSBCompute.AngleOrienteVecteur(p_PosEastAngleOrigin, p_PosMySpeed, p_PosPod);
            p_RadAngleOrgNextCP = CSBCompute.AngleOrientePos(p_PosEastAngleOrigin, Next3CPRoute.NextCP1, p_PosPod);
            if (FirstExecCycle)
            {
                p_DegAngleOrgHead = (int)(p_RadAngleOrgNextCP / Math.PI * 180); FirstExecCycle = false;
            }
            p_DegAngleHeadNextCP = ((p_RadAngleOrgNextCP / Math.PI * 180) - p_DegAngleOrgHead);
            // Drift Angles
            p_DegAngleTrackNextCP = ((p_RadAngleOrgNextCP - p_RadAngleOrgTrack) / Math.PI * 180 + 360) % 360;
            if (p_DegAngleTrackNextCP > 180)
            {
                p_DegAngleTrackNextCP -= 360;
            }

            // Distances
            p_PrevDistNextCheckPoint = p_DistNextCheckpoint;
            p_DistNextCheckpoint     = CSBCompute.DistAB(p_PosPod, Next3CPRoute.NextCP1);
            p_DistMissingNxtCP       = CSBCompute.ClosestFromNxtCP(p_PrevPosMe, p_PosPod, Next3CPRoute.NextCP1, p_DistNextCheckpoint);
        }