Skip to content

Instantly share code, notes, and snippets.

@parzibyte

parzibyte/cpu.js

Created Aug 5, 2020
Embed
What would you like to do?
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