예제 #1
0
 public void KillCar()
 {
     if (captureState)
     {
         // Remove the last 1 second worth of records
         StateInputMeasurements  = StateInputMeasurements.SkipLast(10).ToList();
         StateOutputMeasurements = StateOutputMeasurements.SkipLast(10).ToList();
         SamplesCaptured         = StateInputMeasurements.Count();
     }
 }
예제 #2
0
        public DrivingAction GetOutput(
            float[] rayCollisions,
            Vector2f carPosition,
            float carHeading,
            Vector2f nextCheckpointPosition)
        {
            var output = new DrivingAction();

            if (UseController)
            {
                var update = gameController.OnUpdate();

                output = GetOutputFromUpdate(update);
            }
            else
            {
                if (Keyboard.IsKeyPressed(Keyboard.Key.Up))
                {
                    output.Acceleration = 1;
                }

                if (Keyboard.IsKeyPressed(Keyboard.Key.Down))
                {
                    output.BreakingForce = 1;
                }

                output.LeftTurnForce  = Keyboard.IsKeyPressed(Keyboard.Key.Left) ? 1 : 0;
                output.RightTurnForce = Keyboard.IsKeyPressed(Keyboard.Key.Right) ? 1 : 0;
            }

            if (captureState)
            {
                if (timesinceLastMeasurement > frequencyMs)
                {
                    timesinceLastMeasurement = 0;

                    var outputMeasurement = new float[4];

                    outputMeasurement[0] = output.Acceleration;
                    outputMeasurement[3] = output.BreakingForce;
                    outputMeasurement[1] = output.LeftTurnForce;
                    outputMeasurement[2] = output.RightTurnForce;

                    if (isCapturingInput)
                    {
                        StateInputMeasurements.Add(rayCollisions);
                        StateOutputMeasurements.Add(outputMeasurement);
                        SamplesCaptured++;
                    }
                }
            }

            return(output);
        }
예제 #3
0
 public void ResetCapture()
 {
     StateInputMeasurements.Clear();
     StateOutputMeasurements.Clear();
     SamplesCaptured = 0;
 }