/// <summary> /// Startup method for Ceres UCI chess engine and supplemental features. /// </summary> /// <param name="args"></param> static void Main(string[] args) { #if DEBUG Console.WriteLine(); ConsoleUtils.WriteLineColored(ConsoleColor.Red, "*** WARNING: Ceres binaries built in Debug mode and will run much more slowly than Release"); #endif OutputBanner(); CheckRecursiveOverflow(); HardwareManager.VerifyHardwareSoftwareCompatability(); // Load (or cause to be created) a settings file. if (!CeresUserSettingsManager.DefaultConfigFileExists) { Console.WriteLine(); ConsoleUtils.WriteLineColored(ConsoleColor.Red, $"*** NOTE: Configuration file {CeresUserSettingsManager.DefaultCeresConfigFileName} not found in working directory."); Console.WriteLine(); Console.WriteLine($"Prompting to for required values to initialize:"); CeresUserSettingsManager.DoSetupInitialize(); } // Configure logging level const bool LOG = false; CeresEnvironment.MONITORING_EVENTS = LOG; LogLevel logLevel = LOG ? LogLevel.Information : LogLevel.Critical; LoggerTypes loggerTypes = LoggerTypes.WinDebugLogger | LoggerTypes.ConsoleLogger; CeresEnvironment.Initialize(loggerTypes, logLevel); CeresEnvironment.MONITORING_METRICS = CeresUserSettingsManager.Settings.LaunchMonitor; // if (CeresUserSettingsManager.Settings.DirLC0Networks != null) // NNWeightsFilesLC0.RegisterDirectory(CeresUserSettingsManager.Settings.DirLC0Networks); MCTSEngineInitialization.BaseInitialize(); Console.WriteLine(); #if DEBUG CheckDebugAllowed(); #endif if (args.Length > 0 && args[0].ToUpper() == "CUSTOM") { TournamentTest.Test(); return; // SuiteTest.RunSuiteTest(); return; } StringBuilder allArgs = new StringBuilder(); for (int i = 0; i < args.Length; i++) { allArgs.Append(args[i] + " "); } string allArgsString = allArgs.ToString(); DispatchCommands.ProcessCommand(allArgsString); // Win32.WriteCrashdumpFile(@"d:\temp\dump.dmp"); }
// In order to enable dotnet-counters you need to install dotnet-counters tool with the following command (use cmd) // dotnet tool install --global dotnet-counters // link: https://docs.microsoft.com/en-us/dotnet/core/diagnostics/dotnet-counters#:~:text=dotnet-counters%20is%20a%20performance%20monitoring%20tool%20for%20ad-hoc,values%20that%20are%20published%20via%20the%20EventCounter%20API. static void Main(string[] args) { // You need to change to font to SimSun-ExtB in order to show unicode characters in console - IMPORTANT Console.OutputEncoding = System.Text.Encoding.UTF8; InitCommands(); OutputBanner(); LaunchConsoleMonitor(); // If console app is started without args: if (args.Length == 0) { while (!Commands.All(e => e.Value)) { var required = GetRequiredCommand(); if (required == "RUN") { ConsoleUtils.WriteLineColored(ConsoleColor.Cyan, $"\nSolver is running ..."); DispatchCommands.ProcessCommand("RUN", "ok"); var runAgain = true; while (runAgain) { Console.WriteLine("\nRun again to debug memory usage?"); Console.WriteLine("\tYes or No\n"); var runAgainAnswer = Console.ReadLine().Trim().ToLower(); if (runAgainAnswer.Equals("yes") || runAgainAnswer.Equals("y")) { Console.WriteLine(); DispatchCommands.ProcessCommand("RUN", "ok"); } else { runAgain = false; } } break; } ConsoleUtils.WriteLineColored(ConsoleColor.Cyan, $"Enter a {required} "); Console.WriteLine($"\t{AvailableCommands[required]}"); var userInput = Console.ReadLine().Trim().ToLower(); if (userInput.Equals("help") || userInput.Equals("-h")) { HelpCommands.ProcessHelpCommand(userInput); } else { var ok = DispatchCommands.ProcessCommand(required, userInput); if (ok) { Commands[required] = true; if (required.Trim().ToUpper() == "BOARDSIZE") { BoardSize = Convert.ToSByte(userInput); } } } } } // Console app is started with custom args: else { for (var i = 0; i < args.Length; i++) { (string key, string value) = ParseInput(args[i]); var ok = DispatchCommands.ProcessCommand(key, value); if (ok) { Commands[key.ToUpper()] = true; if (key.Equals("BOARDSIZE")) { BoardSize = Convert.ToSByte(value); } } } if (GetRequiredCommand() == "RUN") { ConsoleUtils.WriteLineColored(ConsoleColor.Cyan, "Solver is running:\n"); DispatchCommands.ProcessCommand("RUN", "ok"); } } }