Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Last active August 5, 2020 19:01
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 parzibyte/d2479adf0d435cf5577145d84a07a406 to your computer and use it in GitHub Desktop.
Save parzibyte/d2479adf0d435cf5577145d84a07a406 to your computer and use it in GitHub Desktop.
isWinner(player, board) {
for (let y = 0; y < ROWS; y++) {
for (let x = 0; x < COLUMNS; x++) {
let count = 0;
count = this.countUp(x, y, player, board);
if (count >= CONNECT) return true;
count = this.countRight(x, y, player, board);
if (count >= CONNECT) return true;
count = this.countUpRight(x, y, player, board);
if (count >= CONNECT) return true;
count = this.countDownRight(x, y, player, board);
if (count >= CONNECT) return true;
}
}
return false;
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment