// ostinato code in green var boardUi = null var initialBoard = "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1" var board = initialBoard var init = function() { var update = function() { aiMove = ostinato.randomAiMove(board) board = (!aiMove.success || aiMove.isCheckMate || aiMove.isDraw) ? initialBoard : aiMove.board boardUi.position(board) window.setTimeout(update, 600) } boardUi = ChessBoard('board', { moveSpeed: 'fast' }) boardUi.start() update() }