using System;
using UnityEngine;
namespace MLAgents.Policies
{
///
/// Whether the action space is discrete or continuous.
///
public enum SpaceType
{
///
/// Discrete action space: a fixed number of options are available.
///
Discrete,
///
/// Continuous action space: each action can take on a float value.
///
Continuous
}
///
/// Holds information about the Brain. It defines what are the inputs and outputs of the
/// decision process.
///
[Serializable]
public class BrainParameters
{
///
/// If continuous : The length of the float vector that represents the state.
/// If discrete : The number of possible values the state can take.
///
public int vectorObservationSize = 1;
///
/// Stacking refers to concatenating the observations across multiple frames. This field
/// indicates the number of frames to concatenate across.
///
[Range(1, 50)] public int numStackedVectorObservations = 1;
///
/// If continuous : The length of the float vector that represents the action.
/// If discrete : The number of possible values the action can take.
///
public int[] vectorActionSize = new[] {1};
///
/// The list of strings describing what the actions correspond to.
///
public string[] vectorActionDescriptions;
///
/// Defines if the action is discrete or continuous.
///
public SpaceType vectorActionSpaceType = SpaceType.Discrete;
public int numActions
{
get
{
switch (vectorActionSpaceType)
{
case SpaceType.Discrete:
return vectorActionSize.Length;
case SpaceType.Continuous:
return vectorActionSize[0];
default:
return 0;
}
}
}
///
/// Deep clones the BrainParameter object.
///
/// A new BrainParameter object with the same values as the original.
public BrainParameters Clone()
{
return new BrainParameters
{
vectorObservationSize = vectorObservationSize,
numStackedVectorObservations = numStackedVectorObservations,
vectorActionSize = (int[])vectorActionSize.Clone(),
vectorActionDescriptions = (string[])vectorActionDescriptions.Clone(),
vectorActionSpaceType = vectorActionSpaceType
};
}
}
}