Struct Move
Struct that encapsulates a swap of adjacent cells. A Move can be constructed from either a starting row, column, and direction, or from a "move index" between 0 and NumPotentialMoves()-1. Moves are enumerated as the internal edges of the game grid. Left/right moves come first. There are (maxCols - 1) * maxRows of these. Up/down moves are next. There are (maxRows - 1) * maxCols of these.
Inherited Members
Namespace: Unity.MLAgents.Integrations.Match3
Assembly: Unity.ML-Agents.dll
Syntax
public struct Move
Fields
Column
Column of the cell that will be moved.
Declaration
public int Column
Field Value
Type | Description |
---|---|
int |
Direction
Direction that the cell will be moved.
Declaration
public Direction Direction
Field Value
Type | Description |
---|---|
Direction |
MoveIndex
Index of the move, from 0 to NumPotentialMoves-1.
Declaration
public int MoveIndex
Field Value
Type | Description |
---|---|
int |
Row
Row of the cell that will be moved.
Declaration
public int Row
Field Value
Type | Description |
---|---|
int |
Methods
FromMoveIndex(int, BoardSize)
Construct a Move from its move index and the board size. This is useful for iterating through all the Moves on a board, or constructing the Move corresponding to an Agent decision.
Declaration
public static Move FromMoveIndex(int moveIndex, BoardSize maxBoardSize)
Parameters
Type | Name | Description |
---|---|---|
int | moveIndex | Must be between 0 and NumPotentialMoves(maxRows, maxCols). |
Board |
maxBoardSize | Max board size |
Returns
Type | Description |
---|---|
Move | Corresponding |
Exceptions
Type | Condition |
---|---|
Argument |
Argument out of range |
FromPositionAndDirection(int, int, Direction, BoardSize)
Construct a Move from the row, column, direction, and board size.
Declaration
public static Move FromPositionAndDirection(int row, int col, Direction dir, BoardSize maxBoardSize)
Parameters
Type | Name | Description |
---|---|---|
int | row | Row |
int | col | Col |
Direction | dir | Dir |
Board |
maxBoardSize | Max board size |
Returns
Type | Description |
---|---|
Move | Corresponding |
InRangeForBoard(BoardSize)
Check if the move is valid for the given board size. This will be passed the return value from AbstractBoard.GetCurrentBoardSize().
Declaration
public bool InRangeForBoard(BoardSize boardSize)
Parameters
Type | Name | Description |
---|---|---|
Board |
boardSize | Board size |
Returns
Type | Description |
---|---|
bool | True if move is valide given input |
Next(BoardSize)
Increment the Move to the next MoveIndex, and update the Row, Column, and Direction accordingly.
Declaration
public void Next(BoardSize maxBoardSize)
Parameters
Type | Name | Description |
---|---|---|
Board |
maxBoardSize | Max board size |
NumPotentialMoves(BoardSize)
Return the number of potential moves for a board of the given size. This is equivalent to the number of internal edges in the board.
Declaration
public static int NumPotentialMoves(BoardSize maxBoardSize)
Parameters
Type | Name | Description |
---|---|---|
Board |
maxBoardSize | Max board size |
Returns
Type | Description |
---|---|
int | Number of potential moves given a boardsize. |
OtherCell()
Get the other row and column that correspond to this move.
Declaration
public (int Row, int Column) OtherCell()
Returns
Exceptions
Type | Condition |
---|---|
Argument |
Argument out of range |
OtherDirection()
Get the opposite direction of this move.
Declaration
public Direction OtherDirection()
Returns
Type | Description |
---|---|
Direction | Oposit |
Exceptions
Type | Condition |
---|---|
Argument |
Argument out of range |