66
77namespace Unity . AI . MLAgents
88{
9+ internal enum WorldProcessorType
10+ {
11+ Default ,
12+ InferenceOnly ,
13+ None
14+ }
15+
916 [ Serializable ]
1017 public struct MLAgentsWorldSpecs
1118 {
1219 [ SerializeField ] internal string Name ;
1320
14- [ SerializeField ] public int NumberAgents ;
15- [ SerializeField ] public ActionType ActionType ;
16- [ SerializeField ] public int3 [ ] ObservationShapes ;
17- [ SerializeField ] public int ActionSize ;
18- [ SerializeField ] public int [ ] DiscreteActionBranches ;
21+ [ SerializeField ] internal WorldProcessorType WorldProcessorType ;
22+
23+ [ SerializeField ] internal int NumberAgents ;
24+ [ SerializeField ] internal ActionType ActionType ;
25+ [ SerializeField ] internal int3 [ ] ObservationShapes ;
26+ [ SerializeField ] internal int ActionSize ;
27+ [ SerializeField ] internal int [ ] DiscreteActionBranches ;
1928
20- [ SerializeField ] public NNModel Model ;
21- [ SerializeField ] public InferenceDevice InferenceDevice ;
29+ [ SerializeField ] internal NNModel Model ;
30+ [ SerializeField ] internal InferenceDevice InferenceDevice ;
2231
2332 private MLAgentsWorld m_World ;
2433
@@ -35,7 +44,25 @@ public MLAgentsWorld GetWorld()
3544 ActionSize ,
3645 DiscreteActionBranches
3746 ) ;
38- m_World . RegisterWorldWithBarracudaModel ( Name , Model , InferenceDevice ) ;
47+ switch ( WorldProcessorType )
48+ {
49+ case WorldProcessorType . Default :
50+ m_World . RegisterWorldWithBarracudaModel ( Name , Model , InferenceDevice ) ;
51+ break ;
52+ case WorldProcessorType . InferenceOnly :
53+ if ( Model == null )
54+ {
55+ throw new MLAgentsException ( $ "No model specified for { Name } ") ;
56+ }
57+ m_World . RegisterWorldWithBarracudaModelForceNoCommunication ( Name , Model , InferenceDevice ) ;
58+ break ;
59+ case WorldProcessorType . None :
60+ Academy . Instance . RegisterWorld ( Name , m_World , new NullWorldProcessor ( m_World ) , false ) ;
61+ break ;
62+ default :
63+ throw new MLAgentsException ( $ "Unknown WorldProcessor Type") ;
64+ }
65+
3966 return m_World ;
4067 }
4168 }
0 commit comments