build_move method

Move build_move(
  1. List<Piece?> board,
  2. dynamic from,
  3. dynamic to,
  4. dynamic flags, [
  5. PieceType? promotion,
])

Implementation

Move build_move(List<Piece?> board, from, to, flags, [PieceType? promotion]) {
  if (promotion != null) {
    flags |= BITS_PROMOTION;
  }

  PieceType? captured;
  final toPiece = board[to];
  if (toPiece != null) {
    captured = toPiece.type;
  } else if ((flags & BITS_EP_CAPTURE) != 0) {
    captured = PAWN;
  }
  return Move(turn, from, to, flags, board[from]!.type, captured, promotion);
}