docs.unity3d.com
    Show / Hide Table of Contents

    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
    ValueType.Equals(Object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Object.Equals(Object, Object)
    Object.ReferenceEquals(Object, Object)
    Object.GetType()
    Namespace: Unity.MLAgents.Integrations.Match3
    Syntax
    public struct Move

    Fields

    Column

    Column of the cell that will be moved.

    Declaration
    public int Column
    Field Value
    Type Description
    Int32

    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
    Int32

    Row

    Row of the cell that will be moved.

    Declaration
    public int Row
    Field Value
    Type Description
    Int32

    Methods

    FromMoveIndex(Int32, 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
    Int32 moveIndex

    Must be between 0 and NumPotentialMoves(maxRows, maxCols).

    BoardSize maxBoardSize
    Returns
    Type Description
    Move
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    FromPositionAndDirection(Int32, Int32, 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
    Int32 row
    Int32 col
    Direction dir
    BoardSize maxBoardSize
    Returns
    Type Description
    Move

    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
    BoardSize boardSize
    Returns
    Type Description
    Boolean

    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
    BoardSize maxBoardSize

    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
    BoardSize maxBoardSize
    Returns
    Type Description
    Int32

    OtherCell()

    Get the other row and column that correspond to this move.

    Declaration
    public (int Row, int Column) OtherCell()
    Returns
    Type Description
    (T1, T2)<Int32, Int32>
    Exceptions
    Type Condition
    ArgumentOutOfRangeException

    OtherDirection()

    Get the opposite direction of this move.

    Declaration
    public Direction OtherDirection()
    Returns
    Type Description
    Direction
    Exceptions
    Type Condition
    ArgumentOutOfRangeException
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023