Exemple #1
0
        public static IMove ComputeRootParallization(IGameState gameState, int itermax, bool verbose, Action<string> printfn, float uctk)
        {
            var rootNode = new MultiThreadedNode(null, null, gameState, uctk);
            var player = gameState.PlayerJustMoved;
            var processors = Environment.ProcessorCount;

            var tasks1 = (Enumerable.Range(0, processors).Select(i => Task.Factory.StartNew(() => ComputeFirstNodes(rootNode, player, itermax, gameState)))).ToArray();
            Task.WaitAll(tasks1);

            var tasks2 = (Enumerable.Range(0, processors).Select(i => Task.Factory.StartNew(() => Compute(rootNode, player, itermax, gameState)))).ToArray();
            Task.WaitAll(tasks2);
            return rootNode.MostVisitedMove();
        }
Exemple #2
0
        public static IMove ComputeRootParallization(IGameState gameState, int itermax, bool verbose, Action <string> printfn, float uctk)
        {
            var rootNode   = new MultiThreadedNode(null, null, gameState, uctk);
            var player     = gameState.PlayerJustMoved;
            var processors = Environment.ProcessorCount;

            var tasks1 = (Enumerable.Range(0, processors).Select(i => Task.Factory.StartNew(() => ComputeFirstNodes(rootNode, player, itermax, gameState)))).ToArray();

            Task.WaitAll(tasks1);

            var tasks2 = (Enumerable.Range(0, processors).Select(i => Task.Factory.StartNew(() => Compute(rootNode, player, itermax, gameState)))).ToArray();

            Task.WaitAll(tasks2);
            return(rootNode.MostVisitedMove());
        }