示例#1
0
        public RunnerModel(string Name, float Distance, RaceModel race)
        {
            this.Name = Name;
            Race      = race ?? new RaceModel();

            int CeilLapsCount = (int)Math.Ceiling(Distance / Race.LapLength);

            if (SettingsModel.FirstLapAlwaysFull)
            {
                var LastLapLength = Distance % Race.LapLength == 0 ? Race.LapLength : Distance % Race.LapLength;
                for (float i = 1; i < CeilLapsCount; ++i)
                {
                    CheckPoints.Add(Race.LapLength);
                }
                CheckPoints.Add(LastLapLength);
            }
            else
            {
                var FirstLapLength = (Distance % Race.LapLength == 0) ? Race.LapLength : Distance % Race.LapLength;
                CheckPoints.Add(FirstLapLength);
                for (float i = 1; i < CeilLapsCount; ++i)
                {
                    CheckPoints.Add(Race.LapLength);
                }
            }
        }
示例#2
0
文件: LogFat.cs 项目: vplauzon/cosbak
        public void CreateCheckPoint(
            long timeStamp,
            IImmutableList <Block>?idsBlocks,
            IImmutableList <Block>?sprocsBlocks,
            IImmutableList <Block>?functionsBlocks,
            IImmutableList <Block>?triggersBlocks)
        {
            var checkpoint = new LogCheckPoint
            {
                TimeStamp       = timeStamp,
                DocumentBatches = InProgressDocumentBatches,
                IdsBlocks       = idsBlocks,
                SprocsBlocks    = sprocsBlocks,
                FunctionsBlocks = functionsBlocks,
                TriggersBlocks  = triggersBlocks
            };

            CheckPoints = CheckPoints.Add(checkpoint);
            InProgressDocumentBatches = InProgressDocumentBatches.Clear();
        }
示例#3
0
    static void Main(string[] args)
    {
        int[] inputs;
        var   pods        = Enumerable.Range(0, 4).Select(x => new Pod()).ToArray();
        var   checkPoints = new CheckPoints();

        var laps            = ReadInts()[0];
        var checkPointCount = ReadInts()[0];

        for (var i = 0; i < checkPointCount; i++)
        {
            inputs = ReadInts();
            checkPoints.Add(inputs[0], inputs[1]);
        }

        while (true)
        {
            for (var i = 0; i < 4; i++)
            {
                inputs = ReadInts();

                pods[i].Point = new Vector(inputs[0], inputs[1]);
                pods[i].Speed = new Vector(inputs[2], inputs[3]);
                pods[i].Angle = inputs[4];
                var nextCheckPoint = checkPoints.Get(inputs[5]);
                if (nextCheckPoint != pods[i].NextCheckPoint)
                {
                    pods[i].NextCheckPoint = nextCheckPoint;
                    pods[i].Checked++;
                }
            }

            for (var i = 0; i < 2; i++)
            {
                var v          = pods[i].NextCheckPoint - pods[i].Point;
                var speedAngle = pods[i].Speed.DiffAngle(v);

                var thrust = "100";

                var target = new Vector(pods[i].NextCheckPoint);
                if (Math.Abs(speedAngle) < 90)
                {
                    RotatePoint(target, pods[i].Point, speedAngle);
                }
                else
                {
                    var nextCheckpointAngle = pods[i].DiffSteerAngle(pods[i].NextCheckPoint);
                    var dist = pods[i].Point.GetDistance(pods[i].NextCheckPoint);
                    D(nextCheckpointAngle, dist);

                    if (dist < 1000 && Math.Abs(nextCheckpointAngle) > 45)
                    {
                        thrust = "0";
                    }
                }

                if (!pods[0].BoostUsed)
                {
                    pods[0].BoostUsed = true;
                    thrust            = "BOOST";
                }

                Console.WriteLine($"{target.X} {target.Y} {thrust}");
            }
        }
    }