您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
41 行
1.3 KiB
41 行
1.3 KiB
using Unity.MLAgents.Sensors;
|
|
using UnityEngine;
|
|
|
|
namespace Unity.MLAgents.Extensions.Match3
|
|
{
|
|
/// <summary>
|
|
/// Sensor component for a Match3 game.
|
|
/// </summary>
|
|
[AddComponentMenu("ML Agents/Match 3 Sensor", (int)MenuGroup.Sensors)]
|
|
public class Match3SensorComponent : SensorComponent
|
|
{
|
|
/// <summary>
|
|
/// Name of the generated Match3Sensor object.
|
|
/// Note that changing this at runtime does not affect how the Agent sorts the sensors.
|
|
/// </summary>
|
|
public string SensorName = "Match3 Sensor";
|
|
|
|
/// <summary>
|
|
/// Type of observation to generate.
|
|
/// </summary>
|
|
public Match3ObservationType ObservationType = Match3ObservationType.Vector;
|
|
|
|
/// <inheritdoc/>
|
|
public override ISensor[] CreateSensors()
|
|
{
|
|
var board = GetComponent<AbstractBoard>();
|
|
var cellSensor = Match3Sensor.CellTypeSensor(board, ObservationType, SensorName + " (cells)");
|
|
if (board.NumSpecialTypes > 0)
|
|
{
|
|
var specialSensor =
|
|
Match3Sensor.SpecialTypeSensor(board, ObservationType, SensorName + " (special)");
|
|
return new ISensor[] { cellSensor, specialSensor };
|
|
}
|
|
else
|
|
{
|
|
return new ISensor[] { cellSensor };
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|