Issues in setting up unity ml-agents for a custom unity environment

Hey Guys,

I know this is a pretty noob question. But how do i set up Unity ML agents with Python .
Here are the steps i followed .

1.) Created Unity Project and imported all C# scripts from ML-agents folder
2.) Created Academy and Brain object and added scripts accordingly.
3.) Created agent script as follows

	public override void AgentStep(float[] actions)
	{
		if(brain.brainParameters.actionSpaceType == StateType.continuous )
		{
			driverHelper.Accelarate = actions [0];
			driverHelper.Steering = actions [1];
			driverHelper.Brake = actions[2];

			for (int i = 0; i < sensorHolder.sensors.Count; ++i)
				if (sensorHolder.sensors *.ReturnedDistance <= 2f) {*
  •  			done = true;*
    
  •  			reward = -1f;*
    
  •  		} else {*
    

if (done == false)

  •  				reward = 0.1f;*
    
  •  		}*
    
  •  }*
    
  • }*

  • public override List CollectState()*

  • {*

  •  List<float> State = new List<float> ();*
    
  •  for(int i=0; i < sensorHolder.sensors.Count;++i)*
    

_ State.Add (sensorHolder.sensors*.ReturnedDistance);*_

* return State;*
* }*
Everything works finely till now. even tested out with player mode in Brain Script
But How can i connect this with my python ML code
When ever i try to execute the following command from the ml-agents directory
python python/learn.py “testcar” --train
I get the following errors
unityagents.exception.UnityEnvironmentException: Couldn’t launch the testcar environment. Provided filename does not match any environments.
And in Game error
[113027-sc2.jpg|113027]_
_

Could anyone be kind enough to tell me how i can fix this and any pointers on How to send signals via python to Unity is appreciated.
Thanks
Regards

@puneets2811

I believe your “testcar” is in python directory. Try this:

python python/learn.py python/testcar --train

Hey! @puneets2811, can you write physics on python in unity without c# and other languages? P.S. Sorry I know this is a more pretty noob question :slight_smile: P.P.S. Sorry for my eng.