7 ms·
Show HN: Battleboat.js – A robot that plays Battleship
- Graham42x 12y agoIt's reached a point where I can no longer beat the bot!
- yincrash 12y agowon my 3rd game. definitely hard
- amcnett 12y agoFun. It'd be nice if there were some kind of transition to display the bot's shots.
- wxm 12y agoWon my first game. [Evidence: http://frupic.frubar.net/32232 http://frupic.frubar.net/32232]
- have_faith 12y agoThanks for the evidence, I was doubting your posts authenticity.
- amenghra 12y agoI always wondered if playing on a hex-grid with some feedback on how close is the nearest ship would make the game more interesting?
- GoldenStake 12y agoOptimal 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 http://imgur.com/gallery/5jx3ARG
- christiangenco 12y agoI found a similar setup: http://imgur.com/aOaZYrs http://imgur.com/aOaZYrs It'd be fun to automate the process and find the absolute best strategy against this deterministic guessing algorithm. Edit: the only placement that actually matters is that of the smallest ship, ie: http://imgur.com/YQ01k95 http://imgur.com/YQ01k95
- urs2102 12y agoBeat 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!
- niix 12y agoAwesome! Won the first game, was feeling a bit worried at first!
- frozenport 12y agoIsn't there a rule that ship can't touch?
- kordless 12y agoWould have been a more appropriate post for yesterday, yar.
- sadkingbilly 12y agoThe 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; } }
- Kortaggio 12y agoThe 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.
- jaachan 12y agoI'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.