Пример #1
0
        private LanderData GetLanderDataFromString(string input)
        {
            var inputs = input.Split(' ');

            var data = new LanderData()
            {
                X        = int.Parse(inputs[0]),
                Y        = int.Parse(inputs[1]),
                HSpeed   = int.Parse(inputs[2]),             // the horizontal speed (in m/s), can be negative.
                VSpeed   = int.Parse(inputs[3]),             // the vertical speed (in m/s), can be negative.
                Fuel     = int.Parse(inputs[4]),             // the quantity of remaining fuel in liters.
                Rotation = int.Parse(inputs[5]),             // the rotation angle in degrees (-90 to 90).
                Power    = int.Parse(inputs[6])              // the thrust power (0 to 4).
            };

            Log($"Ship data: {data}");
            return(data);
        }
Пример #2
0
        public override void Run()
        {
            var mapPos = GetMapPoints();

            Log($"Got {mapPos.Count} map positions");

            LanderData       landerData = null;
            LanderConditions conditions = null;

            // game loop
            while (true)
            {
                landerData = GetLanderDataFromString(ReadLine());
                conditions = new LanderConditions(landerData);
                //We can take the height into consideration to see when we need to power up again, but for now simple dumb landing pattern
                int powerPerc = conditions.VSpeed ? 0 : 4;                 //If our Vspeed is okay we disable truster, otherwise we start it back up
                WriteLine(GetAction(0, powerPerc));
            }
        }
Пример #3
0
 public LanderConditions(LanderData data)
 {
     Angle  = data.Rotation == 0;            //Needs to be in upright position
     VSpeed = Math.Abs(data.VSpeed) <= 15;   //20 is max, 15 is safe
     HSpeed = Math.Abs(data.HSpeed) <= 15;   //20 is max, 15 is safe
 }