コード例 #1
0
    private void Update()
    {
        //Gas
        if (Input.GetKey(KeyCode.UpArrow))
        {
            controller.Accelerate(1.0f);
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            controller.Brake();
        }
        else
        {
            controller.Accelerate(0.0f);
        }

        //Steer
        float steer = 0.0f;

        if (Input.GetKey(KeyCode.LeftArrow))
        {
            steer = -1.0f;
        }
        else if (Input.GetKey(KeyCode.RightArrow))
        {
            steer = 1.0f;
        }
        controller.Steer(steer);
    }
コード例 #2
0
    private void Update()
    {
        if (is_activated)
        {
            if (actions[action_index][0] == -1)
            {
                car_controller.Accelerate(0);
                car_controller.Brake();
            }
            else
            {
                car_controller.Accelerate(actions[action_index][0]);
            }
            car_controller.Steer(actions[action_index][1]);
        }

        string full_log = "";

        full_log += "Last Reward Recived: " + current_reward + "\n";
        full_log += "Epsilon: " + epsilon + "\n";
        full_log += "Actions Q Value: \n";
        for (int i = 0; i < actions.Length; i++)
        {
            full_log += "       " + actions_name[i] + ": " + last_q_values[i] + "\n";
        }
        //Log
        for (int i = 0; i < log.Count; i++)
        {
            full_log += ">>" + log[i] + "\n";
        }
        text_log.text = full_log;
    }
コード例 #3
0
ファイル: Vehicle.cs プロジェクト: RaidPRDev/3d_racing_unity
    private void FixedUpdate()
    {
        float handbrake = 0.0f;

        PersistentModel.Instance.CarSpeed = carController.CurrentSpeed;

        // pass the input to the car!
        float h = CrossPlatformInputManager.GetAxis("Horizontal") * .5f;
        float v = CrossPlatformInputManager.GetAxis("Vertical");

        if (stop)
        {
            // carController.StartSkidTrail();
            carController.Brake(h, true);
            return;
        }

        if (!CanMove)
        {
            if (v > 0)
            {
                // carAudio.useDoppler = true;
                carController.UpdateMove(v);
            }
            return;
        }

        #if !MOBILE_INPUT
        // if (CanMove) v = 1; //try this later...
        carController.Move(h, v, v, handbrake);
        #else
        carController.Move(h, v, v, 0f);
        #endif
    }
コード例 #4
0
    private void Update()
    {
        if (!abort_learning)
        {
            if (actions[action_index][0] == -1)
            {
                car_controller.Accelerate(0);
                car_controller.Brake();
            }
            else
            {
                car_controller.Accelerate(actions[action_index][0]);
            }
            car_controller.Steer(actions[action_index][1]);

            if (text_log != null)
            {
                string full_log = "";
                full_log += "Working Particle: " + working_particle + "\n";
                full_log += "Current Reward: " + current_reward + "\n";
                full_log += "Best Score: " + particle_swarm.GetBestScore() + "\n";
                full_log += "Actions Q Value: \n";
                for (int i = 0; i < actions.Length; i++)
                {
                    full_log += "       " + actions_name[i] + ": " + last_q_values[i] + "\n";
                }
                text_log.text = full_log;
            }
        }
    }
コード例 #5
0
ファイル: CarAI.cs プロジェクト: EllieGoyer/Black-Ice-Racing
 private void Braking()
 {
     if (isBraking)
     {
         controller.throttleInput = -1;
         controller.Brake(controller.backLeftW, controller.backRightW);
     }
     else
     {
         controller.backLeftW.brakeTorque  = 0;
         controller.backRightW.brakeTorque = 0;
     }
 }
コード例 #6
0
    private void Update()
    {
        if (activate_car)
        {
            float[] network_inputs  = car_camera.GetRays();
            float[] network_outputs = network.Compute(network_inputs);

            int   action_index = ChoseAction(network_outputs);
            float accel        = actions[action_index][0];
            float steer        = actions[action_index][1];

            controller.Accelerate(accel);
            if (accel == -1)
            {
                controller.Brake();
            }

            controller.Steer(steer);
        }
    }
コード例 #7
0
 public void Brake()
 {
     carController.Brake();
 }