From 0b9d3b49508712dfd035215179ac8fdb11a182b5 Mon Sep 17 00:00:00 2001 From: Ciakon Date: Fri, 12 Apr 2024 12:10:24 +0200 Subject: [PATCH] bensons gets mental pain from existing --- Assets/Scripts/AgentController.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Assets/Scripts/AgentController.cs b/Assets/Scripts/AgentController.cs index 76c509e..b7822ff 100644 --- a/Assets/Scripts/AgentController.cs +++ b/Assets/Scripts/AgentController.cs @@ -126,11 +126,16 @@ public class AgentController : Agent if (actions.DiscreteActions[1] == 1) hInput = 1f; + // reward for going forward + if (vInput == 1f) { AddReward(0.001f); } + // give benson mental pain for existing (punishment for maximizing first checkpoint by standing still) + AddReward(-0.002f); + float forwardSpeed = Vector3.Dot(transform.forward, rigidBody.velocity); @@ -269,10 +274,19 @@ public class AgentController : Agent return distanceToCheckpoint; } + // punishment for hitting a wall + private void OnCollisionEnter(Collision other) { + if (other.gameObject.tag == "Wall") + { + AddReward(-0.05f); + } + } + + // punishment for staying at a wall private void OnCollisionStay(Collision other) { if (other.gameObject.tag == "Wall") { - AddReward(-0.01f); + AddReward(-0.005f); } } } \ No newline at end of file