put method

bool put(
  1. Piece piece,
  2. String square
)

Put piece on square

Implementation

bool put(Piece piece, String square) {
  /* check for piece */
  if (!SYMBOLS.contains(piece.type.toLowerCase())) {
    return false;
  }

  /* check for valid square */
  if (!(SQUARES.containsKey(square))) {
    return false;
  }

  int sq = SQUARES[square];
  board[sq] = piece;
  if (piece.type == KING) {
    kings[piece.color] = sq;
  }

  update_setup(generate_fen());

  return true;
}