IEnumerator SimulateTurn() { // have white move white.CalculateNextMove(chessBoard.boardState); yield return(new WaitForSeconds(timeToThinkWhite)); white.Stop(); // poll it out while (string.IsNullOrWhiteSpace(white.bestMove)) { yield return(new WaitForSeconds(0.3f)); } // update board state chessBoard.MovePiece(white.bestMove); // have black move black.CalculateNextMove(chessBoard.boardState); yield return(new WaitForSeconds(timeToThinkBlack)); black.Stop(); // poll it out while (string.IsNullOrWhiteSpace(black.bestMove)) { yield return(new WaitForSeconds(0.3f)); } // update board state chessBoard.MovePiece(black.bestMove); // end of turn turn = turn + 1; isSimulating = false; }