<commit_before>function Dots() {
	this.bn = 8;								//number of boxs
	this.bs = (Math.min(width,height) - 4) /8; 		//boxsize

	this.vArray = [];	//array of vertical lines
	this.hArray = [];	//array of horizontal lines
	this.boxArray = [];	//array of filled boxes
	this.blueTurn;

	//sends the starting game layout to wrapper
	this.callSendState = function(){
			var boardState = {
				vArray:				JSON.stringify(this.vArray), 
				hArray:				JSON.stringify(this.hArray), 
				boxArray:			JSON.stringify(this.boxArray), 
				blueTurn:			JSON.stringify(this.blueTurn),
			}
		sendStateToServer(JSON.stringify(boardState));
	}

	this.recieveState = function (boardString) {
		var boardState = 	JSON.parse(boardString);
		this.vArray = 		JSON.parse(boardState.vArray);
		this.hArray = 		JSON.parse(boardState.hArray);
		this.boxArray = 	JSON.parse(boardState.boxArray);
		this.blueTurn = 	JSON.parse(boardState.blueTurn);
		this.drawBoard();
	}

	//initilizes empty arrays representing game state
	this.startGame = function() {
		setupCanvasObjects();

		//fills this.this.vArray with 0s
		for (var x = 0; x < this.bn + 1; x++) {
			this.vArray[x] = [];
			for (var y = 0; y < this.bn; y++) {
				this.vArray[x][y] = false;
			}
		}
		
		//fills this.hArray with 0s
		for (var x = 0; x < this.bn; x++) {
			this.hArray[x] = [];
			for (var y = 0; y < this.bn + 1; y++) {
				this.hArray[x][y] = false;
			}
		}	
		
		//fills this.boxArray with 0s
		for (var x = 0; x < this.bn; x++) {
			this.boxArray[x] = [];
			for (var y = 0; y < this.bn; y++) {
				this.boxArray[x][y] = 0;
			}
		}	
		
		//sets starting player
		this.blueTurn = true;
		
		this.drawBoard();
		this.callSendState();
	}

	//clears canvas and redraws board
	this.drawBoard = function() {	
		//clears canvas
		context.fillStyle = "rgb(255,255,255)";
		context.fillRect(0, 0, width, height);
		
		//draw grid
		this.drawGrid();
		
		//draw lines placed by players
		this.drawLines();
		
		//draws filled boxs
		this.drawFilledBox();
	}	

	//draws grid of lines 
	this.drawGrid = function(){
		context.beginPath();
		//draw vertical lines
		for (var x=0; x<=this.bn*this.bs; x+= this.bs) {
			context.moveTo(x,0);
			context.lineTo(x,this.bn*this.bs);
		}
		
		//draw horizontal lines
		for (var y=0; y<=this.bn*this.bs; y+= this.bs) {
			context.moveTo(0,y);
			context.lineTo(this.bn*this.bs,y);
		}
		
		//fills in lines in offwhite
		context.strokeStyle = "rgb(190,190,190)";
		context.stroke();
		context.closePath();
	}

	//draws in lines clicked by player
	this.drawLines = function(){
		//lines are mostly with a little red or blue
		context.fillStyle = (this.blueTurn) ? "rgb(4,9,83)" : "rgb(103,3,3)";

		//draws vertical and horizontal lines
		for (var x = 0; x < this.bn + 1; x++) {
			for (var y = 0; y < this.bn; y++) {
				if (this.vArray[x][y]) { 
					context.fillRect(x*this.bs, y*this.bs, 4, this.bs+3);
				}
				if (this.hArray[x][y]) { 
					context.fillRect(x*this.bs, y*this.bs, this.bs+3, 4);
				}
			}
		}
	}

	//draws boxes surrounded by lines
	this.drawFilledBox = function(){
		for (var x = 0; x < this.bn; x++) {
			for (var y = 0; y < this.bn; y++) {
				if(this.boxArray[x][y] == 1) {
					context.fillStyle = "rgb(200,0,0)";
					context.fillRect(x*this.bs+5,y*this.bs+5,this.bs-7,this.bs-7);
				}
				else if(this.boxArray[x][y] == 2) {
					context.fillStyle = "rgb(0,0,200)";
					context.fillRect(x*this.bs+5,y*this.bs+5,this.bs-7,this.bs-7);
				}
			}
		}	
	}

	//counts the total boxes by the passed player color
	this.findScore = function(color) {
		score = 0;
		for (var x = 0; x < this.bn; x++) {
			for (var y = 0; y < this.bn; y++) {<commit_msg>fixed indexing on hArray loop<commit_after>function Dots() {
	this.bn = 8;								//number of boxs
	this.bs = (Math.min(width,height) - 4) /8; 		//boxsize

	this.vArray = [];	//array of vertical lines
	this.hArray = [];	//array of horizontal lines
	this.boxArray = [];	//array of filled boxes
	this.blueTurn;

	//sends the starting game layout to wrapper
	this.callSendState = function(){
			var boardState = {
				vArray:				JSON.stringify(this.vArray), 
				hArray:				JSON.stringify(this.hArray), 
				boxArray:			JSON.stringify(this.boxArray), 
				blueTurn:			JSON.stringify(this.blueTurn),
			}
		sendStateToServer(JSON.stringify(boardState));
	}

	this.recieveState = function (boardString) {
		var boardState = 	JSON.parse(boardString);
		this.vArray = 		JSON.parse(boardState.vArray);
		this.hArray = 		JSON.parse(boardState.hArray);
		this.boxArray = 	JSON.parse(boardState.boxArray);
		this.blueTurn = 	JSON.parse(boardState.blueTurn);
		this.drawBoard();
	}

	//initilizes empty arrays representing game state
	this.startGame = function() {
		setupCanvasObjects();

		//fills this.this.vArray with 0s
		for (var x = 0; x < this.bn + 1; x++) {
			this.vArray[x] = [];
			for (var y = 0; y < this.bn; y++) {
				this.vArray[x][y] = false;
			}
		}
		
		//fills this.hArray with 0s
		for (var x = 0; x < this.bn; x++) {
			this.hArray[x] = [];
			for (var y = 0; y < this.bn + 1; y++) {
				this.hArray[x][y] = false;
			}
		}	
		
		//fills this.boxArray with 0s
		for (var x = 0; x < this.bn; x++) {
			this.boxArray[x] = [];
			for (var y = 0; y < this.bn; y++) {
				this.boxArray[x][y] = 0;
			}
		}	
		
		//sets starting player
		this.blueTurn = true;
		
		this.drawBoard();
		this.callSendState();
	}

	//clears canvas and redraws board
	this.drawBoard = function() {	
		//clears canvas
		context.fillStyle = "rgb(255,255,255)";
		context.fillRect(0, 0, width, height);
		
		//draw grid
		this.drawGrid();
		
		//draw lines placed by players
		this.drawLines();
		
		//draws filled boxs
		this.drawFilledBox();
	}	

	//draws grid of lines 
	this.drawGrid = function(){
		context.beginPath();
		//draw vertical lines
		for (var x=0; x<=this.bn*this.bs; x+= this.bs) {
			context.moveTo(x,0);
			context.lineTo(x,this.bn*this.bs);
		}
		
		//draw horizontal lines
		for (var y=0; y<=this.bn*this.bs; y+= this.bs) {
			context.moveTo(0,y);
			context.lineTo(this.bn*this.bs,y);
		}
		
		//fills in lines in offwhite
		context.strokeStyle = "rgb(190,190,190)";
		context.stroke();
		context.closePath();
	}

	//draws in lines clicked by player
	this.drawLines = function(){
		//lines are mostly with a little red or blue
		context.fillStyle = (this.blueTurn) ? "rgb(4,9,83)" : "rgb(103,3,3)";

		//draws vertical and horizontal lines
		for (var x = 0; x < this.bn + 1; x++) {
			for (var y = 0; y < this.bn; y++) {
				if (this.vArray[x][y]) { 
					context.fillRect(x*this.bs, y*this.bs, 4, this.bs+3);
				}
				if (this.hArray[y][x]) { 
					context.fillRect(y*this.bs, x*this.bs, this.bs+3, 4);
				}
			}
		}
	}

	//draws boxes surrounded by lines
	this.drawFilledBox = function(){
		for (var x = 0; x < this.bn; x++) {
			for (var y = 0; y < this.bn; y++) {
				if(this.boxArray[x][y] == 1) {
					context.fillStyle = "rgb(200,0,0)";
					context.fillRect(x*this.bs+5,y*this.bs+5,this.bs-7,this.bs-7);
				}
				else if(this.boxArray[x][y] == 2) {
					context.fillStyle = "rgb(0,0,200)";
					context.fillRect(x*this.bs+5,y*this.bs+5,this.bs-7,this.bs-7);
				}
			}
		}	
	}

	//counts the total boxes by the passed player color
	this.findScore = function(color) {
		score = 0;
		for (var x = 0; x < this.bn; x++) {
			for (var y = 0; y < this.bn; y++) {
{'fraction_non_alphanumeric': 0.17521834061135372, 'fraction_numerical': 0.021834061135371178, 'mean_word_length': 2.807272727272727, 'pattern_counts': {'":': 0, '<': 31, '<?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': '5666450', 'n_tokens_mistral': 3381, 'n_tokens_neox': 2855, 'n_words': 648}