<commit_before><!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Battleboat!</title>
	<style>
	div {
		padding: 0;
		margin: 0;
	}
	.grid {
		height: 520px;
		width: 520px;
		border: 1px solid black;
	}
		.grid-row {
			width: 520px;
			height: 52px;
		}
			.grid-cell {
				height: 50px;
				width: 50px;
				display: inline-block;
				border: 1px solid black;
			}
				.grid-cell:hover {
					cursor: pointer;
				}
			.grid-ship {
				background-color: gray;
			}
			.grid-miss {
				background-color: blue;
			}
			.grid-hit {
				background-color: red;
			}
			.grid-sunk {
				background-color: black;
			}
	</style>
</head>
<body>
	<!-- Everything's on one line because of the whitespace bug that causes spacing between divs -->
	<div class="grid"><div class="grid-row grid-row-0"><div class="grid-cell grid-cell-0-0"></div><div class="grid-cell grid-cell-0-1"></div><div class="grid-cell grid-cell-0-2"></div><div class="grid-cell grid-cell-0-3"></div><div class="grid-cell grid-cell-0-4"></div><div class="grid-cell grid-cell-0-5"></div><div class="grid-cell grid-cell-0-6"></div><div class="grid-cell grid-cell-0-7"></div><div class="grid-cell grid-cell-0-8"></div><div class="grid-cell grid-cell-0-9"></div></div><div class="grid-row grid-row-1"><div class="grid-cell grid-cell-1-0"></div><div class="grid-cell grid-cell-1-1"></div><div class="grid-cell grid-cell-1-2"></div><div class="grid-cell grid-cell-1-3"></div><div class="grid-cell grid-cell-1-4"></div><div class="grid-cell grid-cell-1-5"></div><div class="grid-cell grid-cell-1-6"></div><div class="grid-cell grid-cell-1-7"></div><div class="grid-cell grid-cell-1-8"></div><div class="grid-cell grid-cell-1-9"></div></div><div class="grid-row grid-row-2"><div class="grid-cell grid-cell-2-0"></div><div class="grid-cell grid-cell-2-1"></div><div class="grid-cell grid-cell-2-2"></div><div class="grid-cell grid-cell-2-3"></div><div class="grid-cell grid-cell-2-4"></div><div class="grid-cell grid-cell-2-5"></div><div class="grid-cell grid-cell-2-6"></div><div class="grid-cell grid-cell-2-7"></div><div class="grid-cell grid-cell-2-8"></div><div class="grid-cell grid-cell-2-9"></div></div><div class="grid-row grid-row-3"><div class="grid-cell grid-cell-3-0"></div><div class="grid-cell grid-cell-3-1"></div><div class="grid-cell grid-cell-3-2"></div><div class="grid-cell grid-cell-3-3"></div><div class="grid-cell grid-cell-3-4"></div><div class="grid-cell grid-cell-3-5"></div><div class="grid-cell grid-cell-3-6"></div><div class="grid-cell grid-cell-3-7"></div><div class="grid-cell grid-cell-3-8"></div><div class="grid-cell grid-cell-3-9"></div></div><div class="grid-row grid-row-4"><div class="grid-cell grid-cell-4-0"></div><div class="grid-cell grid-cell-4-1"></div><div class="grid-cell grid-cell-4-2"></div><div class="grid-cell grid-cell-4-3"></div><div class="grid-cell grid-cell-4-4"></div><div class="grid-cell grid-cell-4-5"></div><div class="grid-cell grid-cell-4-6"></div><div class="grid-cell grid-cell-4-7"></div><div class="grid-cell grid-cell-4-8"></div><div class="grid-cell grid-cell-4-9"></div></div><div class="grid-row grid-row-5"><div class="grid-cell grid-cell-5-0"></div><div class="grid-cell grid-cell-5-1"></div><div class="grid-cell grid-cell-5-2"></div><div class="grid-cell grid-cell-5-3"></div><div class="grid-cell grid-cell-5-4"></div><div class="grid-cell grid-cell-5-5"></div><div class="grid-cell grid-cell-5-6"></div><div class="grid-cell grid-cell-5-7"></div><div class="grid-cell grid-cell-5-8"></div><div class="grid-cell grid-cell-5-9"></div></div><div class="grid-row grid-row-6"><div class="grid-cell grid-cell-6-0"></div><div class="grid-cell grid-cell-6-1"></div><div class="grid-cell grid-cell-6-2"></div><div class="grid-cell grid-cell-6-3"></div><div class="grid-cell grid-cell-6-4"></div><div class="grid-cell grid-cell-6-5"></div><div class="grid-cell grid-cell-6-6"></div><div class="grid-cell grid-cell-6-7"></div><div class="grid-cell grid-cell-6-8"></div><div class="grid-cell grid-cell-6-9"></div></div><div class="grid-row grid-row-7"><div class="grid-cell grid-cell-7-0"></div><div class="grid-cell grid-cell-7-1"></div><div class="grid-cell grid-cell-7-2"></div><div class="grid-cell grid-cell-7-3"></div><div class="grid-cell grid-cell-7-4"></div><div class="grid-cell grid-cell-7-5"></div><div class="grid-cell grid-cell-7-6"></div><div class="grid-cell grid-cell-7-7"></div><div class="grid-cell grid-cell-7-8"></div><div class="grid-cell grid-cell-7-9"></div></div><div class="grid-row grid-row-8"><div class="grid-cell grid-cell-8-0"></div><div class="grid-cell grid-cell-8-1"></div><div class="grid-cell grid-cell-8-2"></div><div class="grid-cell grid-cell-8-3"></div><div class="grid-cell grid-cell-8-4"></div><div class="grid-cell grid-cell-8-5"></div><div class="grid-cell grid-cell-8-6"></div><div class="grid-cell grid-cell-8-7"></div><div class="grid-cell grid-cell-8-8"></div><div class="grid-cell grid-cell-8-9"></div></div><div class="grid-row grid-row-9"><div class="grid-cell grid-cell-9-0"></div><div class="grid-cell grid-cell-9-1"></div><div class="grid-cell grid-cell-9-2"></div><div class="grid-cell grid-cell-9-3"></div><div class="grid-cell grid-cell-9-4"></div><div class="grid-cell grid-cell-9-5"></div><div class="grid-cell grid-cell-9-6"></div><div class="grid-cell grid-cell-9-7"></div><div class="grid-cell grid-cell-9-8"></div><div class="grid-cell grid-cell-9-9"></div></div></div>

	<script>
	// Battleship Clone
	// <NAME>, 2014
	// MIT License

	// This is one-player for now and you don't get to place your own ships yet but I'm going to update that later.
	// Currently the computer just places ships at random and you have to guess where they are but I'll work on an AI based on the DataGenetics algorithm: http://www.datagenetics.com/blog/december32011/

	
	// I know it's a global variable, but I couldn't think of how else to represent this and the ships available are a universal constant
	var availableships = ['carrier','battleship','destroyer','submarine','speedboat']

	function Game(size, numShips) {
		this.size = size;
		this.numShips = numShips;

		this.initialize = function() {
			// You are player 0 and the computer is player 1
			this.player0grid = new Grid(0, this.size);
			this.player1grid = new Grid(1, this.size);

			this.player0fleet = new Fleet(0, this.numShips);
			this.player1fleet = new Fleet(1, this.numShips);
		}
		this.initialize()
	}
	function Grid(player, size) {
		// Grid code:
		// 0 = water (empty)
		// 1 = undamaged ship
		// 2 = water with a cannonball in it (missed shot)
		// 3 = damaged ship (hit shot)
		this.size = size;
		this.cells = [];
		this.initialize = function() {
			for (var x = 0; x < this.size; x++) {
				var row = [];
				this.cells[x] = row;
				for (var y = 0; y < this.size; y++) {
					row.push(0)
				};
			};
		}
		this.initialize();
	}
	Grid.prototype.applyColor = function(x, y, type) {
		var classes = ['grid-cell','grid-cell-'+x+'-'+y,'grid-'+type]
		document.querySelector('.grid-cell-'+x+'-'+y).setAttribute('class', classes.join(" "))
	}

	function Fleet(player, numShips) {
		this.player = player;
		this.numShips = numShips;
		this.ships = [];
		this.populate = function(numShips) {
			for (var i = 0; i < this.numShips; i++) {
				// loop over the ship types when numShips > availableships.length
				var j = i % availableships.length;
				this.ships.push(new Ship(availableships[j]));
			};
		}
		this.populate();<commit_msg>Move init functions outside constructor<commit_after><!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Battleboat!</title>
	<style>
	div {
		padding: 0;
		margin: 0;
	}
	.grid {
		height: 520px;
		width: 520px;
		border: 1px solid black;
	}
		.grid-row {
			width: 520px;
			height: 52px;
		}
			.grid-cell {
				height: 50px;
				width: 50px;
				display: inline-block;
				border: 1px solid black;
			}
				.grid-cell:hover {
					cursor: pointer;
				}
			.grid-ship {
				background-color: gray;
			}
			.grid-miss {
				background-color: blue;
			}
			.grid-hit {
				background-color: red;
			}
			.grid-sunk {
				background-color: black;
			}
	</style>
</head>
<body>
	<!-- Everything's on one line because of the whitespace bug that causes spacing between divs -->
	<div class="grid"><div class="grid-row grid-row-0"><div class="grid-cell grid-cell-0-0"></div><div class="grid-cell grid-cell-0-1"></div><div class="grid-cell grid-cell-0-2"></div><div class="grid-cell grid-cell-0-3"></div><div class="grid-cell grid-cell-0-4"></div><div class="grid-cell grid-cell-0-5"></div><div class="grid-cell grid-cell-0-6"></div><div class="grid-cell grid-cell-0-7"></div><div class="grid-cell grid-cell-0-8"></div><div class="grid-cell grid-cell-0-9"></div></div><div class="grid-row grid-row-1"><div class="grid-cell grid-cell-1-0"></div><div class="grid-cell grid-cell-1-1"></div><div class="grid-cell grid-cell-1-2"></div><div class="grid-cell grid-cell-1-3"></div><div class="grid-cell grid-cell-1-4"></div><div class="grid-cell grid-cell-1-5"></div><div class="grid-cell grid-cell-1-6"></div><div class="grid-cell grid-cell-1-7"></div><div class="grid-cell grid-cell-1-8"></div><div class="grid-cell grid-cell-1-9"></div></div><div class="grid-row grid-row-2"><div class="grid-cell grid-cell-2-0"></div><div class="grid-cell grid-cell-2-1"></div><div class="grid-cell grid-cell-2-2"></div><div class="grid-cell grid-cell-2-3"></div><div class="grid-cell grid-cell-2-4"></div><div class="grid-cell grid-cell-2-5"></div><div class="grid-cell grid-cell-2-6"></div><div class="grid-cell grid-cell-2-7"></div><div class="grid-cell grid-cell-2-8"></div><div class="grid-cell grid-cell-2-9"></div></div><div class="grid-row grid-row-3"><div class="grid-cell grid-cell-3-0"></div><div class="grid-cell grid-cell-3-1"></div><div class="grid-cell grid-cell-3-2"></div><div class="grid-cell grid-cell-3-3"></div><div class="grid-cell grid-cell-3-4"></div><div class="grid-cell grid-cell-3-5"></div><div class="grid-cell grid-cell-3-6"></div><div class="grid-cell grid-cell-3-7"></div><div class="grid-cell grid-cell-3-8"></div><div class="grid-cell grid-cell-3-9"></div></div><div class="grid-row grid-row-4"><div class="grid-cell grid-cell-4-0"></div><div class="grid-cell grid-cell-4-1"></div><div class="grid-cell grid-cell-4-2"></div><div class="grid-cell grid-cell-4-3"></div><div class="grid-cell grid-cell-4-4"></div><div class="grid-cell grid-cell-4-5"></div><div class="grid-cell grid-cell-4-6"></div><div class="grid-cell grid-cell-4-7"></div><div class="grid-cell grid-cell-4-8"></div><div class="grid-cell grid-cell-4-9"></div></div><div class="grid-row grid-row-5"><div class="grid-cell grid-cell-5-0"></div><div class="grid-cell grid-cell-5-1"></div><div class="grid-cell grid-cell-5-2"></div><div class="grid-cell grid-cell-5-3"></div><div class="grid-cell grid-cell-5-4"></div><div class="grid-cell grid-cell-5-5"></div><div class="grid-cell grid-cell-5-6"></div><div class="grid-cell grid-cell-5-7"></div><div class="grid-cell grid-cell-5-8"></div><div class="grid-cell grid-cell-5-9"></div></div><div class="grid-row grid-row-6"><div class="grid-cell grid-cell-6-0"></div><div class="grid-cell grid-cell-6-1"></div><div class="grid-cell grid-cell-6-2"></div><div class="grid-cell grid-cell-6-3"></div><div class="grid-cell grid-cell-6-4"></div><div class="grid-cell grid-cell-6-5"></div><div class="grid-cell grid-cell-6-6"></div><div class="grid-cell grid-cell-6-7"></div><div class="grid-cell grid-cell-6-8"></div><div class="grid-cell grid-cell-6-9"></div></div><div class="grid-row grid-row-7"><div class="grid-cell grid-cell-7-0"></div><div class="grid-cell grid-cell-7-1"></div><div class="grid-cell grid-cell-7-2"></div><div class="grid-cell grid-cell-7-3"></div><div class="grid-cell grid-cell-7-4"></div><div class="grid-cell grid-cell-7-5"></div><div class="grid-cell grid-cell-7-6"></div><div class="grid-cell grid-cell-7-7"></div><div class="grid-cell grid-cell-7-8"></div><div class="grid-cell grid-cell-7-9"></div></div><div class="grid-row grid-row-8"><div class="grid-cell grid-cell-8-0"></div><div class="grid-cell grid-cell-8-1"></div><div class="grid-cell grid-cell-8-2"></div><div class="grid-cell grid-cell-8-3"></div><div class="grid-cell grid-cell-8-4"></div><div class="grid-cell grid-cell-8-5"></div><div class="grid-cell grid-cell-8-6"></div><div class="grid-cell grid-cell-8-7"></div><div class="grid-cell grid-cell-8-8"></div><div class="grid-cell grid-cell-8-9"></div></div><div class="grid-row grid-row-9"><div class="grid-cell grid-cell-9-0"></div><div class="grid-cell grid-cell-9-1"></div><div class="grid-cell grid-cell-9-2"></div><div class="grid-cell grid-cell-9-3"></div><div class="grid-cell grid-cell-9-4"></div><div class="grid-cell grid-cell-9-5"></div><div class="grid-cell grid-cell-9-6"></div><div class="grid-cell grid-cell-9-7"></div><div class="grid-cell grid-cell-9-8"></div><div class="grid-cell grid-cell-9-9"></div></div></div>

	<script>
	// Battleship Clone
	// <NAME>, 2014
	// MIT License

	// This is one-player for now and you don't get to place your own ships yet but I'm going to update that later.
	// Currently the computer just places ships at random and you have to guess where they are but I'll work on an AI based on the DataGenetics algorithm: http://www.datagenetics.com/blog/december32011/


	// I know it's a global variable, but I couldn't think of how else to represent this and the ships available are a universal constant
	var availableships = ['carrier','battleship','destroyer','submarine','speedboat']

	function Game(size, numShips) {
		this.size = size;
		this.numShips = numShips;
		this.initialize()
	}
	Game.prototype.initialize = function() {
		// You are player 0 and the computer is player 1
		this.player0grid = new Grid(0, this.size);
		// this.player1grid = new Grid(1, this.size);

		this.player0fleet = new Fleet(0, this.numShips);
		// this.player1fleet = new Fleet(1, this.numShips);
	}

	function Grid(player, size) {
		// Grid code:
		// 0 = water (empty)
		// 1 = undamaged ship
		// 2 = water with a cannonball in it (missed shot)
		// 3 = damaged ship (hit shot)
		this.size = size;
		this.cells = [];
		this.initialize();
	}
	Grid.prototype.initialize = function() {
		for (var x = 0; x < this.size; x++) {
			var row = [];
			this.cells[x] = row;
			for (var y = 0; y < this.size; y++) {
				row.push(0)
			};
		};
	}
	Grid.prototype.applyColor = function(x, y, type) {
		var classes = ['grid-cell','grid-cell-'+x+'-'+y,'grid-'+type]
		document.querySelector('.grid-cell-'+x+'-'+y).setAttribute('class', classes.join(" "))
	}

	function Fleet(player, numShips) {
		this.player = player;
		this.numShips = numShips;
		this.ships = [];
		this.populate();
	}
	Fleet.prototype.populate = function(numShips) {
		for (var i = 0; i < this.numShips; i++) {
			// loop over the ship types when numShips > availableships.length
			var j = i % availableships.length;
			this.ships.push(new Ship(availableships[j]));
		};
{'fraction_non_alphanumeric': 0.22957250182833588, 'fraction_numerical': 0.03417325975666512, 'mean_word_length': 4.119809394145677, 'pattern_counts': {'":': 0, '<': 479, '<?xml version=': 0, '>': 475, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4068690', 'n_tokens_mistral': 5815, 'n_tokens_neox': 5451, 'n_words': 1011}