Skip to content

Instantly share code, notes, and snippets.

@twogood
Created May 28, 2015 05:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save twogood/1663de8a3590dd4f0acf to your computer and use it in GitHub Desktop.
Save twogood/1663de8a3590dd4f0acf to your computer and use it in GitHub Desktop.
Code of the day
function counter(colAdd, rowAdd) {
var count = 1;
var x, y;
for (x = move.col + colAdd, y = move.row + rowAdd;
isOwnedByCurrentPlayer(x, y);
count++, x += colAdd, y += rowAdd) {
}
for (x = move.col - colAdd, y = move.row - rowAdd;
isOwnedByCurrentPlayer(x, y);
count++, x -= colAdd, y -= rowAdd) {
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment