private void TryAddSupplementalNodes(MCTSManager manager, int maxNodes, MCTSNodesSelectedSet selectedNodes, ILeafSelector selector) { foreach ((MCTSNode parentNode, int selectorID, int childIndex) in ((LeafSelectorMulti)selector).supplementalCandidates) // TODO: remove cast { if (childIndex <= parentNode.NumChildrenExpanded - 1) { // This child was already selected as part of the normal leaf gathering process. continue; } else { MCTSEventSource.TestCounter1++; // Record visit to this child in the parent (also increments the child NInFlight counter) parentNode.UpdateRecordVisitsToChild(selectorID, childIndex, 1); MCTSNode node = parentNode.CreateChild(childIndex); ((LeafSelectorMulti)selector).DoVisitLeafNode(node, 1);// TODO: remove cast if (!parentNode.IsRoot) { if (selectorID == 0) { parentNode.Parent.Ref.BackupIncrementInFlight(1, 0); } else { parentNode.Parent.Ref.BackupIncrementInFlight(0, 1); } } // Try to process this node int nodesBefore = selectedNodes.NodesNN.Count; selector.InsureAnnotated(node); selectedNodes.ProcessNode(node); bool wasSentToNN = selectedNodes.NodesNN.Count != nodesBefore; //if (wasSentToNN) MCTSEventSource.TestCounter2++; // dje: add counter? } } }
private void TryAddRootPreloadNodes(MCTSManager manager, int maxNodes, MCTSNodesSelectedSet selectedNodes, ILeafSelector selector) { if (rootPreloader == null) { return; } List <MCTSNode> rootPreloadNodes = rootPreloader.GetRootPreloadNodes(manager.Root, selector.SelectorID, maxNodes, MCTSRootPreloader.PRELOAD_MIN_P); if (rootPreloadNodes != null) { for (int i = 0; i < rootPreloadNodes.Count; i++) { MCTSNode node = rootPreloadNodes[i]; selector.InsureAnnotated(node); selectedNodes.ProcessNode(node); } } }