Last active
December 11, 2015 02:09
-
-
Save rigibun/4528716 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Putable(board, x, y, turn){ | |
var count = 0; | |
for(var i = -1; i <= 1; i++){ | |
for(var j = -1; j <= 1; j++){ | |
if(i == 0 && j == 0) continue; | |
if(board[y + i][x + j] == 3 - turn){ | |
var k = i; | |
var l = j; | |
var incount = 0; | |
while(1){ | |
if(board[y + k][x + l] != 3 - turn){ | |
if(board[y + k][x + l] == turn) | |
count += incount; | |
break; | |
} | |
else{ | |
incount++; | |
k += i; | |
l += j; | |
} | |
} | |
} | |
} | |
} | |
if(count > 0) return true; | |
else return false; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment