示例#1
0
        public void Fight(IEngine engineA, IEngine engineB, BitBoard board, int index = 0)
        {
            var indexText  = index.ToString().PadLeft(6, '0');
            var targetFile = Path.Combine(fightPath,
                                          $"{indexText} {DateTime.Now:yyyy-MM-dd HH-mm} {engineA.Name}-{engineB.Name}.tmp");

            FightResult fightResult;

            using (var cc = ConsoleCopy.Create(targetFile))
            {
                Console.WriteLine("################### Begin #######################");
                Console.WriteLine("{0} ({2}) vs {1} ({3})", engineA.Name, engineB.Name, "Black", "White");

                fightResult = DoFight(engineA, engineB, board);

                Console.WriteLine("################### Result #######################");
                Console.WriteLine("{0}", fightResult);
                Console.WriteLine("#################### End #######################");
            }

            var score         = fightResult.WinnerName == engineA.Name ? fightResult.Score : -fightResult.Score;
            var newTargetFile = Path.Combine(fightPath,
                                             $"{indexText} {engineA.Name}-{engineB.Name} ({score}) {DateTime.Now:yyyy-MM-dd HH-mm}.txt");

            File.Move(targetFile, newTargetFile);
        }
示例#2
0
 public ConverterML(ConsoleCopy consoleCopy, string originalFilePath, string destinationFilePath, string originalPath, string replacePath)
 {
     this.consoleCopy     = consoleCopy;
     _originalFilePath    = originalFilePath;
     _destinationFilePath = destinationFilePath;
     _originalUrl         = originalPath;
     _destinationUrl      = replacePath;
 }
示例#3
0
            public static void CreateConsole(string path)
            {
                ReleaseConsole();
                AllocConsole();
                con = new ConsoleCopy(path);

                //Disable the X button on the console window
                EnableMenuItem(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_DISABLED);
            }
示例#4
0
 static void Main(string[] args)
 {
     try
     {
         ConsoleCopy.Create();
         var sw = Stopwatch.StartNew();
         DeepLearning.Test();
         sw.Stop();
         Console.WriteLine($"done! {sw.Elapsed}");
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
     Console.Read();
 }
示例#5
0
        public static void CreateConsole(string path = null)
        {
            if (!Debugger.IsAttached) //Don't override debugger's console
            {
                ReleaseConsole();
                AllocConsole();
            }

            if (!string.IsNullOrEmpty(path))
            {
                con = new ConsoleCopy(path);
            }

            //Disable the X button on the console window
            EnableMenuItem(GetSystemMenu(GetConsoleWindow(), false), SC_CLOSE, MF_DISABLED);
        }
示例#6
0
        public void Fight(IEngine engineA, IEngine engineB, string targetPath, BitBoard board)
        {
            var targetFile = Path.Combine(targetPath,
                                          string.Format("{0:yyyy-MM-dd HH-mm} {1}-{2}.txt", DateTime.Now, engineA.Name, engineB.Name));

            using (var cc = ConsoleCopy.Create(targetFile))
            {
                Console.WriteLine("################### Begin #######################");
                Console.WriteLine("{0} ({2}) vs {1} ({3})", engineA.Name, engineB.Name, "Black", "White");

                var fightResult = Fight(engineA, engineB, board);

                Console.WriteLine("################### Result #######################");
                Console.WriteLine("{0}", fightResult);
                Console.WriteLine("#################### End #######################");
            }
        }
示例#7
0
        static async Task Main()
        {
            // receive messages from the subscription



            //Console.SetOut(oldOut);


            using (var cc = new ConsoleCopy("output.json")) {
                Console.WriteLine("The application started at {0:HH:mm:ss.fff}", DateTime.Now);
                var task1 = Problem2.ReceiveMessagesFromSubscriptionAsync();
                var task2 = Problem1.ReceiveMessagesFromSubscriptionAsync();

                await Task.WhenAll(task1, task2);

                Console.WriteLine("Done");
            }
        }
示例#8
0
        static void Main(string[] args)
        {
            //try
            //{
            //  Check if action is present
            Settings setting = ParseInput(args);

            if (setting.ToolAction == ToolAction.Unknown)
            {
                PringUsage();
                return;
            }

            string      logPath    = String.Format("ConsoleLog-{0}-{1}.log", setting.ToolAction, DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss"));
            ConsoleCopy consoleLog = new ConsoleCopy(logPath);

            ConverterML converter = new ConverterML(consoleLog, setting.BlogMLFileName, setting.WRXFileName, setting.SourceImageUrl, setting.DestinationImageUrl);

            //We got Action
            switch (setting.ToolAction)
            {
            case ToolAction.RemoveComments:
                if (RequiredParametersPrintUsage(ToolAction.RemoveComments, args))
                {
                    converter.RemoveAllComments(setting.BlogMLFileName);
                    Console.WriteLine("All comments removed from the file : {0}", setting.BlogMLFileName);
                }
                break;

            case ToolAction.ExportToWRX:
                if (RequiredParametersPrintUsage(ToolAction.ExportToWRX, args))
                {
                    string wrxFileName = converter.GenerateWRXFile();
                    Console.WriteLine("Created WRX format");

                    //Generate ReDirect, SourceQA and TargetQA File
                    converter.GenerateHelperFiles(setting.SourceBaseUrl, setting.TargetBaseUrl, wrxFileName);
                }
                break;

            case ToolAction.QATarget:
                if (RequiredParametersPrintUsage(ToolAction.QATarget, args))
                {
                    converter.QATarget(setting.QATargetFileName);
                }
                break;

            case ToolAction.NewWRXWithOnlyFailedPosts:
                if (RequiredParametersPrintUsage(ToolAction.NewWRXWithOnlyFailedPosts, args))
                {
                    string wrxFileName = converter.GenerateWRXFileWithFailedPosts(setting.WRXFileName, setting.QAReportFileName);
                    Console.WriteLine("Successfully created WRX file with only error post names");
                }

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            Console.WriteLine("ALL Done");
            Console.ReadLine();

            //}
            //catch (Exception ex)
            //{
            //    Console.WriteLine(ex);
            //    Console.WriteLine();
            //    PringUsage();
            //}
            if (consoleLog != null)
            {
                consoleLog.Dispose();
            }
        }