17 comments

[ 4.6 ms ] story [ 50.7 ms ] thread
It's reached a point where I can no longer beat the bot!
won my 3rd game. definitely hard
Fun. It'd be nice if there were some kind of transition to display the bot's shots.
I always wondered if playing on a hex-grid with some feedback on how close is the nearest ship would make the game more interesting?
Optimal placement of the boats is pretty simple to find in games like this. After playing a round or two a simple pattern in the searching algorithm emerges.

After a few iterations of optimization you get the most moves before the bot finds your boat

Here is the setup: http://imgur.com/gallery/5jx3ARG

Beat it three times by simply clustering the boats together. Assumed that any program which will be 'good' at Battleship will also be one that will have an efficient way of searching for ships throughout the board. By clustering them all next to each other - the boat wastes moves searching the rest of the board. Cool regardless!
Awesome! Won the first game, was feeling a bit worried at first!
Would have been a more appropriate post for yesterday, yar.
The probability grid is very neat. One question though, it looks like Ship.DIRECTION_VERTICAL and Ship.DIRECTION_HORIZONTAL might be flipped. It seems consistent, so it's ok. Just the label "vertical" actually means "horizontal" and vice-versa.

  for (var i = 0; i < this.shipLength; i++) {
  if (direction === Ship.DIRECTION_VERTICAL) {
				if (this.playerGrid.cells[x + i][y] === CONST.TYPE_SHIP ||
					this.playerGrid.cells[x + i][y] === CONST.TYPE_MISS ||
					this.playerGrid.cells[x + i][y] === CONST.TYPE_SUNK) {
					return false;
				}
  }
The Ship.DIRECTION_VERTICAL and Ship.DIRECTION_HORIZONTAL are correct. :) It just seems backward because by a quirk of how the the grid cells are generated in JS, the x-direction is actually visually up/down and the y-direction is visually left/right.
I'm just getting "Please enable Javascript" Checking out the console I'm getting two "SecurityError: The operation is insecure." errors during the localStorage access, probably due to me disabling cookies. Can't find which domain the cookies are under so can't play it now.