I want to train a game that requires user login. Currently, I hard-code the login to use the training account. Each player can only be logged in once, therefore using the --num-envs=x parameter for training will still result in only one environment actually training. Is there a way to access the ID of the current environment, so that I can use different logins for each separate environment? I want to be able to say
playerName = $"player{envId};
Is there a way to do that?
I looked into the Academy and Communicator implementations and did not find anything useful.
I found a way to do it: When starting the training with e.g. --num-envs=4
, each environment will be launched on its own mlagents-port
, starting with port 5005. The port will be passed as a commandline argument to the Unity process. Printing the processes with ps aux
will show this:
ML Processes
In the Unity code, the port can then be fetched via the System.Environment.GetCommandLineArgs()
and used to determine the player name.