File tree Expand file tree Collapse file tree 2 files changed +36
-8
lines changed
com.unity.ml-agents/Runtime Expand file tree Collapse file tree 2 files changed +36
-8
lines changed Original file line number Diff line number Diff line change @@ -363,6 +363,22 @@ public void GiveModel(
363
363
m_Brain = m_PolicyFactory . GeneratePolicy ( Heuristic ) ;
364
364
}
365
365
366
+ /// <summary>
367
+ /// Updates the type of behavior for the agent.
368
+ /// </summary>
369
+ /// <param name="behaviorType"> The new behaviorType for the Agent
370
+ /// </param>
371
+ public void SetBehaviorType ( BehaviorType behaviorType )
372
+ {
373
+ if ( m_PolicyFactory . m_BehaviorType == behaviorType )
374
+ {
375
+ return ;
376
+ }
377
+ m_PolicyFactory . m_BehaviorType = behaviorType ;
378
+ m_Brain ? . Dispose ( ) ;
379
+ m_Brain = m_PolicyFactory . GeneratePolicy ( Heuristic ) ;
380
+ }
381
+
366
382
/// <summary>
367
383
/// Returns the current step counter (within the current episode).
368
384
/// </summary>
Original file line number Diff line number Diff line change 5
5
6
6
namespace MLAgents . Policies
7
7
{
8
+
9
+ /// <summary>
10
+ /// Defines what type of behavior the Agent will be using
11
+ /// - Default : The Agent will use the remote process for decision making.
12
+ /// if unavailable, will use inference and if no model is provided, will use
13
+ /// the heuristic.
14
+ /// - HeuristicOnly : The Agent will always use its heuristic
15
+ /// - InferenceOnly : The Agent will always use inference with the provided
16
+ /// neural network model.
17
+ /// </summary>
18
+ [ Serializable ]
19
+ public enum BehaviorType
20
+ {
21
+ Default ,
22
+ HeuristicOnly ,
23
+ InferenceOnly
24
+ }
25
+
26
+
8
27
/// <summary>
9
28
/// The Factory to generate policies.
10
29
/// </summary>
11
30
[ AddComponentMenu ( "ML Agents/Behavior Parameters" , ( int ) MenuGroup . Default ) ]
12
31
internal class BehaviorParameters : MonoBehaviour
13
32
{
14
- [ Serializable ]
15
- enum BehaviorType
16
- {
17
- Default ,
18
- HeuristicOnly ,
19
- InferenceOnly
20
- }
21
33
22
34
[ HideInInspector ]
23
35
[ SerializeField ]
@@ -36,7 +48,7 @@ enum BehaviorType
36
48
// and will always have its default value
37
49
// This field is set in the custom editor.
38
50
#pragma warning disable 0649
39
- BehaviorType m_BehaviorType ;
51
+ internal BehaviorType m_BehaviorType ;
40
52
#pragma warning restore 0649
41
53
[ HideInInspector ]
42
54
[ SerializeField ]
You can’t perform that action at this time.
0 commit comments