public static void ExecuteStatisticalAnalysis(GameSimluator simluator, SimulationConfig simulationConfig)
        {
            List <OneGameStatisticsDto> allGameStats = RunSimluations(simluator, simulationConfig.NumberOfIterations, simulationConfig.NumberOfProgressLogs, simulationConfig.MaxTurns);

            //export raw results
            RawStatisticDataCsvExporter.ExportRawGameStatsToFile(allGameStats);

            //do statistical analysis
            GameStatisticCalculator.CalculateAndWriteStatisticConclusions(allGameStats, simulationConfig.DurationOfOneMoveInSeconds);
        }
        public static SimulationConfig AskUserForSimulationConfig()
        {
            Console.WriteLine($"\r\n\r\nDefault simulation config:\r\n{SimulationConfig.Default.ToString()}.");
            Console.WriteLine($"Press ENTER to begin or input custom comma separated values.");
            string userResponse = Console.ReadLine();

            SimulationConfig simulationConfig;

            if (string.IsNullOrWhiteSpace(userResponse))
            {
                simulationConfig = SimulationConfig.Default;
            }
            else
            {
                string[] configValues = userResponse.Split(' ', ','); //space will also be considered as a separator

                if (configValues.Length < 4)
                {
                    Console.WriteLine($"WARNING: Some config values are missing. Using default config.");
                    simulationConfig = SimulationConfig.Default;
                }
                else
                {
                    try
                    {
                        simulationConfig = new SimulationConfig()
                        {
                            DurationOfOneMoveInSeconds = int.Parse(configValues[0]),
                            NumberOfIterations         = int.Parse(configValues[1]),
                            NumberOfProgressLogs       = int.Parse(configValues[2]),
                            MaxTurns = int.Parse(configValues[3])
                        };

                        Console.WriteLine($"Using user config:\r\n{simulationConfig.ToString()}.");
                    }
                    catch
                    {
                        Console.WriteLine($"WARNING: Parsign config values failed. Using default config.");
                        simulationConfig = SimulationConfig.Default;
                    }
                }
            }

            return(simulationConfig);
        }
Пример #3
0
        static void Main(string[] args)
        {
            GameSimluator simluator = new GameSimluator();

            //import board data
            SnakeOrLadderEntity[] gameBoard = GameBoardImporter.LoadGameBoard(IntputFileName);
            simluator.LoadGameBoard(gameBoard);

            //do a huge test
            SimulationConfig simulationConfig = UserInteraction.AskUserForSimulationConfig();

            MonteCarloAnalysis.ExecuteStatisticalAnalysis(simluator, simulationConfig);

            //exeute one test live
            Console.WriteLine("\r\n\r\nExecuting one game with live scores:");
            simluator.Simlulate(100, true);

            //keep program open
            Console.ReadLine();
        }