|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
foreach (BrainType bt in System.Enum.GetValues(typeof(BrainType))) |
|
|
|
{ |
|
|
|
if ((int)bt >= CoreBrains.Length) |
|
|
|
break; |
|
|
|
if (CoreBrains[(int)bt] == null) |
|
|
|
{ |
|
|
|
CoreBrains[(int)bt] = ScriptableObject.CreateInstance("CoreBrain" + bt.ToString()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// If the length of CoreBrains does not match the number of BrainTypes,
|
|
|
|
// we increase the length of CoreBrains
|
|
|
|
|
|
|
foreach (KeyValuePair<int, Agent> idAgent in agents) |
|
|
|
{ |
|
|
|
List<float> states = idAgent.Value.CollectState(); |
|
|
|
if ((states.Count != brainParameters.stateSize) && (brainParameters.stateSpaceType == StateType.continuous )) |
|
|
|
if ((states.Count != brainParameters.stateSize) && (brainParameters.stateSpaceType == StateType.continuous)) |
|
|
|
if ((states.Count != 1) && (brainParameters.stateSpaceType == StateType.discrete )) |
|
|
|
if ((states.Count != 1) && (brainParameters.stateSpaceType == StateType.discrete)) |
|
|
|
{ |
|
|
|
throw new UnityAgentsException(string.Format(@"The number of states does not match for agent {0}:
|
|
|
|
Was expecting 1 discrete states but received {1}.", idAgent.Value.gameObject.name, states.Count));
|
|
|
|