<commit_before>import { KING, QUEEN, KNIGHT, BISHOP, ROOK, PAWN } from './brands';
import { Point } from './point'

export class Board {

	constructor(files=8, ranks=8, boardArr) {
		this.files = files;
		this.ranks = ranks;
		this.storage = createStorage(files, ranks);
		this.pieces = new Set();
		this.pieces[KING] = new Set();
		this.pieces[QUEEN] = new Set();
		this.pieces[KNIGHT] = new Set();
		this.pieces[BISHOP] = new Set();
		this.pieces[ROOK] = new Set();
		this.pieces[PAWN] = new Set();
		if (boardArr != null) {
			this.decorate(boardArr);
		}
	}

	map(fn) {
		return new Board(this.ranks, this.files, this.storage.map((rank, i) =>
			rank.map((piece, j) => fn(piece, new Point(j, i)))));
	}

	forEach(fn) {
		// TODO: make this work like #map(), use this abstraction everywhere.
		return this.storage.forEach(fn);
	}

	getPieces(brand) {
		return brand == null ? this.pieces : this.pieces[brand];
	}

	getPieceCoords(piece) {
		for (var i = 0, iLen = this.storage.length; i < iLen; i++) {
			const rank = this.storage[i];
			for (var j = 0, jLen = rank.length; j < jLen; j++) {
				const p = rank[j];
				if (p === piece) {
					return new Point(j, i);
				}
			}
		}
		return null;
	}

	getPieceByCoords({ x, y }, rotated=false) {
		const rank = this.storage[rotated ? this.ranks - y - 1 : y];
		return rank == null ? null : rank[rotated ? this.files - x - 1 : x];
	}

	placePiece(piece, { x: file, y: rank }) {
		this.storage[rank][file] = piece;
		this.pieces.add(piece);
		this.pieces[piece.brand].add(piece);
	}
<commit_msg>board: remove temporary kludge<commit_after>import { KING, QUEEN, KNIGHT, BISHOP, ROOK, PAWN } from './brands';
import { Point } from './point'

export class Board {

	constructor(files=8, ranks=8, boardArr) {
		this.files = files;
		this.ranks = ranks;
		this.storage = createStorage(files, ranks);
		this.pieces = new Set();
		this.pieces[KING] = new Set();
		this.pieces[QUEEN] = new Set();
		this.pieces[KNIGHT] = new Set();
		this.pieces[BISHOP] = new Set();
		this.pieces[ROOK] = new Set();
		this.pieces[PAWN] = new Set();
		if (boardArr != null) {
			this.decorate(boardArr);
		}
	}

	map(fn) {
		return new Board(this.ranks, this.files, this.storage.map((rank, i) =>
			rank.map((piece, j) => fn(piece, new Point(j, i)))));
	}

	getPieces(brand) {
		return brand == null ? this.pieces : this.pieces[brand];
	}

	getPieceCoords(piece) {
		for (var i = 0, iLen = this.storage.length; i < iLen; i++) {
			const rank = this.storage[i];
			for (var j = 0, jLen = rank.length; j < jLen; j++) {
				const p = rank[j];
				if (p === piece) {
					return new Point(j, i);
				}
			}
		}
		return null;
	}

	getPieceByCoords({ x, y }, rotated=false) {
		const rank = this.storage[rotated ? this.ranks - y - 1 : y];
		return rank == null ? null : rank[rotated ? this.files - x - 1 : x];
	}

	placePiece(piece, { x: file, y: rank }) {
		this.storage[rank][file] = piece;
		this.pieces.add(piece);
		this.pieces[piece.brand].add(piece);
	}

{'fraction_non_alphanumeric': 0.17980543441798055, 'fraction_numerical': 0.004025494800402549, 'mean_word_length': 3.2722063037249285, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '1817854', 'n_tokens_mistral': 1273, 'n_tokens_neox': 1127, 'n_words': 282}