changePiece

fun changePiece(coordinate: Coordinate): Board

Changes the piece at the specified coordinate by swapping its color from 'B' to 'W' or vice versa.

Return

A new board with the piece color swapped at the specified position.

Parameters

coordinate

The coordinate of the piece to change.

Throws

if the coordinate is out of bounds or if there is no piece at the position.


fun changePiece(idx: Int): Board

Changes the piece at the specified linear index by swapping its color.

Return

A new board with the piece color swapped at the specified index.

Parameters

idx

The linear index of the piece to change.

Throws

if the index is out of bounds or if there is no piece at the position.