Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created August 5, 2020 21:50
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/17c6aaa49c911c3edbd4cda3d8c98787 to your computer and use it in GitHub Desktop.
Save parzibyte/17c6aaa49c911c3edbd4cda3d8c98787 to your computer and use it in GitHub Desktop.
async makeCpuMove() {
if (!this.isCpuPlaying || this.currentPlayer !== PLAYER_CPU) {
return;
}
const bestColumn = this.getBestColumnForCpu();
const firstEmptyRow = this.getFirstEmptyRow(bestColumn, this.board);
console.log({ firstEmptyRow });
Vue.set(this.board[firstEmptyRow], bestColumn, this.currentPlayer);
const status = await this.checkGameStatus();
if (!status) {
this.togglePlayer();
} else {
this.askUserForAnotherMatch();
}
},
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment