Can you change an Agent's public field at runtime through Python API?

Let’s say I have an Agent like so:

public class MyAgent : Agent {
    public int numEnemies;
    public int numGoals;
    ...
}

Right now what I can do is change the value of numEnemies and numGoals through the Unity interface, build the project and re-run with my Python code. This works, but seems terribly inefficient.

Is there a way to control those two variable through the Python API at runtime so I can just do something like:
env = UnityEnvironment(filename=“myApp.exe”)
env.numEnemies = 10
env.numGoals = 5
env.reset()

Taking a look at custom side channels, it seems like that might be what I want, but I’m not entirely sure.

There is way to configure environment parameters in Python during training, please see this doc.
Does that work for your case?

1 Like

I thought things like
Academy.Instance.EnvironmentParameters.GetWithDefault("my_environment_parameter", 0.0f);
only worked if I set the filename=None and ran it within the Unity environment. I would like to run this with a built binary and not through the Unity interface if possible.

Okay, so I misunderstood the documentation the first time. You CAN in fact set and reference through prebuilt binaries using GetWithDefault.