コード例 #1
0
 public DepthLimitedUCTTreeNode(IGameMove move, DepthLimitedUCTTreeNode parent, IGameState state, int depth, int maxDepth, IStateBestMoveEstimator stateEstimator, double constant = 1.0)
     : base(move, parent, state, constant, false)
 {
     this.maxDepth       = maxDepth;
     this.depth          = depth;
     this.stateEstimator = stateEstimator;
     if (depth <= maxDepth)
     {
         untriedMoves = state.GetMoves();
     }
     else
     {
         untriedMoves = new List <IGameMove>();
         if (!state.isTerminal())
         {
             IGameMove estimatedMove = stateEstimator.EstimateMove(state);
             state.DoMove(estimatedMove);
             AddChild(estimatedMove, state);
         }
         else
         {
             ITreeNode node = this;
             while (node != null)
             {
                 node.Update(state.GetResult(node.PlayerWhoJustMoved));
                 node = node.Parent;
             }
         }
     }
 }
コード例 #2
0
        public override ITreeNode AddChild(IGameMove move, IGameState state)
        {
            DepthLimitedUCTTreeNode n = new DepthLimitedUCTTreeNode(move, this, state, depth + 1, maxDepth, stateEstimator, constant);

            untriedMoves.Remove(move);
            childNodes.Add(n);
            return(n);
        }