Created
August 5, 2020 21:50
-
-
Save parzibyte/17c6aaa49c911c3edbd4cda3d8c98787 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
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