Пример #1
0
    // This function should be called when we want this player to play
    public IEnumerator PlayTurn()
    {
        yield return(new WaitUntil(() => playerTurnIndex == globalTurn)); // only play when it is the current player's turn

        if (GameBoardInformation.isGameOver == true)
        {
            WriteTextFile.Write();
            yield break;
        }
        else
        {
            StartCoroutine(MakeMove()); // This is where the player will actually perform the move.
            yield return(new WaitUntil(() => finishedMove == true));

            finishedMove = false; // resets to false, to allow the player to play again
            GameTree.UpdateGameStateAndTree(lastMove);
            TechnicalStatistics.LastHeuristic    = GameTree.head.HeuristicValue;
            TechnicalStatistics.LastMoveString   = TechnicalStatistics.GetLastMoveString(GameTree.head, secondsPassed);
            TechnicalStatistics.totalTimePassed += secondsPassed;

            // once we reach here, all the parameters of TechnicalStatistics have been updated properly.
            // Therefore, we will add this move to our List of moves here.
            WriteTextFile.AddMove();

            GameBoardInformation.updateGameOver();
            globalTurn = (globalTurn + 1) % 2; // increase index to say that it is the other player's turn
            yield return(PlayTurn());
        }
    }
    // this function should be called at the end of every move, and AFTER all TechnicalStatistics have been updated, otherwise it will not output correct values
    public static void AddMove()
    {
        string str = TechnicalStatistics.ParametersAsText();

        MoveList.Add(str);
    }