Ejemplo n.º 1
0
        public Node startNMCTS()
        {
            timer.Start();
            tree = new DeterministicNode(this.board.getBoardState(), null, NODE.NONE, Constant.NONE, Constant.NONE);
            tree.expand();
            tree.updateStatus(tree.rollOut(), tree.s);
            taskQueue jlhParallelThread = new taskQueue(base.jlhParallel);

            Task <DeterministicNode> searchTree = null;

            for (int i = 0; i < base.jlhParallel; i++)
            {
                searchTree = jlhParallelThread.enqueueReturn(move);
            }
            //sum winrate nondeterministic node
            for (int j = 0; j < searchTree.Result.children.Length; j++)
            {
                if (searchTree.Result.children[j] is NondeterministicNode)
                {
                    ((NondeterministicNode)searchTree.Result.children[j]).sumWinRate();
                }
            }

            DeterministicNode result = searchTree.Result;

            Node maxWinRate = result.children[0];

            for (int i = 1; i < result.children.Length; i++)
            {
                if (maxWinRate.winRate <= result.children[i].winRate)
                {
                    maxWinRate = result.children[i];
                }
            }

            jlhParallelThread.Dispose();

            return(maxWinRate);
        }