Exemplo n.º 1
0
        static async Task MainSearchAsync()
        {
            int initialWallet    = 28000;
            int simulationCount  = 0;
            var results          = new ConcurrentDictionary <double, SimulationResult>();
            var simulationRunner = new SimulationRunner();

            timer = new Timer((e) =>
            {
                try
                {
                    AnalyzeResults(results.ToList(), simulationCount);
                    Console.WriteLine($"Saved at {simulationCount} runs");
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }
            }, null, TimeSpan.FromMilliseconds(5000), TimeSpan.FromMilliseconds(5000));

            var games = await simulationRunner.LoadGames(new DateTime(2018, 09, 13, 22, 30, 0), new DateTime(2018, 09, 14, 6, 30, 0)).ConfigureAwait(false);

            games = games.OrderBy(g => g.Id).ToList();

            Console.WriteLine("launching Foreach");

            Parallel.ForEach(Enumerable.Range(1, 10000000),
                             new ParallelOptions {
                MaxDegreeOfParallelism = 8
            },
                             (count) =>
            {
                var controllerSettings = GenerateRandomControllerSettings();
                simulationCount++;
                simulationRunner = new SimulationRunner();
                var player       = new Player()
                {
                    Wallet = 45000
                };

                var controller = new RouletteController(
                    player, controllerSettings.BaseBet,
                    controllerSettings.Target,
                    controllerSettings.Multiplier,
                    controllerSettings.PassGames,
                    controllerSettings.Reducer);

                simulationRunner.StartWith(player, controller, games);
                player.ComputeStats();
                player.Bets.Clear();
                var controllerResults = controller.GetControllerResults();

                var simulationResult     = new SimulationResult(controllerSettings, controllerResults, player, initialWallet);
                player.ControllerResults = controller.ToString();
                results.TryAdd(simulationResult.TotalScore, simulationResult);
            });
        }
Exemplo n.º 2
0
        static async Task MainAsync()
        {
            int initialWallet    = 45000;
            var results          = new ConcurrentDictionary <ControllerSettings, Player>();
            var simulationRunner = new SimulationRunner();
            var games            = await simulationRunner.LoadGames(new DateTime(2018, 09, 13, 22, 30, 0), new DateTime(2018, 09, 14, 6, 30, 0)).ConfigureAwait(false);

            games            = games.OrderBy(g => g.Id).ToList();
            simulationRunner = new SimulationRunner();
            var player = new Player()
            {
                Wallet = initialWallet
            };

            var controllerSettings = new ControllerSettings()
            {
                BaseBet    = 4,
                Multiplier = 2.09,
                PassGames  = 7,
                Reducer    = 0.001,
                Target     = 7
            };

            var controller = new RouletteController(
                player, controllerSettings.BaseBet,
                controllerSettings.Target,
                controllerSettings.Multiplier,
                controllerSettings.PassGames,
                controllerSettings.Reducer);

            simulationRunner.StartWith(player, controller, games);
            player.ComputeStats();
            player.ControllerResults = controller.ToString();
            var controllerResults = controller.GetControllerResults();

            var simulationResult = new SimulationResult(controllerSettings, controllerResults, player, initialWallet);

            results.TryAdd(controllerSettings, player);
            Console.WriteLine(player);
            Console.WriteLine(controller);
            Console.WriteLine(simulationResult);
        }