|
|
|
|
|
|
using System; |
|
|
|
using Unity.MLAgents.Sensors; |
|
|
|
using UnityEngine; |
|
|
|
using UnityEngine.Serialization; |
|
|
|
|
|
|
|
namespace Unity.MLAgents.Integrations.Match3 |
|
|
|
{ |
|
|
|
|
|
|
[AddComponentMenu("ML Agents/Match 3 Sensor", (int)MenuGroup.Sensors)] |
|
|
|
public class Match3SensorComponent : SensorComponent, IDisposable |
|
|
|
{ |
|
|
|
[HideInInspector, SerializeField, FormerlySerializedAs("SensorName")] |
|
|
|
string m_SensorName = "Match3 Sensor"; |
|
|
|
|
|
|
|
public string SensorName = "Match3 Sensor"; |
|
|
|
public string SensorName |
|
|
|
{ |
|
|
|
get => m_SensorName; |
|
|
|
set => m_SensorName = value; |
|
|
|
} |
|
|
|
|
|
|
|
[HideInInspector, SerializeField, FormerlySerializedAs("ObservationType")] |
|
|
|
Match3ObservationType m_ObservationType = Match3ObservationType.Vector; |
|
|
|
public Match3ObservationType ObservationType = Match3ObservationType.Vector; |
|
|
|
public Match3ObservationType ObservationType |
|
|
|
{ |
|
|
|
get => m_ObservationType; |
|
|
|
set => m_ObservationType = value; |
|
|
|
} |
|
|
|
|
|
|
|
private ISensor[] m_Sensors; |
|
|
|
|
|
|
|
|
|
|
Dispose(); |
|
|
|
|
|
|
|
var board = GetComponent<AbstractBoard>(); |
|
|
|
var cellSensor = Match3Sensor.CellTypeSensor(board, ObservationType, SensorName + " (cells)"); |
|
|
|
var cellSensor = Match3Sensor.CellTypeSensor(board, m_ObservationType, m_SensorName + " (cells)"); |
|
|
|
var specialSensor = Match3Sensor.SpecialTypeSensor(board, ObservationType, SensorName + " (special)"); |
|
|
|
var specialSensor = Match3Sensor.SpecialTypeSensor(board, m_ObservationType, m_SensorName + " (special)"); |
|
|
|
m_Sensors = specialSensor != null |
|
|
|
? new ISensor[] { cellSensor, specialSensor } |
|
|
|
: new ISensor[] { cellSensor }; |
|
|
|