Exemplo n.º 1
0
        // --------------------------------------------------------------------------------------------
        public void RecordVisitToTopLevelMove(MCTSNode leafNode, MCTSNodeStructIndex indexOfChildDescendentFromRoot, LeafEvaluationResult evalResult)
        {
#if NOT
            if (indexOfChildDescendentFromRoot == -1)
            {
                return;                                 // if the root
            }
            int childIndex = -1;
            Span <MCTSNodeStructChild> children = Root.Ref.Children;
            for (int i = 0; i < Root.NumChildrenExpanded; i++)
            {
                if (children[i].ChildIndex.Index == indexOfChildDescendentFromRoot)
                {
                    childIndex = i;
                    break;
                }
            }
            if (childIndex == -1)
            {
                throw new Exception("Internal error");
            }

            if (rootChildrenMovingAverageValues == null)
            {
                rootChildrenMovingAverageN             = new float[Root.NumPolicyMoves];
                rootChildrenMovingAverageValues        = new float[Root.NumPolicyMoves];
                rootChildrenMovingAverageSquaredValues = new float[Root.NumPolicyMoves];
            }

            float v    = evalResult.V * (leafNode.Depth % 2 == 0 ? -1 : 1);
            float diff = v - (float)Root.Ref.Children[childIndex].ChildRef.Q;

            const float C1 = 0.99f;
            const float C2 = 1.0f - C1;
Exemplo n.º 2
0
 /// <summary>
 /// Implements apply logic for nodes in a batch.
 /// </summary>
 /// <param name="nodes"></param>
 /// <param name="selectorID"></param>
 /// <param name="node"></param>
 /// <param name="evalResult"></param>
 void ApplyResult(Span <MCTSNodeStruct> nodes, int selectorID, MCTSNode node, LeafEvaluationResult evalResult)
 {
     ref MCTSNodeStruct nodeRef = ref node.Ref;