Ejemplo n.º 1
0
        private static void Test()
        {
            int threshold = 400 * 1000 * 1000;

            while (true)
            {
                var           gsc     = new GameServerClient();
                TrainResponse problem = gsc.Train(TrainProblemType.Any, 15);
                Console.Out.WriteLine("==== TrainProblem: {0}", problem);

                Task <int> countTask = Task.Run(() =>
                {
                    IEnumerable <byte[]> trees = new BinaryBruteForcer(problem.operators).Enumerate(problem.size - 1);
                    return(trees.TakeWhile((t, i) => i < threshold).Count());
                });
                Stopwatch sw     = Stopwatch.StartNew();
                string    answer = ConcurrentWithoutShitAlphaProtocol.PostSolution(problem.id, problem.size,
                                                                                   problem.operators);
                sw.Stop();
                Console.Out.WriteLine("==== Solved, waiting for TreeSize...");
                countTask.Wait();
                Console.Out.WriteLine("==== SolvedIn: {0} ms, Answer: {1}, TreeSize: {2}", sw.ElapsedMilliseconds,
                                      answer,
                                      countTask.Result);
            }
        }
Ejemplo n.º 2
0
        public static void Run()
        {
            var gsc = new GameServerClient();

            while (true)
            {
                var problem = gsc.Train(TrainProblemType.Any, 14);
                log.DebugFormat("==== TrainProblem: {0}", problem);

                var solver = new Solver();
                var sw     = Stopwatch.StartNew();
                var answer = solver.Solve(problem.id, problem.size, problem.OperatorsExceptBonus, (args, values) => new SmartGenerator(args, values, problem.OperatorsExceptBonus).Enumerate(problem.size - 1));
                sw.Stop();
                log.DebugFormat("==== SolvedIn: {0} ms, Answer: {1}", sw.ElapsedMilliseconds, answer);
            }
        }