<commit_before>class World {

	constructor(width, height) {
		this.width = width;
		this.height = height;
		this.entities = [];	// entities in this world
		this.killents = [];	// entities that are to be removed from this world
		this.scoreCallback = function(){};

		this.time = new Date().getTime();
	}

	think() {
		// update time
		var now = new Date().getTime();
		this.timedelta = (now - this.time) * 0.001;
		this.time = now;

		// remove entities marked for removal
		for(let i = 0; i < this.killents.length; ++i) {
			let idx = this.entities.indexOf(this.killents[i]);
			if(idx >= 0) {
				this.entities.splice(idx, 1);
			}
		}
		this.killents = [];

		// ensure all remaining entities think
		for(let i = 0; i < this.entities.length; ++i) {
			let ent = this.entities[i];
			if("think" in ent) {
				this.entities[i].think();
			}
		}
	}

	findRadius(ent, radius, type) {
		var radius_squared = radius * radius;
		var result = [];
		var x = ent.x;
		var y = ent.y;

		for(let i = 0; i < this.entities.length; ++i) {
			let e2 = this.entities[i];
			if(e2 === ent || (type && e2.type != type)) {
				continue;
			}
			let xdelta = x - e2.x;
			let ydelta = y - e2.y;
			let dist_squared = (xdelta*xdelta)+(ydelta*ydelta);
			if(dist_squared <= radius_squared) {
				result.push(e2);
			}
		}

		return result;
	}

	findClosest(ent, radius, type) {
		var radius_squared = radius * radius;
		var result = null;
		var best = radius_squared + 9;
		var x = ent.x;
		var y = ent.y;

		for(let i = 0; i < this.entities.length; ++i) {
			let e2 = this.entities[i];
			if(e2 === ent || (type && e2.type != type)) {
				continue;
			}

			let xdelta = x - e2.x;
			let ydelta = y - e2.y;
			let dist_squared = (xdelta*xdelta)+(ydelta*ydelta);
			if(dist_squared <= radius_squared && dist_squared < best) {
				result = e2;
				best = dist_squared;
			}
		}

		return result;
	}

	findType(type) {
		var result = [];
		for(var i = 0; i < this.entities.length; ++i) {
			let ent = this.entities[i];
			if(ent.type === type) {
				result.push(ent);
			}
		}

		return result;
	}

	getNetMsg() {
		var msg = [];
		for(let i = 0; i < this.entities.length; ++i) {
			let ent = this.entities[i];
			if("getNetMsg" in ent) {
				msg.push(ent.getNetMsg());
			}
		}
		return msg;
	}

	add(ent) {
		if(this.entities.indexOf(ent) < 0) {
			this.entities.push(ent);
		}
	}

	remove(ent) {
		if(this.killents.indexOf(ent) < 0) {
			this.killents.push(ent);
		}
	}

	setScoreCallback(callback) {
		this.scoreCallback = callback;
	}
<commit_msg>further cleanup, use ES6-style loops<commit_after>class World {

	constructor(width, height) {
		this.width = width;
		this.height = height;
		this.entities = [];	// entities in this world
		this.killents = [];	// entities that are to be removed from this world
		this.scoreCallback = function(){};

		this.time = new Date().getTime();
	}

	think() {
		// update time
		var now = new Date().getTime();
		this.timedelta = (now - this.time) * 0.001;
		this.time = now;

		// remove entities marked for removal
		for(let kent of this.killents) {
			let idx = this.entities.indexOf(kent);
			if(idx >= 0) {
				this.entities.splice(idx, 1);
			}
		}
		// clear array of entities to be removed
		this.killents.length = 0;

		// ensure all remaining entities think
		for(let ent of this.entities) {
			if("think" in ent) {
				ent.think();
			}
		}
	}

	findRadius(ent, radius, type) {
		var radius_squared = radius * radius;
		var result = [];
		var x = ent.x;
		var y = ent.y;

		for(let e2 of this.entities) {
			if(e2 === ent || (type && e2.type != type)) {
				continue;
			}
			let xdelta = x - e2.x;
			let ydelta = y - e2.y;
			let dist_squared = (xdelta*xdelta)+(ydelta*ydelta);
			if(dist_squared <= radius_squared) {
				result.push(e2);
			}
		}

		return result;
	}

	findClosest(ent, radius, type) {
		var radius_squared = radius * radius;
		var result = null;
		var best = radius_squared + 9;
		var x = ent.x;
		var y = ent.y;

		for(let e2 of this.entities) {
			if(e2 === ent || (type && e2.type != type)) {
				continue;
			}

			let xdelta = x - e2.x;
			let ydelta = y - e2.y;
			let dist_squared = (xdelta*xdelta)+(ydelta*ydelta);
			if(dist_squared <= radius_squared && dist_squared < best) {
				result = e2;
				best = dist_squared;
			}
		}

		return result;
	}

	findType(type) {
		var result = [];
		for(let ent of this.entities) {
			if(ent.type === type) {
				result.push(ent);
			}
		}
		return result;
	}

	getNetMsg() {
		var msg = [];
		for(let ent of this.entities) {
			if("getNetMsg" in ent) {
				msg.push(ent.getNetMsg());
			}
		}
		return msg;
	}

	add(ent) {
		if(this.entities.indexOf(ent) < 0) {
			this.entities.push(ent);
		}
	}

	remove(ent) {
		if(this.killents.indexOf(ent) < 0) {
			this.killents.push(ent);
		}
	}

	setScoreCallback(callback) {
		this.scoreCallback = callback;
	}

{'fraction_non_alphanumeric': 0.1614497528830313, 'fraction_numerical': 0.01029654036243822, 'mean_word_length': 2.668429003021148, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 5, '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': '67923', 'n_tokens_mistral': 2194, 'n_tokens_neox': 1857, 'n_words': 437}