Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameMode"/> class.
        /// </summary>
        public GameMode()
        {
            _gameSession = new GameSession();
            _gameSession.OnThinkingOutput += GameSession_OnThinkingOutput;

            _csvLogger = new CsvLogger(AILogsDirectory);

            _thinkingOutputEnabled = false;

            _engineColor = Color.Black;
            _enemyColor  = Color.White;

            _gameResultTokens = new Dictionary <string, GameResult>
            {
                { "1-0", GameResult.WhiteWon },
                { "0-1", GameResult.BlackWon },
                { "1/2-1/2", GameResult.Draw }
            };

            CommandsManager.AddCommandHandler(CommandType.Post, ExecutePostCommand);
            CommandsManager.AddCommandHandler(CommandType.NoPost, ExecuteNoPostCommand);
            CommandsManager.AddCommandHandler(CommandType.Time, ExecuteTimeCommand);
            CommandsManager.AddCommandHandler(CommandType.OTim, ExecuteOTimCommand);
            CommandsManager.AddCommandHandler(CommandType.White, ExecuteWhiteCommand);
            CommandsManager.AddCommandHandler(CommandType.Black, ExecuteBlackCommand);
            CommandsManager.AddCommandHandler(CommandType.Go, ExecuteGoCommand);
            CommandsManager.AddCommandHandler(CommandType.UserMove, ExecuteUserMoveCommand);
            CommandsManager.AddCommandHandler(CommandType.Result, ExecuteResultCommand);
        }
Ejemplo n.º 2
0
 //-------------
 //methods
 //-------------
 public GlobalObject()
 {
     mTagStorage = new TagStorage();
     csvLogger   = new CsvLogger();
     timer       = new Timer();
     mode        = Mode.Test;
 }
Ejemplo n.º 3
0
        public void StandardWriteDoesNotLog()
        {
            CsvLogger logger = new CsvLogger();

            logger.Write("Foo");
            logger.GetClipboardData().Data.Should().BeNull();
        }
Ejemplo n.º 4
0
        public Base()
        {
            csvLogger = new CsvLogger();
            helper    = new Helpers();

            // uncomment this line when there is a valid connection string

            //dBAdapter = new DBAdapter(Config.DataBase.ConnectionString);
        }
Ejemplo n.º 5
0
        public void SetTarget_Unset_Throws()
        {
            CsvLogger logger = new CsvLogger();

            Assert.Throws <Exception>(delegate
            {
                logger.Write(new LogMessage());
            });
        }
Ejemplo n.º 6
0
 public static void Initialize()
 {
     System.IO.Directory.CreateDirectory("logs");
     CreateItemLogger = new CsvLogger<CreateItemLog>(@"logs\createitem.csv") { TitleKey = "Logger_CreateItem" };
     CreateShipLogger = new CsvLogger<CreateShipLog>(@"logs\createship.csv") { TitleKey = "Logger_CreateShip" };
     MissionLogger = new CsvLogger<MissionLog>(@"logs\mission.csv") { TitleKey = "Expedition" };
     BattleDropLogger = new CsvLogger<BattleDropLog>(@"logs\drop.csv") { TitleKey = "Logger_Drop" };
     MaterialLogger = new MaterialLogger(@"logs\material.csv");
     BattleDetailLogger = new BattleDetailLogger();
 }
Ejemplo n.º 7
0
        public void Write_EmptyMessage_AppearsInFile()
        {
            CsvLogger logger = new CsvLogger();

            logger.SetTarget(".\\file.txt");

            logger.Write(new LogMessage());
            string text = File.ReadAllText(".\\file.txt");

            Assert.AreEqual("", text.Trim());
        }
Ejemplo n.º 8
0
    void displayResults()
    {
        ssvepOff();
        LoggerInterface logger = new CsvLogger("Streak.csv");

        logger.add(Start_Screen.profile);
        resultTitleText.text   = "Results";
        averageStreakText.text = "Average: " + resultsInSeconds(getAverageStreak());
        logger.add(resultsInSeconds(highscore));
        logger.add(resultsInSeconds(getAverageStreak()));
        logger.write();
    }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameMode"/> class.
        /// </summary>
        /// <param name="configManager">The configuration manager.</param>
        public GameMode(ConfigManager configManager) : base(configManager)
        {
            _gameSession = new GameSession();
            _csvLogger   = new CsvLogger(AILogsDirectory);

            _gameResultTokens = new Dictionary <string, GameResult>
            {
                { "1-0", GameResult.WhiteWon },
                { "0-1", GameResult.BlackWon },
                { "1/2-1/2", GameResult.Draw },
                { "aborted on move 1", GameResult.Aborted }
            };

            _gameSession.OnGameEnded += GameSession_OnGameEnded;
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameMode"/> class.
        /// </summary>
        /// <param name="configManager">The configuration manager.</param>
        public GameMode(ConfigManager configManager) : base(configManager)
        {
            var helperThreadsCount = configManager.GetValue <int>(HelperThreadsCountConfigKeyName);

            _gameSession = new GameSession(helperThreadsCount);
            _csvLogger   = new CsvLogger(AILogsDirectory);

            _gameResultTokens = new Dictionary <string, GameResult>
            {
                { "1-0", GameResult.WhiteWon },
                { "0-1", GameResult.BlackWon },
                { "1/2-1/2", GameResult.Draw },
                { "aborted on move 1", GameResult.Aborted }
            };

            _gameSession.OnGameEnded += GameSession_OnGameEnded;
        }
Ejemplo n.º 11
0
        public void TableLogs()
        {
            Table table = Table.Create(1, 1);

            table.AddRow("One", "Two");
            table.AddRow("Three", "Four");

            CsvLogger logger = new CsvLogger();

            logger.Write(table);
            Stream stream = logger.GetClipboardData().Data as Stream;

            stream.Position = 0;
            StreamReader reader = new StreamReader(stream);

            reader.ReadToEnd().Should().Be("\"One\",\"Two\"\r\n\"Three\",\"Four\"\r\n");
        }
        private void WriteLogCsvFile(CsvLogger data)
        {
            var path = Path.Combine(AssemblyHelper.GetCurrentExecutingAssemblyPath(), string.Format("{0}{1}", _outputRoot, "MsSqlPerformanceLogger.csv"));

            using (StreamWriter writer = new StreamWriter(path, append: true))
            {
                var Testwriter = new CsvWriter(writer);
                Testwriter.Configuration.Delimiter = ",";
                Testwriter.Configuration.AutoMap <CsvLogger>();
                Testwriter.Configuration.HasHeaderRecord = true;
                var record = new List <CsvLogger> {
                    data
                };
                Testwriter.WriteRecords(record);
                writer.Flush();
            }
        }
    public override void reset()
    {
        LoggerInterface logger = new CsvLogger("Power.csv");

        logger.add(Start_Screen.profile);
        logger.add(Math.Round(highscore * 100).ToString());
        logger.write();
        currentPoint = 0;
        currentPower = 0;
        lastPower    = 0;
        passedTest   = false;
        updateButtonColor(Color.white);
        setButtonText("Starting");
        slider.value = 0;
        secondRun    = true;
        reader       = null;
        device       = null;
        mainMenu.SetActive(true);
        currentPanel.SetActive(false);
    }
Ejemplo n.º 14
0
 public static void Initialize()
 {
     System.IO.Directory.CreateDirectory("logs");
     CreateItemLogger = new CsvLogger <CreateItemLog>(@"logs\createitem.csv")
     {
         TitleKey = "Logger_CreateItem"
     };
     CreateShipLogger = new CsvLogger <CreateShipLog>(@"logs\createship.csv")
     {
         TitleKey = "Logger_CreateShip"
     };
     MissionLogger = new CsvLogger <MissionLog>(@"logs\mission.csv")
     {
         TitleKey = "Expedition"
     };
     BattleDropLogger = new CsvLogger <BattleDropLog>(@"logs\drop.csv")
     {
         TitleKey = "Logger_Drop"
     };
     MaterialLogger     = new MaterialLogger(@"logs\material.csv");
     BattleDetailLogger = new BattleDetailLogger();
 }
Ejemplo n.º 15
0
        static void Main(string[] args)
        {
            var nsgaFactory   = new NsgaSolverFactory(new Random());
            var configuration = new ConfigurationProvider().GetConfiguration();

            configuration.PopulationSize = 300;
            configuration.MaxIterations  = 400;

            var mathSolver = nsgaFactory.GetMathSolver(configuration);

            var result = mathSolver.Solve();

            CsvLogger.RegisterLogger("math");

            foreach (var res in result.Fronts.First().Select(i => i.Evaluations))
            {
                CsvLogger.AddRow("math", new dynamic[] { res[0].Score, res[1].Score });
            }

            CsvLogger.Write("math", "math.csv");

            Console.WriteLine("done");
        }
Ejemplo n.º 16
0
            public ConsoleTaskLoggers(ITask task, IArgumentProvider arguments)
            {
                if (arguments.GetOption <bool?>(StandardOptions.Clipboard) ?? task.GetOptionDefault <bool>(StandardOptions.Clipboard[0]))
                {
                    _richTextLogger    = new RichTextLogger();
                    _csvLogger         = new CsvLogger();
                    _textLogger        = new TextLogger();
                    _spreadsheetLogger = new XmlSpreadsheetLogger();
                    _aggregatedLogger  = new AggregatedLogger(
                        ConsoleLogger.Instance,
                        _richTextLogger,
                        _spreadsheetLogger,
                        _csvLogger,
                        _textLogger);

                    RegisterLogger(LoggerType.Result, _aggregatedLogger);
                }
                else
                {
                    RegisterLogger(LoggerType.Result, ConsoleLogger.Instance);
                }

                RegisterLogger(LoggerType.Status, ConsoleLogger.Instance);
            }
Ejemplo n.º 17
0
        public async Task ExportCsv(string file)
        {
            var results = await _resultsService.GetResultsAsync();

            CsvLogger <SpeedTestResult> .WriteFile(results, file);
        }
Ejemplo n.º 18
0
 public FlightRecorder(Game game, params ICsvLoggable[] items)
     : base(game, 10000)
 {
     _logger = new CsvLogger(@"Logs\FlightRecording_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv", 1, ';');
     _logger.Register(items);
 }
Ejemplo n.º 19
0
        public static void TestOfNetwork(LnScraper scraper, string fileName, string networkType, string protocols, int size, int stepSize, int repeats, int ttl, bool subsetting)
        {
            using (var logger = new CsvLogger(fileName, true,
                                              "ProtocolType,NetworkType,NetworkSize,NoOutboundChannels,TTL,Repeats,Size,FoundPercentage"))
            {
                for (int i = 1; i < size; i = i + stepSize)
                {
                    try
                    {
                        var    testNodes          = scraper.CreateLnComp(i);
                        double noOutboundChannels = testNodes.Count(n => n.Connections.Count < 1);
                        int    networkSize        = testNodes.Count;

                        // dsdv test
                        if (protocols.Contains("DSDV"))
                        {
                            Random     rnd        = new Random();
                            List <int> rndIndexes = new List <int>();

                            for (int j = 0; j < 200; j++)
                            {
                                int r = rnd.Next(networkSize - 1);
                                if (rndIndexes.Contains(r))
                                {
                                    j--;
                                }
                                else
                                {
                                    rndIndexes.Add(r);
                                }
                            }

                            var dsdvNodes = CompositionBuilder.CreateDsdvNodes(testNodes, rndIndexes);
                            for (int reps = 1; reps < repeats; reps++)
                            {
                                var found = FindRoutesSubset(dsdvNodes, true, rndIndexes);
                                logger.WriteLine($"DSDV,{networkType},{networkSize},{noOutboundChannels},NAN,{reps},{i},{found}");
                            }
                        }

                        //dsr test
                        if (protocols.Contains("DSR"))
                        {
                            if (!subsetting)
                            {
                                var dsrNodes = CompositionBuilder.CreateDsrNodes(testNodes);
                                for (int j = 0; j < ttl; j++)
                                {
                                    for (int reps = 1; reps < repeats; reps++)
                                    {
                                        var found = TestReachability(dsrNodes, false, j, reps);
                                        logger.WriteLine($"DSR,{networkType},{networkSize},{noOutboundChannels},{j},{reps},{i},{found}");
                                    }
                                }
                            }
                            else
                            {
                                Random     rnd        = new Random();
                                List <int> rndIndexes = new List <int>();

                                for (int j = 0; j < 1000; j++)
                                {
                                    int r = rnd.Next(networkSize - 1);
                                    if (rndIndexes.Contains(r))
                                    {
                                        j--;
                                    }
                                    else
                                    {
                                        rndIndexes.Add(r);
                                    }
                                }

                                var dsrNodes = CompositionBuilder.CreateDsrNodes(testNodes, rndIndexes);
                                for (int j = 0; j < ttl; j++)
                                {
                                    for (int reps = 1; reps < repeats; reps++)
                                    {
                                        var found = FindRoutesSubset(dsrNodes, false, rndIndexes, j);
                                        logger.WriteLine($"DSR,{networkType},{networkSize},{noOutboundChannels},{j},{reps},{i},{found}");
                                    }
                                }
                            }
                        }

                        // zrp test
                        if (protocols.Contains("ZRP"))
                        {
                            var zrpNodes = CompositionBuilder.CreateZrpNodes(testNodes);
                            for (int j = 0; j < ttl; j++)
                            {
                                for (int reps = 1; reps < repeats; reps++)
                                {
                                    var found = TestReachability(zrpNodes, true, j, reps);
                                    logger.WriteLine($"ZRP,{networkType},{networkSize},{noOutboundChannels},{j},{reps},{i},{found}");
                                }
                            }
                        }

                        // zrp test
                        if (protocols.Contains("ZPRUNE"))
                        {
                            var zrpNodes = CompositionBuilder.CreateZrpNodes(testNodes, null, true);
                            for (int j = 0; j < ttl; j++)
                            {
                                for (int reps = 1; reps < repeats; reps++)
                                {
                                    var found = TestReachability(zrpNodes, true, j, reps);
                                    logger.WriteLine($"ZPRUNE,{networkType},{networkSize},{noOutboundChannels},{j},{reps},{i},{found}");
                                }
                            }
                        }
                    }
                    catch (Exception)
                    {
                        if (i > 1)
                        {
                            i -= stepSize;
                        }
                    }
                }
            }
        }
Ejemplo n.º 20
0
        public static void TestTableSize(LnScraper scraper, string fileName, string networkType, string protocols, int size, int stepSize, int repeats, int ttl)
        {
            using (var logger = new CsvLogger(fileName, true,
                                              "ProtocolType,NetworkType,NetworkSize,TTL,Repeats,Size,TableSize"))
            {
                for (int i = 1; i < size; i = i + stepSize)
                {
                    var testNodes   = scraper.CreateLnComp(i);
                    int networkSize = testNodes.Count;

                    // creates list of the indexes of the nodes we check. We check the same node in each protocol
                    int        subsetCount = (int)(networkSize * (2 / 100d)); // Test on 2% of the nodes
                    Random     rnd         = new Random();
                    List <int> rndIndexes  = new List <int>();

                    for (int j = 0; j < subsetCount; j++)
                    {
                        rndIndexes.Add(rnd.Next(networkSize - 1));
                    }

                    // dsdv test
                    if (protocols.Contains("DSDV"))
                    {
                        var dsdvNodes = CompositionBuilder.CreateDsdvNodes(testNodes, rndIndexes);
                        for (int reps = 1; reps < repeats; reps++)
                        {
                            double res = AvgTableSize(dsdvNodes, rndIndexes, 1);
                            logger.WriteLine($"DSDV,{networkType},{networkSize},NAN,{reps},{i},{res}");
                        }
                    }

                    //dsr test
                    if (protocols.Contains("DSR"))
                    {
                        var dsrNodes = CompositionBuilder.CreateDsrNodes(testNodes, rndIndexes);
                        for (int j = 0; j < ttl; j++)
                        {
                            for (int reps = 1; reps < repeats; reps++)
                            {
                                double res = AvgTableSize(dsrNodes, rndIndexes, 1, false);
                                logger.WriteLine($"DSR,{networkType},{networkSize},{j},{reps},{i},{res}");
                            }
                        }
                    }

                    // zrp test
                    if (protocols.Contains("ZRP"))
                    {
                        var zrpNodes = CompositionBuilder.CreateZrpNodes(testNodes, rndIndexes);
                        for (int j = 0; j < ttl; j++)
                        {
                            for (int reps = 1; reps < repeats; reps++)
                            {
                                double res = AvgTableSize(zrpNodes, rndIndexes, 1);
                                logger.WriteLine($"ZRP,{networkType},{networkSize},{j},{reps},{i},{res}");
                            }
                        }
                    }

                    // zrp prune test
                    if (protocols.Contains("ZPRUNE"))
                    {
                        var zrpNodes = CompositionBuilder.CreateZrpNodes(testNodes, rndIndexes, true);
                        for (int j = 0; j < ttl; j++)
                        {
                            for (int reps = 1; reps < repeats; reps++)
                            {
                                double res = AvgTableSize(zrpNodes, rndIndexes, 1);
                                logger.WriteLine($"ZPRUNE,{networkType},{networkSize},{j},{reps},{i},{res}");
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
 public FlightRecorder(Game game, params ICsvLoggable[] items)
     : base(game, 10000)
 {
     _logger = new CsvLogger(@"Logs\FlightRecording_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".csv", 1, ';');
     _logger.Register(items);
 }