Unity3D ML-Agents Hummingbird Notes

Software tutorials of interest.
Post Reply
Message
Author
jstenner
Site Admin
Posts: 87
Joined: Wed Jan 27, 2010 7:33 pm

Unity3D ML-Agents Hummingbird Notes

#1 Post by jstenner »

My Notes on modifications to the Unity3D Hummingbird Tutorial

So the key issue with The Hummingbird Tutorial is that it's written for ML-Agents.1.0. There are some key changes that have to be made.

Really helpful in migrating the code to ML-Agents 2+
https://www.immersivelimit.com/tutorial ... -for-unity
https://www.immersivelimit.com/tutorial ... -ml-agents

In particular, the conversion of Heuristic and OnActionReceived functions which transitioned to ActionBuffers in HummingbirdAgent.cs.

I also had to upgrade the trainer_config.yaml file to the newest format for v2.0. I found on the Unity forum that a python script to automatcially migrates previous configs is provided:
https://forum.unity.com/threads/trainer ... id.912671/

https://github.com/Unity-Technologies/ml-agents

These are specific to my setup on my home workstation/drives:
  • Here's what I ran with my mlagents_env virtual environment active. I'm not sure if this works properly independent of venv.
    python -m mlagents.trainers.upgrade_config /Volumes/T3/Unity/ml-agents/config/hummingbird/trainer_config.yaml /Volumes/T3/Unity/ml-agents/config/hummingbird/hummingbird_new.yaml

    As opposed to the tutorial that uses Anaconda on a PC for venv, I'm using venv and running my training from inside the cloned ml-agents directory on T3.
    mlagents-learn config/hummingbird/hummingbird_new.yaml --run-id=hummingbird
Last but not least, the Hummingbird Tutorial ends with a new Unity scene set up for a game between the AI and a player. There is an error in FlowerArea.cs that keeps it from compiling or playing. The MoveToSafeRandomPosition() function call needs to be moved from the Start() function to the Awake() function or else it returns a negative number, causing an index error.

After those changes, ALL GOOD!
The master of disaster!

Post Reply