Exemplo n.º 1
0
 // Use this for initialization
 void Awake()
 {
     gameModel  = new Game();
     skySquishy = new MCTSkyNet(gameModel, RLBrain.startInd);
     FindObjectOfType <HandRender>().InitHand();
     FindObjectOfType <BoardRenderer>().initBoard();
     FindObjectOfType <ClaimGameRenderer>().initClaims();
 }
Exemplo n.º 2
0
    public void TrainOfThought(object stateInfo)
    {
        IGame     game           = new Game();
        MCTSkyNet squishyThought = new MCTSkyNet(game, game.isPlayerOneTurn());

        for (int i = 0; i < numPlaythroughs; i++)
        {
            squishyThought.MCTSSingleIteration();
        }
        SkyNetNode newRoot = squishyThought.GetRoot();
    }
Exemplo n.º 3
0
    public void Test(object obj)
    {
        object[] objArr          = obj as object[];
        int      numGames        = (int)objArr[0];
        int      i               = (int)objArr[1];
        int      numPlaythroughs = (int)objArr[2];
        int      bundleNum       = (int)objArr[3];

        Log(i, "STARTING", bundleNum, numGames, numPlaythroughs);

        IGame game = new Game(constDecks[i]);

        MCTSkyNet  squishyThought   = new MCTSkyNet(game, numPlaythroughs, 5.0f, i, bundleNum, numGames);
        bool       curBoardTerminal = false;
        int        moveCnt          = 0;
        SkyNetNode gameNode         = squishyThought.GetRoot();

        while (!curBoardTerminal)
        {
            SkyNetNode picked = squishyThought.PickOfficialMove(game, gameNode, numPlaythroughs, i, moveCnt);


            //Debug.Assert(picked.playerOne == game.isPlayerOneTurn());
            MakeMove(game, picked.move);
            //Console.Write(gameNode.ToString());
            moveCnt++;
            //Console.WriteLine(moveCnt);
            //float winRate = picked.visitCnt == 0 ? 0 : (picked.winCnt / picked.visitCnt);
            //string winPercent = winRate.ToString();
            //Log(i, String.Format("Move: {0}", moveCnt), bundleNum, numGames, numPlaythroughs);
            //Log(i, String.Format("Move: {0} -- Win Rate: {1}", moveCnt, winPercent), bundleNum, numGames, numPlaythroughs);
            if (picked.isTerminal())
            {
                curBoardTerminal = true;
                int winningPlayer = picked.playerOne ? 1 : 2;
                Log(i, String.Format("ENDING -- PLAYER {0} WIN -- MOVES {1}", winningPlayer, moveCnt), bundleNum, numGames, numPlaythroughs);
                continue;
            }
            else if (moveCnt >= maxMoves)
            {
                curBoardTerminal = true;
                Log(i, "GAME ENDING -- STALEMATE -- MOVES " + moveCnt.ToString(), bundleNum, numGames, numPlaythroughs);
                continue;
            }
            //updateRootList(squishyThought.GetRoot());
            gameNode = picked;
        }

        //updateRootList(squishyThought.GetRoot());
        Save(squishyThought.GetRoot(), bundleNum, numGames, numPlaythroughs);
    }