<commit_before>package com.christophdietze.jack.common.board;

public class PositionUtils {

	public static Position makeMoveVerified(Position position, Move move) throws IllegalMoveException {
		MoveLegality legality = MoveChecker.isPseudoLegalMove(null, null);
		if (!legality.isLegal()) {
			throw new IllegalMoveException(legality.getMessage());
		}
		Position trialPosition = makeMove(position, move);
		if (MoveChecker.canCaptureKing(/* trialPosition */null)) {
			throw new IllegalMoveException();
		}
		return trialPosition;
	}

	public static Position makeMove(Position position, Move move) {
		if (isPseudoLegalCastleMove(position, move)) {
			// castle move
			Position.Builder builder = new Position.Builder(position);
			builder.clearEnPassantPawn().clearPhantomKings().switchPlayerToMove();
			if (builder.isWhiteToMove()) {
				builder.fullmoveNumber(builder.getFullmoveNumber() + 1);
			}
			makeCastleMove(builder, move);
			return builder.build();
		} else {
			// normal move
			Position.Builder builder = new Position.Builder(position);
			builder.clearEnPassantPawn().clearPhantomKings();
			Piece fromPiece = position.getPiece(move.getFrom());
			Piece toPiece = position.getPiece(move.getTo());
			builder.clearPhantomKings();
			// adjust castling availability
			if (fromPiece == Piece.WHITE_KING) {
				builder.canWhiteCastleKingside(false).canWhiteCastleQueenside(false);
			} else if (fromPiece == Piece.BLACK_KING) {
				builder.canBlackCastleKingside(false).canBlackCastleQueenside(false);
			}<commit_msg>fixed tests<commit_after>package com.christophdietze.jack.common.board;

public class PositionUtils {

	public static Position makeMoveVerified(Position position, Move move) throws IllegalMoveException {
		MoveLegality legality = MoveChecker.isPseudoLegalMove(position, move);
		if (!legality.isLegal()) {
			throw new IllegalMoveException(legality.getMessage());
		}
		Position trialPosition = makeMove(position, move);
		if (MoveChecker.canCaptureKing(trialPosition)) {
			throw new IllegalMoveException();
		}
		return trialPosition;
	}

	public static Position makeMove(Position position, Move move) {
		if (isPseudoLegalCastleMove(position, move)) {
			// castle move
			Position.Builder builder = new Position.Builder(position);
			builder.clearEnPassantPawn().clearPhantomKings().switchPlayerToMove();
			if (builder.isWhiteToMove()) {
				builder.fullmoveNumber(builder.getFullmoveNumber() + 1);
			}
			makeCastleMove(builder, move);
			return builder.build();
		} else {
			// normal move
			Position.Builder builder = new Position.Builder(position);
			builder.clearEnPassantPawn().clearPhantomKings();
			Piece fromPiece = position.getPiece(move.getFrom());
			Piece toPiece = position.getPiece(move.getTo());
			builder.clearPhantomKings();
			// adjust castling availability
			if (fromPiece == Piece.WHITE_KING) {
				builder.canWhiteCastleKingside(false).canWhiteCastleQueenside(false);
			} else if (fromPiece == Piece.BLACK_KING) {
				builder.canBlackCastleKingside(false).canBlackCastleQueenside(false);
			}
{'fraction_non_alphanumeric': 0.11096605744125326, 'fraction_numerical': 0.0006527415143603133, 'mean_word_length': 5.179435483870968, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1919727', 'n_tokens_mistral': 1050, 'n_tokens_neox': 917, 'n_words': 175}