addPiece

fun addPiece(coordinate: Coordinate, value: PieceType): Board

Adds a piece to the board at the specified coordinate.

Return

A new board with the added piece.

Parameters

coordinate

The (row, column) coordinate where the piece will be added.

value

The type of piece to add.

Throws

if the coordinate is out of bounds or if there is already a piece at that position.


fun addPiece(idx: Int, value: PieceType): Board

Adds a piece to the board at the specified linear index.

Return

A new board with the added piece.

Parameters

idx

The linear index where the piece will be added.

value

The type of piece to add.

Throws

if the index is out of bounds or if there is already a piece at that position.


fun addPiece(piece: Piece): Board

Adds a piece to the board.

Return

A new board with the added piece.

Parameters

piece

The piece to add.

Throws

if the coordinate is out of bounds or if there is already a piece at that position.