Zufallszüge

 

 

JavaScript

var board,
  game = new Chess();

var makeRandomMove = function() {
  var possibleMoves = game.moves();

  // exit if the game is over
  if (game.game_over() === true ||
    game.in_draw() === true ||
    possibleMoves.length === 0) return;

  var randomIndex = Math.floor(Math.random() * possibleMoves.length);
  game.move(possibleMoves[randomIndex]);
  board.position(game.fen());

  window.setTimeout(makeRandomMove, 500);
};

board = new ChessBoard('board', 'start');

window.setTimeout(makeRandomMove, 500);

HTML

<script src="js/chess.js"></script>
<div id="board" style="width: 400px"></div>