<commit_before>"use strict";

function Game() {
	this.context = null;
	this.width = document.body.clientWidth - 400;
	this.height = document.body.clientHeight - 80;
	this.timer = 0;
	this.runtime = 0;
	this.debug = 1;
	/** ms accuracy of simulation steps performed,
	* 10 means 100 calculations a second, 20 means 50. */
	this.stepAccuracy = 10;
	/** counter of steps performed during a tick */
	this.steps = 0;
	/** Holds the handle for the requestAnimationFrame clock */
	this.animFrame = null;
	/** Holds the timestamp from when the last step was finished */
	this.lastStepRTC = null;
	/** Counts the ms between the last 5 frames */
	this.fpsCounter = [0,0,0,0,0];
	this.fpsIndex = -1;
	/** Count upwards towards the rtc for the step counter, so we know when to
	* run a simulation step */
	this.stepCatchupRTC = null;
	/** Clock for comparing rendering timings with the rtc */
	this.renderCatchupRTC = null;
	/** Real Time Counter since animation start */
	this.rtc = 0;
	/** Timestamp from when start were called */
	this.animStart = null;
	/** Holds mouse position over the canvas */
	this.mouse = null;
	this.mouseButton = null;
	this.root = {
		cells: [],
		cellsLastTick: [],
		numCells: 0
	};
	this.state = { running:0 };
	this.gameflags = {
		DUMMY: 1,
	};
	this.settings = { numOfCells:500, showFPSGraph:true };
	this.topo = new Topology(0, 0, this.width, this.height);
}

Game.prototype.init = function() {
		var self = this,
			canvas = document.querySelector("#game");
		//this.fpsCounter = new Array(100);

		// WINDOW SIZE AND RESIZE
		canvas.width = this.width;
		canvas.height = this.height;
		this.context = canvas.getContext("2d");

		window.addEventListener("resize", function(e) {
			this.width = document.body.clientWidth - 400;
			this.height = document.body.clientHeight - 80;
			canvas.width = this.width;
			canvas.height = this.height;
			this.topo.update();
		}, false);

		// Capture mouse movement
		canvas.addEventListener("mousemove", function(e) {
			this.mouse = { x:e.pageX - this.offsetLeft, y:e.pageY - this.offsetTop };
		}, false);
		canvas.addEventListener("mouseout", function() { this.mouse = null; }, false);

		/**
		* Initialize cells
		*/
		this.root.cells = new Array(this.settings.numOfCells);
		for (var i = 0; i < this.settings.numOfCells; i++ ) {
			this.root.cells[i] = new Cell();
		};
		this.root.numCells = this.root.cells.length;

		// Track state of mousbuttons as a read-on-demand variable
		self.mouseButton = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
		document.body.onmousedown = function(evt) {
		  self.mouseButton[evt.button]++;
		};
		document.body.onmouseup = function(evt) {
		  self.mouseButton[evt.button]--;
		};
};

	/**
	* Calls game logic and simulation
	* @function
	* @private
	*/
Game.prototype.tick = function(t) {
		//timer.calleach(1000,function(){console.log(Math.random(5))});
		var self = this;
		this.energy = 0;

		//topo.update();
};

	/**<commit_msg>Fixed faulty reference to "this" in anonymous/inline function calls<commit_after>"use strict";

function Game() {
	this.context = null;
	this.width = document.body.clientWidth - 400;
	this.height = document.body.clientHeight - 80;
	this.timer = 0;
	this.runtime = 0;
	this.debug = 1;
	/** ms accuracy of simulation steps performed,
	* 10 means 100 calculations a second, 20 means 50. */
	this.stepAccuracy = 10;
	/** counter of steps performed during a tick */
	this.steps = 0;
	/** Holds the handle for the requestAnimationFrame clock */
	this.animFrame = null;
	/** Holds the timestamp from when the last step was finished */
	this.lastStepRTC = null;
	/** Counts the ms between the last 5 frames */
	this.fpsCounter = [0,0,0,0,0];
	this.fpsIndex = -1;
	/** Count upwards towards the rtc for the step counter, so we know when to
	* run a simulation step */
	this.stepCatchupRTC = null;
	/** Clock for comparing rendering timings with the rtc */
	this.renderCatchupRTC = null;
	/** Real Time Counter since animation start */
	this.rtc = 0;
	/** Timestamp from when start were called */
	this.animStart = null;
	/** Holds mouse position over the canvas */
	this.mouse = null;
	this.mouseButton = null;
	this.root = {
		cells: [],
		cellsLastTick: [],
		numCells: 0
	};
	this.state = { running:0 };
	this.gameflags = {
		DUMMY: 1,
	};
	this.settings = { numOfCells:500, showFPSGraph:true };
	this.topo = new Topology(0, 0, this.width, this.height);
}

Game.prototype.init = function() {
		var game = this,
			canvas = document.querySelector("#game");
		//this.fpsCounter = new Array(100);

		// WINDOW SIZE AND RESIZE
		canvas.width = this.width;
		canvas.height = this.height;
		this.context = canvas.getContext("2d");

		window.addEventListener("resize", function(e) {
			this.width = document.body.clientWidth - 400;
			this.height = document.body.clientHeight - 80;
			canvas.width = this.width;
			canvas.height = this.height;
			game.topo.update();
		}, false);

		// Capture mouse movement
		canvas.addEventListener("mousemove", function(e) {
			game.mouse = { x:e.pageX - game.offsetLeft, y:e.pageY - game.offsetTop };
		}, false);
		canvas.addEventListener("mouseout", function() { game.mouse = null; }, false);

		/**
		* Initialize cells
		*/
		this.root.cells = new Array(this.settings.numOfCells);
		for (var i = 0; i < this.settings.numOfCells; i++ ) {
			this.root.cells[i] = new Cell();
		};
		this.root.numCells = this.root.cells.length;

		// Track state of mousbuttons as a read-on-demand variable
		game.mouseButton = [ 0, 0, 0, 0, 0, 0, 0, 0, 0 ];
		document.body.onmousedown = function(evt) {
		  game.mouseButton[evt.button]++;
		};
		document.body.onmouseup = function(evt) {
		  game.mouseButton[evt.button]--;
		};
};

	/**
	* Calls game logic and simulation
	* @function
	* @private
	*/
Game.prototype.tick = function(t) {
		//timer.calleach(1000,function(){console.log(Math.random(5))});
		var self = this;
		this.energy = 0;

		//topo.update();
};

	/**
{'fraction_non_alphanumeric': 0.1491198375084631, 'fraction_numerical': 0.02064996614759648, 'mean_word_length': 3.396577380952381, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7220683', 'n_tokens_mistral': 2234, 'n_tokens_neox': 1982, 'n_words': 526}