Hi!
I'm trying to beat the "Making a New Learning Environment" tutorial, but Unity is giving me trouble with overridden methods in the RollerAgent script.
"`RollerAgent.CollectObservations()' is marked as an override but no suitable method found to override"
It should be overridden as it stands in the tutorial, and I've got no idea whats wrong, aside from assuming something isn't properly installed.
`
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RollerAgent : Agent {
public Transform target;
Rigidbody rBodie;
public float speed = 10;
private float previousDistance = float.MaxValue;
List<float> observation = new List<float>();
// Use this for initialization
void Start () {
rBodie = GetComponent<Rigidbody>();
}
public override void CollectObservations() {
// Calculate relative position
Vector3 relativePosition = target.position - this.transform.position;
// Relative position
AddVectorObs(relativePosition.x/5);
AddVectorObs(relativePosition.z/5);
// Distance to edges of platform
AddVectorObs((this.transform.position.x + 5)/5);
AddVectorObs((this.transform.position.x - 5)/5);
AddVectorObs((this.transform.position.z + 5)/5);
AddVectorObs((this.transform.position.z - 5)/5);
// Agent velocity
AddVectorObs(rBodie.velocity.x/5);
AddVectorObs(rBodie.velocity.z/5);
}
public override void AgentAction(float[] vectorAction, string textAction) {
// Actions, size = 2
Vector3 controlSignal = Vector3.zero;
controlSignal.x = Mathf.Clamp(vectorAction[0], -1, 1);
controlSignal.z = Mathf.Clamp(vectorAction[1], -1, 1);
rBodie.AddForce(controlSignal * speed);
float distanceToTarget = Vector3.Distance(this.transform.position,
target.position);
// Reached target
if (distanceToTarget < 1.42f)
{
Done();
AddReward(1.0f);
}
// Getting closer
if (distanceToTarget < previousDistance)
{
AddReward(0.1f);
} else {
AddReward(-0.1f);
}
// Time penalty
AddReward(-0.05f);
// Fell off platform
if (this.transform.position.y < -1.0)
{
Done();
AddReward(-1.0f);
}
previousDistance = distanceToTarget;
}
public override void AgentReset() {
if (this.transform.position.y < -1.0) {
this.transform.position = Vector3.zero;
this.rBodie.angularVelocity = Vector3.zero;
this.rBodie.velocity = Vector3.zero;
} else {
target.position = new Vector3(Random.value * 8 - 4,
0.5f,
Random.value * 8 - 4);
}
}
}`
The most likely cause is that you are using the 0.2 version of ML-Agents instead of the 0.3 version. That function changed name between those releases. The master branch has the latest, 0.3 code.
Hey, so I redownloaded the MLAgents and tried to recreate the tut project anew, but now I'm getting the following error:
"Assets/ML-Agents/Scripts/ExternalCommunicator.cs(259,24): error CS1061: Type System.Text.StringBuilder' does not contain a definition forClear' and no extension method Clear' of typeSystem.Text.StringBuilder' could be found. Are you missing an assembly reference?"
Go to your Player Settings (menu: Edit Project Settings Player).
Under Other Settings, set Scripting Runtime Version to "Experimental (.NET 4.6 Equivalent)".
While you are there, add "ENABLE_TENSORFLOW" to the "Scripting Define Symbols" a couple of settings further down.
It is a little buried, but instructions for these settings are covered here:
https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Getting-Started-with-Balance-Ball.md#embedding-the-trained-brain-into-the-unity-environment-experimental
Damn, I totally forgot to set these again as well. Thanks, all issues cleared.
Glad to hear it.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Go to your Player Settings (menu: Edit Project Settings Player).
Under Other Settings, set Scripting Runtime Version to "Experimental (.NET 4.6 Equivalent)".
While you are there, add "ENABLE_TENSORFLOW" to the "Scripting Define Symbols" a couple of settings further down.