function isGameOver() {
  // Check the available moves for the current player
  const availableMoves = nowPlaying.map(
    (pieceType) => tilesWith(pieceType)
      .flat()
      .filter((sprite) => sprite.type === pieceType)
      .map((piece) => findPossibleMoves(arrToObj(translateXYToBoard(piece))))
  ).flat(2).length;

  // If the current playing player has no available moves, then it is game over
  if (availableMoves === 0) {
    // Determine the winning player by choosing the next player
    nextPlayer();

    // Show a message on the screen
    const winnerPlayer = nowPlaying === PLAYERS.BLACK ? "Black" : "White";
    addText("Game over!", { y: 5, color: color`3` });
    addText(`${winnerPlayer} has won!`, { y: 6, color: color`3` });
    addText("Press \"i\"", { y: 9, color: color`3` });
    addText("to play again", { y: 10, color: color`3` });

    // Enable the "i" (reset) button
    gameOver = true;
  }
}
Check whether the game should be considered over. If yes, set the gameOver variable to true