diff --git a/docs/Learning-Environment-Create-New.md b/docs/Learning-Environment-Create-New.md index 867e8890805..4316984fdba 100644 --- a/docs/Learning-Environment-Create-New.md +++ b/docs/Learning-Environment-Create-New.md @@ -231,8 +231,8 @@ calculate an analytical solution to the problem. In our case, the information our Agent collects includes the position of the target, the position of the agent itself, and the velocity of the agent. This helps the Agent learn to control its speed so it doesn't overshoot the target -and roll off the platform. In total, the agent observation contains 8 values as -implemented below: +and roll off the platform. In total, the agent observation contains 8 values +asimplemented below: ```csharp public override void CollectObservations(VectorSensor sensor) @@ -260,14 +260,18 @@ the first determines the force applied along the x-axis; and the second determines the force applied along the z-axis. (If we allowed the Agent to move in three dimensions, then we would need a third action.) -The RollerAgent applies the values from the `action[]` array to its Rigidbody +The RollerAgent applies the values from the `actionBuffers.ContinuousActions[]` array to its Rigidbody component `rBody`, using `Rigidbody.AddForce()`: ```csharp -Vector3 controlSignal = Vector3.zero; -controlSignal.x = action[0]; -controlSignal.z = action[1]; -rBody.AddForce(controlSignal * forceMultiplier); +public override void OnActionReceived(ActionBuffers actionBuffers) +{ + float[] continuousActions = actionBuffers.ContinuousActions; + Vector3 controlSignal = Vector3.zero; + controlSignal.x = continuousActions[0]; + controlSignal.z = continuousActions[1]; + rBody.AddForce(controlSignal * forceMultiplier); +} ``` #### Rewards @@ -315,9 +319,10 @@ public float forceMultiplier = 10; public override void OnActionReceived(ActionBuffers actionBuffers) { // Actions, size = 2 + float[] continuousActions = actionBuffers.ContinuousActions; Vector3 controlSignal = Vector3.zero; - controlSignal.x = actionBuffers.ContinuousActions[0]; - controlSignal.z = actionBuffers.ContinuousActions[1]; + controlSignal.x = continuousActions[0]; + controlSignal.z = continuousActions[1]; rBody.AddForce(controlSignal * forceMultiplier); // Rewards @@ -434,6 +439,8 @@ behaviors: Hyperparameters are explained in [the training configuration file documentation](Training-Configuration-File.md) +Make sure the Behaviour name in the `Bahaviour Parameters` component matches the one in the config file. + Since this example creates a very simple training environment with only a few inputs and outputs, using small batch and buffer sizes speeds up the training considerably. However, if you add more complexity to the environment or change