<commit_before>package de.doe;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

import de.doe.figures.Figure;

public class Board {
	
	protected Field[][] board = new Field[6][5];
	protected Player activePlayer;
	protected int turn;
	
	public Board() {
		initalizeField();
		activePlayer = Player.WHITE;
		turn = 1;
		
		board[0][0].figure = Figure.BLACK_KING;
		board[0][1].figure = Figure.BLACK_QUEEN;
		board[0][2].figure = Figure.BLACK_BISHOP;
		board[0][3].figure = Figure.BLACK_KNIGHT;
		board[0][4].figure = Figure.BLACK_ROOK;
		
		for (int i = 0; i <= 4; i++) {
			board[1][i].figure = Figure.BLACK_PAWN;
			board[4][i].figure = Figure.WHITE_PAWN;
		}
		
		board[5][0].figure = Figure.WHITE_ROOK;
		board[5][1].figure = Figure.WHITE_KNIGHT;
		board[5][2].figure = Figure.WHITE_BISHOP;
		board[5][3].figure = Figure.WHITE_QUEEN;
		board[5][4].figure = Figure.WHITE_KING;
		
	}
	
	private void initalizeField() {
		for (int y = 0; y < board.length; y++) {
			for (int x = 0; x < board[0].length; x++) {
				board[y][x] = new Field(null);
			}
		}
	}
	
	public Board(String board) {
		initalizeField();
		initializeFigure(board);
	}
	
	private void initializeFigure(String board) {
		String[] lines = board.split(System.lineSeparator());
		String[] firstLine = lines[0].split(" ");
		turn = Integer.parseInt(firstLine[0]);
		activePlayer = Player.fromChar(firstLine[1].charAt(0));
		
		for (int i = 1; i < lines.length; i++) {
			char[] charLine = lines[i].toCharArray();
			for (int j = 0; j < charLine.length; j++) {
				switch (charLine[j]) {
				case 'p':
					this.board[i - 1][j].figure = Figure.BLACK_PAWN;
					break;
				case 'P':
					this.board[i - 1][j].figure = Figure.WHITE_PAWN;
					break;
				case 'r':
					this.board[i - 1][j].figure = Figure.BLACK_ROOK;
					break;
				case 'R':
					this.board[i - 1][j].figure = Figure.WHITE_ROOK;
					break;
				case 'n':
					this.board[i - 1][j].figure = Figure.BLACK_KNIGHT;
					break;
				case 'N':
					this.board[i - 1][j].figure = Figure.WHITE_KNIGHT;
					break;
				case 'b':
					this.board[i - 1][j].figure = Figure.BLACK_BISHOP;
					break;
				case 'B':
					this.board[i - 1][j].figure = Figure.WHITE_BISHOP;
					break;
				case 'q':
					this.board[i - 1][j].figure = Figure.BLACK_QUEEN;
					break;
				case 'Q':
					this.board[i - 1][j].figure = Figure.WHITE_QUEEN;
					break;
				case 'k':
					this.board[i - 1][j].figure = Figure.BLACK_KING;
					break;
				case 'K':
					this.board[i - 1][j].figure = Figure.WHITE_KING;
					break;
				case '.':
					this.board[i - 1][j].figure = null;
					break;
				default:
					this.board[i - 1][j].figure = null;
				}
			}
			
		}
	}
	
	public Board(BufferedReader reader) {
		initalizeField();
		String board = "";
		String line;
		
		try {
			do {
				line = reader.readLine();
				if (line != null) {
					board = board + line + System.lineSeparator();
				}
			} while (reader.ready() && line != null);
			initializeFigure(board.trim());
			
		} catch (IOException e) {
			org.apache.log4j.Logger.getRootLogger().fatal("Could not read board", e);
		}
	}
	
	@Override
	public String toString() {
		return Arrays.deepToString(board);
	}
	
	public void print(PrintWriter writer) {
		writer.print(this.toString());
		writer.flush();
	}
	
	public Field getField(int x, int y) {
		
		return board[y][x];
	}
}<commit_msg>small performance improvement in Board<commit_after>package de.doe;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Arrays;

import de.doe.figures.Figure;

public class Board {
	
	protected Field[][] board = new Field[6][5];
	protected Player activePlayer;
	protected int turn;
	
	public Board() {
		initalizeField();
		activePlayer = Player.WHITE;
		turn = 1;
		
		board[0][0].figure = Figure.BLACK_KING;
		board[0][1].figure = Figure.BLACK_QUEEN;
		board[0][2].figure = Figure.BLACK_BISHOP;
		board[0][3].figure = Figure.BLACK_KNIGHT;
		board[0][4].figure = Figure.BLACK_ROOK;
		
		for (int i = 0; i <= 4; i++) {
			board[1][i].figure = Figure.BLACK_PAWN;
			board[4][i].figure = Figure.WHITE_PAWN;
		}
		
		board[5][0].figure = Figure.WHITE_ROOK;
		board[5][1].figure = Figure.WHITE_KNIGHT;
		board[5][2].figure = Figure.WHITE_BISHOP;
		board[5][3].figure = Figure.WHITE_QUEEN;
		board[5][4].figure = Figure.WHITE_KING;
		
	}
	
	private void initalizeField() {
		for (int y = 0; y < board.length; y++) {
			for (int x = 0; x < board[0].length; x++) {
				board[y][x] = new Field(null);
			}
		}
	}
	
	public Board(String board) {
		initalizeField();
		initializeFigure(board);
	}
	
	private void initializeFigure(String board) {
		String[] lines = board.split(System.lineSeparator());
		String[] firstLine = lines[0].split(" ");
		turn = Integer.parseInt(firstLine[0]);
		activePlayer = Player.fromChar(firstLine[1].charAt(0));
		
		for (int i = 1; i < lines.length; i++) {
			char[] charLine = lines[i].toCharArray();
			for (int j = 0; j < charLine.length; j++) {
				switch (charLine[j]) {
				case 'p':
					this.board[i - 1][j].figure = Figure.BLACK_PAWN;
					break;
				case 'P':
					this.board[i - 1][j].figure = Figure.WHITE_PAWN;
					break;
				case 'r':
					this.board[i - 1][j].figure = Figure.BLACK_ROOK;
					break;
				case 'R':
					this.board[i - 1][j].figure = Figure.WHITE_ROOK;
					break;
				case 'n':
					this.board[i - 1][j].figure = Figure.BLACK_KNIGHT;
					break;
				case 'N':
					this.board[i - 1][j].figure = Figure.WHITE_KNIGHT;
					break;
				case 'b':
					this.board[i - 1][j].figure = Figure.BLACK_BISHOP;
					break;
				case 'B':
					this.board[i - 1][j].figure = Figure.WHITE_BISHOP;
					break;
				case 'q':
					this.board[i - 1][j].figure = Figure.BLACK_QUEEN;
					break;
				case 'Q':
					this.board[i - 1][j].figure = Figure.WHITE_QUEEN;
					break;
				case 'k':
					this.board[i - 1][j].figure = Figure.BLACK_KING;
					break;
				case 'K':
					this.board[i - 1][j].figure = Figure.WHITE_KING;
					break;
				case '.':
					this.board[i - 1][j].figure = null;
					break;
				default:
					this.board[i - 1][j].figure = null;
				}
			}
			
		}
	}
	
	public Board(BufferedReader reader) {
		initalizeField();
		StringBuilder board = new StringBuilder();
		String line;
		
		try {
			do {
				line = reader.readLine();
				if (line != null) {
					board.append(line).append(System.lineSeparator());
				}
			} while (reader.ready() && line != null);
			initializeFigure(board.toString().trim());
			
		} catch (IOException e) {
			org.apache.log4j.Logger.getRootLogger().fatal("Could not read board", e);
		}
	}
	
	@Override
	public String toString() {
		return Arrays.deepToString(board);
	}
	
	public void print(PrintWriter writer) {
		writer.print(this.toString());
	}
	
	public Field getField(int x, int y) {
		
		return board[y][x];
	}
}
{'fraction_non_alphanumeric': 0.16676367869615832, 'fraction_numerical': 0.014842840512223517, 'mean_word_length': 2.947731188971855, 'pattern_counts': {'":': 0, '<': 13, '<?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': '3999357', 'n_tokens_mistral': 3127, 'n_tokens_neox': 2528, 'n_words': 512}