// Main game loop handling turns
    private IEnumerator GameLoop()
    {
        // Run game loop while the game isn't over (won/lost) or tied
        while (!board.state.GameOver && !board.state.GameTied)
        {
            board.state.turn = BoardState.GameTurn.Player;

            List <Point> PiecesToConvert_Player = new List <Point>();
            board.state.GenerateAvailableMoves();

            if (board.state.PossibleToMove)
            {
                board.state.WhiteCantMove = false;

                while (playerMove == null)
                {
                    yield return(null);
                }
                // Clears the debug log
                // ClearLog();

                Debug.Log("Player's turn.");

                if (board.state.AvailableMove(playerMove, ref PiecesToConvert_Player))
                {
                    Debug.Log("Converting pieces from " + playerMove.X + "," + playerMove.Y);
                    ConvertPieces(PiecesToConvert_Player);
                    Debug.Log("converted pieces from player");
                }
                else
                {
                    StartCoroutine(uiManager.ShowMessage("Invalid move.", 1));
                    playerMove = null;
                    continue;
                }
                //Debug.Log("Done player move");
            }
            else
            {
                Debug.Log("No possible player moves.");
                StartCoroutine(uiManager.ShowMessage("Player is unable to move.", 1));
                board.state.WhiteCantMove = true;
            }


            yield return(new WaitForSeconds(0.5f));


            // Check whether game over before computer turn
            //Debug.Log ("checking game over");
            GameOver(board.state.CheckGameOver());

            if (!board.state.GameOver)
            {
                Debug.Log("Computer's turn.");
                List <Point> PiecesToConvert_Computer = new List <Point>();

                board.state.turn = BoardState.GameTurn.Computer;
                board.state.GenerateAvailableMoves();

                // If the computer can move, make the best possible move
                if (board.state.PossibleToMove)
                {
                    board.state.BlackCantMove = false;

                    PiecesToConvert_Computer = aiManager.ComputerMoveMTCS();

                    Debug.Log("Converting pieces from " + PiecesToConvert_Computer[0].X + "," + PiecesToConvert_Computer[0].Y);
                    ConvertPieces(PiecesToConvert_Computer);
                }
                else
                {
                    Debug.Log("No possible computer moves.");
                    StartCoroutine(uiManager.ShowMessage("Computer is unable to move.", 1));
                    board.state.BlackCantMove = true;
                }
            }
            // Check whether game over before player turn

            GameOver(board.state.CheckGameOver());

            playerMove = null;
        }
    }