|
|
|
|
|
by sadkingbilly
4291 days ago
|
|
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;
}
}
|
|