/// <summary> /// Constructor for selector over specified MCTSIterator. /// </summary> /// <param name="context"></param> /// <param name="selectorID"></param> /// <param name="priorSequence"></param> /// <param name="guessNumLeaves"></param> public LeafSelectorMulti(MCTSIterator context, int selectorID, PositionWithHistory priorSequence, int guessNumLeaves) { Debug.Assert(selectorID < ILeafSelector.MAX_SELECTORS); if (USE_CUSTOM_THREADPOOL) { tpm = tpmPool.Value.GetFromPool(); } SelectorID = selectorID; PriorSequence = priorSequence; paramsExecution = context.ParamsSearch.Execution; int maxNodesPerBatchForRootPreload = context.ParamsSearch.Execution.RootPreloadDepth > 0 ? MCTSSearchFlow.MAX_PRELOAD_NODES_PER_BATCH : 0; int extraLeafsDynamic = 0; if (context.ParamsSearch.PaddedBatchSizing) { extraLeafsDynamic = context.ParamsSearch.PaddedExtraNodesBase + (int)(context.ParamsSearch.PaddedExtraNodesMultiplier * guessNumLeaves); } leafs = new ListBounded <MCTSNode>(guessNumLeaves + maxNodesPerBatchForRootPreload + extraLeafsDynamic); Context = context; }
/// <summary> /// Shuts down the selector, restoring the thread pool back to the static pool /// </summary> public void Shutdown() { if (tpm != null) { tpmPool.Value.RestoreToPool(tpm); } tpm = null; }