I am trying to have AI learn to play on a board using the Match3 extensions.
The AI cannot learn to move one of its units closer to the enemy. This was due to the Match3Sensor’s observation type being set to ‘vector’. Meaning it only took 1d array of information which made it difficult for the AI to learn movement.
So I tried setting the observation types to ‘uncompressed visual’ and ‘compressed visual’. Since these allow for multi-dimensional observations. But this is where the problem occurs.
When I set the Match3Sensor observation type to ‘uncompressed visuals’ the command prompt returns this error while stopping the learning process.
raise UnityTrainerException(f"Unsupported Sensor with specs {obs_spec}") mlagents.trainers.exception.UnityTrainerException: Unsupported Sensor with specs ObservationSpec(shape=(10, 10, 10), dimension_property=(<DimensionProperty.NONE: 1>, <DimensionProperty.TRANSLATIONAL_EQUIVARIANCE: 2>, <DimensionProperty.TRANSLATIONAL_EQUIVARIANCE: 2>), observation_type=<ObservationType.DEFAULT: 0>, name='Match3 Sensor (cells)')
And this error when setting the type to ‘compressed visuals’.
mlagents_envs.exception.UnityObservationException: Decompressed observation did not have the expected shape - decompressed had (10, 10, 6) but expected [6, 10, 10]
The observation codes which is used to feed the sensor are these 2. Each for the cell type and unit types on each cell.
public override int GetCellType(int row, int col)
{
Cell cell = GetCell(row, col);
return (int)cell.type;
}
public override int GetSpecialType(int row, int col)
{
Cell cell = GetCell(row, col);
if (cell.CurrentUnits.Count > 0)
{
Unit unit = cell.CurrentUnits[0];
if (unit.PlayerNumber == player.number)
{
return (int)unit.type;
}
else
{
return (int)unit.type * -1;
}
}
return 0;
}
This is the boardsize
public override BoardSize GetMaxBoardSize()
{
BoardSize boardSize = new BoardSize();
boardSize.Rows = 10;
boardSize.Columns = 10;
boardSize.NumCellTypes = 10;
boardSize.NumSpecialTypes = 5;
return boardSize;
}