Beispiel #1
0
    void End()
    {
        int blackPoints = gameState.CountPoints(gameState.Board, 1);
        int whitePoints = gameState.CountPoints(gameState.Board, 2);

        string scoreB = blackPoints.ToString();
        string scoreW = whitePoints.ToString();

        endText.enabled = true;
        endPanel.SetActive(true);

        if (blackPoints > whitePoints)
        {
            endText.text = "Koniec gry\nWygrał czarny\nZdobył " + scoreB + " punktów\nDzięki za grę";
            SaveResult("Black");
        }
        else if (blackPoints < whitePoints)
        {
            endText.text = "Koniec gry\nWygrał biały\nZdobył " + scoreW + " punktów\nDzięki za grę";
            SaveResult("White");
        }
        else
        {
            endText.text = "Koniec gry\nRemis\nDzięki za grę";
            SaveResult("Draw");
        }
        Restart();
    }
Beispiel #2
0
    public double rollOut(TreeNode tn)
    {
        Othello   rollGS       = new Othello(tn.gameState);
        bool      stillPlaying = true;
        double    rc           = 0;
        int       moveIndex;
        ArrayList am = rollGS.availableMoves();

        while (am.Count > 0 && stillPlaying)
        {
            moveIndex = r.Next(0, am.Count);

            int move = (int)am[moveIndex];
            rollGS.makeMove(move);

            rollGS.NextTurn();

            if (rollGS.CanMove(rollGS.Board) == false)
            {
                rollGS.NextTurn();

                if (rollGS.CanMove(rollGS.Board) == false)
                {
                    stillPlaying = false;
                    int blackPoints = rollGS.CountPoints(rollGS.Board, 1);
                    int whitePoints = rollGS.CountPoints(rollGS.Board, 2);

                    if (blackPoints > whitePoints)
                    {
                        rc = 1.0;
                    }
                    else if (blackPoints <= whitePoints)
                    {
                        rc = 0.0;
                    }
                }
            }
            am = rollGS.availableMoves();
        }

        return(rc);
    }