<commit_before>package mitzi;

import java.util.Set;

public class NaiveBoard implements IBoard {

	protected static int[][] initial_board = {
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 12, 13, 14, 15, 16, 14, 13, 12, 00, 00 },
			{ 00, 00, 11, 11, 11, 11, 11, 11, 11, 11, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 01, 01, 01, 01, 01, 01, 01, 01, 00, 00 },
			{ 00, 00, 02, 03, 04, 05, 06, 04, 03, 02, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 } };

	private int[][] board = new int[12][12];

	private int full_move_clock;

	private int half_move_clock;

	// squares c1, g1, c8 and g8 in ICCF numeric notation
	// do not change the squares' order or bad things will happen!
	private int[] castling = new int[4];

	private int en_passant_target;

	private int active_color;

	private NaiveBoard returnCopy() {
		NaiveBoard newBoard = new NaiveBoard();

		newBoard.active_color = active_color;
		newBoard.en_passant_target = en_passant_target;
		newBoard.full_move_clock = full_move_clock;
		newBoard.half_move_clock = half_move_clock;
		System.arraycopy(castling, 0, newBoard.castling, 0, 4);

		for (int i = 2; i < 11; i++)
			System.arraycopy(board[i], 0, newBoard.board[i], 0, 12);

		return newBoard;
	}

	private int getFromBoard(int square) {
		int row = SquareHelper.getRow(square);
		int column = SquareHelper.getColumn(square);
		return board[10 - row][1 + column];
	}

	private void setOnBoard(int square, int piece_value) {
		int row = SquareHelper.getRow(square);
		int column = SquareHelper.getColumn(square);
		board[10 - row][1 + column] = piece_value;
	}

	@Override
	public void setToInitial() {
		board = initial_board;

		full_move_clock = 1;

		half_move_clock = 0;

		castling[0] = 31;
		castling[1] = 71;
		castling[2] = 38;
		castling[3] = 78;

		en_passant_target = -1;

		active_color = PieceHelper.WHITE;
	}

	@Override
	public void setToFEN(String fen) {
		// TODO Auto-generated method stub

	}

	@Override
	public NaiveBoard doMove(IMove move) {

		NaiveBoard newBoard = this.returnCopy();

		int src = move.getFromSquare();
		int dest = move.getToSquare();

		// if promotion
		if (move.getPromotion() != 0) {
			newBoard.setOnBoard(src, 0);
			newBoard.setOnBoard(dest, move.getPromotion());

			newBoard.half_move_clock = 0;

		}
		// If rochade
		else if (PieceHelper.pieceType(src) == PieceHelper.KNIGHT
				&& Math.abs((src - dest)) == 20) {
			newBoard.setOnBoard(dest,
					PieceHelper.pieceValue(PieceHelper.KING, active_color));
			newBoard.setOnBoard(src, 0);
			newBoard.setOnBoard((src + dest) / 2,
					PieceHelper.pieceValue(PieceHelper.ROOK, active_color));
			if (SquareHelper.getColumn(dest) == 3)
				newBoard.setOnBoard(src - 40, 0);
			else
				newBoard.setOnBoard(src + 30, 0);

			newBoard.half_move_clock++;
			
		}
		// If en passant
		else if (PieceHelper.pieceType(src) == PieceHelper.PAWN
				&& dest == this.getEnPassant()) {
			newBoard.setOnBoard(dest,
					PieceHelper.pieceValue(PieceHelper.PAWN, active_color));
			newBoard.setOnBoard(src, 0);
			if (active_color == PieceHelper.WHITE)
				newBoard.setOnBoard(dest - 1, 0);
			else
				newBoard.setOnBoard(dest + 1, 0);

			newBoard.half_move_clock = 0;
		}
		// Usual move
		else {
			newBoard.setOnBoard(dest, this.getFromBoard(src));
			newBoard.setOnBoard(src, 0);

			if (this.getFromBoard(dest) != 0
					|| PieceHelper.pieceType(this.getFromBoard(src)) == PieceHelper.PAWN)
				newBoard.half_move_clock = 0;
			else
				newBoard.half_move_clock++;

		}

		// Change active_color after move
		newBoard.active_color = PieceHelper.pieceOppositeColor(this
				.getFromBoard(dest)); 
		if (active_color == PieceHelper.BLACK)
			newBoard.full_move_clock++;

		// Update en_passant
		if (PieceHelper.pieceType(this.getFromBoard(src)) == PieceHelper.PAWN
				&& Math.abs(dest - src) == 2)
			newBoard.en_passant_target = (dest + src) / 2;
		else
			newBoard.en_passant_target = -1;
		
		// Update casteling
		if(PieceHelper.pieceType(this.getFromBoard(src))==PieceHelper.KING)
			if(active_color==PieceHelper.WHITE && src== 51){
				newBoard.castling[0]=-1;
				newBoard.castling[1]=-1;<commit_msg>on "old" board piece is still on src<commit_after>package mitzi;

import java.util.Set;

public class NaiveBoard implements IBoard {

	protected static int[][] initial_board = {
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 12, 13, 14, 15, 16, 14, 13, 12, 00, 00 },
			{ 00, 00, 11, 11, 11, 11, 11, 11, 11, 11, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 01, 01, 01, 01, 01, 01, 01, 01, 00, 00 },
			{ 00, 00, 02, 03, 04, 05, 06, 04, 03, 02, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 },
			{ 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00, 00 } };

	private int[][] board = new int[12][12];

	private int full_move_clock;

	private int half_move_clock;

	// squares c1, g1, c8 and g8 in ICCF numeric notation
	// do not change the squares' order or bad things will happen!
	private int[] castling = new int[4];

	private int en_passant_target;

	private int active_color;

	private NaiveBoard returnCopy() {
		NaiveBoard newBoard = new NaiveBoard();

		newBoard.active_color = active_color;
		newBoard.en_passant_target = en_passant_target;
		newBoard.full_move_clock = full_move_clock;
		newBoard.half_move_clock = half_move_clock;
		System.arraycopy(castling, 0, newBoard.castling, 0, 4);

		for (int i = 2; i < 11; i++)
			System.arraycopy(board[i], 0, newBoard.board[i], 0, 12);

		return newBoard;
	}

	private int getFromBoard(int square) {
		int row = SquareHelper.getRow(square);
		int column = SquareHelper.getColumn(square);
		return board[10 - row][1 + column];
	}

	private void setOnBoard(int square, int piece_value) {
		int row = SquareHelper.getRow(square);
		int column = SquareHelper.getColumn(square);
		board[10 - row][1 + column] = piece_value;
	}

	@Override
	public void setToInitial() {
		board = initial_board;

		full_move_clock = 1;

		half_move_clock = 0;

		castling[0] = 31;
		castling[1] = 71;
		castling[2] = 38;
		castling[3] = 78;

		en_passant_target = -1;

		active_color = PieceHelper.WHITE;
	}

	@Override
	public void setToFEN(String fen) {
		// TODO Auto-generated method stub

	}

	@Override
	public NaiveBoard doMove(IMove move) {

		NaiveBoard newBoard = this.returnCopy();

		int src = move.getFromSquare();
		int dest = move.getToSquare();

		// if promotion
		if (move.getPromotion() != 0) {
			newBoard.setOnBoard(src, 0);
			newBoard.setOnBoard(dest, move.getPromotion());

			newBoard.half_move_clock = 0;

		}
		// If rochade
		else if (PieceHelper.pieceType(src) == PieceHelper.KNIGHT
				&& Math.abs((src - dest)) == 20) {
			newBoard.setOnBoard(dest,
					PieceHelper.pieceValue(PieceHelper.KING, active_color));
			newBoard.setOnBoard(src, 0);
			newBoard.setOnBoard((src + dest) / 2,
					PieceHelper.pieceValue(PieceHelper.ROOK, active_color));
			if (SquareHelper.getColumn(dest) == 3)
				newBoard.setOnBoard(src - 40, 0);
			else
				newBoard.setOnBoard(src + 30, 0);

			newBoard.half_move_clock++;
			
		}
		// If en passant
		else if (PieceHelper.pieceType(src) == PieceHelper.PAWN
				&& dest == this.getEnPassant()) {
			newBoard.setOnBoard(dest,
					PieceHelper.pieceValue(PieceHelper.PAWN, active_color));
			newBoard.setOnBoard(src, 0);
			if (active_color == PieceHelper.WHITE)
				newBoard.setOnBoard(dest - 1, 0);
			else
				newBoard.setOnBoard(dest + 1, 0);

			newBoard.half_move_clock = 0;
		}
		// Usual move
		else {
			newBoard.setOnBoard(dest, this.getFromBoard(src));
			newBoard.setOnBoard(src, 0);

			if (this.getFromBoard(dest) != 0
					|| PieceHelper.pieceType(this.getFromBoard(src)) == PieceHelper.PAWN)
				newBoard.half_move_clock = 0;
			else
				newBoard.half_move_clock++;

		}

		// Change active_color after move
		newBoard.active_color = PieceHelper.pieceOppositeColor(this
				.getFromBoard(src)); 
		if (active_color == PieceHelper.BLACK)
			newBoard.full_move_clock++;

		// Update en_passant
		if (PieceHelper.pieceType(this.getFromBoard(src)) == PieceHelper.PAWN
				&& Math.abs(dest - src) == 2)
			newBoard.en_passant_target = (dest + src) / 2;
		else
			newBoard.en_passant_target = -1;
		
		// Update casteling
		if(PieceHelper.pieceType(this.getFromBoard(src))==PieceHelper.KING)
			if(active_color==PieceHelper.WHITE && src== 51){
				newBoard.castling[0]=-1;
				newBoard.castling[1]=-1;
{'fraction_non_alphanumeric': 0.14544235924932977, 'fraction_numerical': 0.08042895442359249, 'mean_word_length': 3.5262891809909, 'pattern_counts': {'":': 0, '<': 5, '<?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': 72, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '782639', 'n_tokens_mistral': 4482, 'n_tokens_neox': 3366, 'n_words': 858}