2 ms·
Looks like computer moves randomly: /************************************************************* * Computer Move (random) *********************
by omoikane 2y ago
Looks like computer moves randomly:
/*************************************************************
* Computer Move (random)
*************************************************************/
function computerMove(){
if (gameOver) return;
let wasWhite=whiteToMove;
let moves=generateLegalMoves(wasWhite);
if (moves.length===0){
detectGameState();
return;
}
let randIndex=Math.floor(Math.random()*moves.length);
let move=moves[randIndex];
makeMove(move);
renderBoard();
detectGameState();
if (!wasWhite){
fullmoveNumber++;
}
}