Class Match3Sensor
Sensor for Match3 games. Can generate either vector, compressed visual, or uncompressed visual observations. Uses a GridValueProvider to determine the observation values.
Namespace: Unity.MLAgents.Integrations.Match3
Syntax
public class Match3Sensor : object, ISensor, IBuiltInSensor, IDisposable
Constructors
Match3Sensor(AbstractBoard, GridValueProvider, Int32, Match3ObservationType, String)
Create a sensor for the GridValueProvider with the specified observation type.
Declaration
public Match3Sensor(AbstractBoard board, GridValueProvider gvp, int oneHotSize, Match3ObservationType obsType, string name)
Parameters
Type | Name | Description |
---|---|---|
AbstractBoard | board | The abstract board. |
GridValueProvider | gvp | The GridValueProvider, should be either board.GetCellType or board.GetSpecialType. |
Int32 | oneHotSize | The number of possible values that the GridValueProvider can return. |
Match3ObservationType | obsType | Whether to produce vector or visual observations |
String | name | Name of the sensor. |
Remarks
Use Match3Sensor.CellTypeSensor() or Match3Sensor.SpecialTypeSensor() instead of calling the constructor directly.
Methods
CellTypeSensor(AbstractBoard, Match3ObservationType, String)
Create a sensor that encodes the board cells as observations.
Declaration
public static Match3Sensor CellTypeSensor(AbstractBoard board, Match3ObservationType obsType, string name)
Parameters
Type | Name | Description |
---|---|---|
AbstractBoard | board | The abstract board. |
Match3ObservationType | obsType | Whether to produce vector or visual observations |
String | name | Name of the sensor. |
Returns
Type | Description |
---|---|
Match3Sensor |
Dispose()
Clean up the owned Texture2D.
Declaration
public void Dispose()
GetBuiltInSensorType()
Declaration
public BuiltInSensorType GetBuiltInSensorType()
Returns
Type | Description |
---|---|
BuiltInSensorType |
GetCompressedObservation()
Return a compressed representation of the observation. For small observations, this should generally not be implemented. However, compressing large observations (such as visual results) can significantly improve model training time.
Declaration
public byte[] GetCompressedObservation()
Returns
Type | Description |
---|---|
Byte[] | Compressed observation. |
Implements
GetCompressionSpec()
Return information on the compression type being used. If no compression is used, return Default().
Declaration
public CompressionSpec GetCompressionSpec()
Returns
Type | Description |
---|---|
CompressionSpec | An object describing the compression used by the sensor. |
Implements
GetName()
Get the name of the sensor. This is used to ensure deterministic sorting of the sensors on an Agent, so the naming must be consistent across all sensors and agents.
Declaration
public string GetName()
Returns
Type | Description |
---|---|
String | The name of the sensor. |
Implements
GetObservationSpec()
Returns a description of the observations that will be generated by the sensor. See ObservationSpec for more details, and helper methods to create one.
Declaration
public ObservationSpec GetObservationSpec()
Returns
Type | Description |
---|---|
ObservationSpec | An object describing the observation. |
Implements
Reset()
Resets the internal state of the sensor. This is called at the end of an Agent's episode. Most implementations can leave this empty.
Declaration
public void Reset()
Implements
SpecialTypeSensor(AbstractBoard, Match3ObservationType, String)
Create a sensor that encodes the cell special types as observations. Returns null if the board's NumSpecialTypes is 0 (indicating the sensor isn't needed).
Declaration
public static Match3Sensor SpecialTypeSensor(AbstractBoard board, Match3ObservationType obsType, string name)
Parameters
Type | Name | Description |
---|---|---|
AbstractBoard | board | The abstract board. |
Match3ObservationType | obsType | Whether to produce vector or visual observations |
String | name | Name of the sensor. |
Returns
Type | Description |
---|---|
Match3Sensor |
Update()
Update any internal state of the sensor. This is called once per each agent step.
Declaration
public void Update()
Implements
Write(ObservationWriter)
Write the observation data directly to the ObservationWriter. Note that this (and GetCompressedObservation()) may be called multiple times per agent step, so should not mutate any internal state.
Declaration
public int Write(ObservationWriter writer)
Parameters
Type | Name | Description |
---|---|---|
ObservationWriter | writer | Where the observations will be written to. |
Returns
Type | Description |
---|---|
Int32 | The number of elements written. |