-1

I am brand new to unity and ml-agents and i am working on a project based on https://towardsdatascience.com/ultimate-volleyball-a-3d-volleyball-environment-built-using-unity-ml-agents-c9d3213f3064. (https://github.com/CoderOneHQ/ultimate-volleyball)

The objective i have is to extend the game from a 1v1 to a 2v2 game. What i was initially thinking was to add another agent and add some new observations to each agent with raycast, so that they can be aware of eachother. ( The observations that are currently used is the following 11:

  • Agent’s y-rotation (i.e. whether the Agent is facing left/right) [1]
  • Agent’s x,y,z-velocity [3]
  • Agent’s x,y,z-normalized vector to the ball (i.e. direction to the ball) [3]
  • Ball’s x,y,z-velocity [3]

Then i plan to alter the reward system so that they no longer receive points for only hitting the ball over the net, but also for passing once before shooting the ball over the net.

I started with copying the game object of each agent in the hierarchy and just duplicating the characters and giving them different names. This worked without modifying the code, but still after training them, they both charge towards the ball very aggressively instead of cooperating (which is why i need more observations).

Because of this i have a question:

  • Is it possible to use ray perception sensor 3D when i already have vector observations? if so, how can i modify the code to include it and be able to observe the teamplayer

[enter image description here]

I tried adding a ray perception sensor 3D component, but the error i got was:

Number of Sensors must match. 1 != 2

Sensor shapes must match. [11] != [14] UnityEngine.Debug:AssertFormat (bool,string,object[]) Unity.MLAgents.Sensors.SensorShapeValidator:ValidateSensors (System.Collections.Generic.List1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Sensors/SensorShapeValidator.cs:43) Unity.MLAgents.Inference.ModelRunner:PutObservations (Unity.MLAgents.AgentInfo,System.Collections.Generic.List1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Inference/ModelRunner.cs:160) Unity.MLAgents.Policies.BarracudaPolicy:RequestDecision (Unity.MLAgents.AgentInfo,System.Collections.Generic.List`1<Unity.MLAgents.Sensors.ISensor>) (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Policies/BarracudaPolicy.cs:96) Unity.MLAgents.Agent:NotifyAgentDone (Unity.MLAgents.Agent/DoneReason) (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Agent.cs:573) Unity.MLAgents.Agent:EndEpisodeAndReset (Unity.MLAgents.Agent/DoneReason) (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Agent.cs:794) Unity.MLAgents.Agent:EndEpisode () (at Library/PackageCache/com.unity.ml-agents@2.1.0-exp.1/Runtime/Agent.cs:769) VolleyballEnvController:ResolveEvent (Event) (at Assets/Scripts/VolleyballEnvController.cs:122) VolleyballController:OnTriggerEnter (UnityEngine.Collider) (at Assets/Scripts/VolleyballController.cs:48)

I am pretty new to this and i imagine that i have to edit the code to include the observations, but i have no idea of how to do it. Can anyone help me?

  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 18 '23 at 08:19

0 Answers0