public static void GamePlayTestSolver(int tests, bool withSolver)
        {
            GoBoard    lGoBoard    = new GoBoard(19);
            GameRecord lGameRecord = new GameRecord();

            SGFCollection lSGFCollection = new SGFCollection();

            lSGFCollection.LoadSGFFromMemory(SGFGameSamples.GAME_1993_ZHONG_JIALIN_HANE_YASUMASA_1);
            lSGFCollection.RetrieveGame(lGameRecord, 0);

            SimpleTimer lSimpleTimer = new SimpleTimer();

            GameRecordBoardAdapter.Apply(lGameRecord, lGoBoard, true);
            //lGameRecord.Apply(lGoBoard, true);

            for (int i = 0; i < tests; i++)
            {
                if (withSolver)
                {
                    lGoBoard.SafetyStatusMap = null;
                    int lSafePoints = lGoBoard.CountSafePoints(Color.Black);
                    lSafePoints += lGoBoard.CountSafePoints(Color.White);
                }
            }

            lSimpleTimer.Stop();

            Console.Write("19x19 Game - Solver [ ");
            Console.Write("] # " + tests.ToString() + " times. ");
            Console.Write("Elapsed: " + lSimpleTimer.MilliSecondsElapsed.ToString() + " ms ");
            Console.WriteLine("Avg.: " + (lSimpleTimer.MilliSecondsElapsed / tests).ToString() + " ms ");

            return;
        }
예제 #2
0
        // temp. for testing
        /// <summary>
        /// Launches the test.
        /// </summary>
        /// <returns></returns>
        public static int LaunchTest2()
        {
            GoBoard    lGoBoard    = new GoBoard(9);
            GameRecord lGameRecord = new GameRecord();

            SGFCollection lSGFCollection = new SGFCollection();

            lSGFCollection.LoadSGFFromMemory(SGFGameSamples.DYER);
            lSGFCollection.RetrieveGame(lGameRecord);
            GameRecordBoardAdapter.Apply(lGameRecord, lGoBoard, false);

            lGoBoard.Dump();

            PatternCollection lPatternCollection = new PatternCollection(@"Patterns\test.db");

            NagCoordinator lNagCoordinator = new NagCoordinator(9999, lPatternCollection);

            lNagCoordinator.Initialize(lGoBoard);
            ThreadPoolHelperWithParam <int> .Execute(LaunchWorker, 9999);

            ThreadPoolHelperWithParam <int> .Execute(LaunchWorker, 9999);

            ThreadPoolHelperWithParam <int> .Execute(LaunchWorker, 9999);

            ThreadPoolHelperWithParam <int> .Execute(LaunchWorker, 9999);

            Thread.Sleep(1000 * 1);

            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);
            lNagCoordinator.CreateNagPoints(lGoBoard, -10000, 10000, Color.Black, 30, 0, 0, 1);


            Thread.Sleep(1000 * 300);

            return(0);
        }
예제 #3
0
        public static int CZD()
        {
            GameRecords lGameRecords = new GameRecords();

            lGameRecords.Load(@"Regression\CZD\Source", @"CZD_*.sgf", true);

            Dictionary <SafetyStatus, int> lSafetyUsage = new Dictionary <SafetyStatus, int>();

            foreach (GameRecord lGameRecord in lGameRecords.Games)
            {
                GoBoard lGoBoard = new GoBoard(19);
                GameRecordBoardAdapter.Apply(lGameRecord, lGoBoard);
                //lGameRecord.Apply(lGoBoard);

                foreach (GoCell lCell in lGoBoard.Cells)
                {
                    SafetyStatus lSafetyStatus = lGoBoard.GetSafetyStatus(lCell.Index);

                    if (lSafetyUsage.ContainsKey(lSafetyStatus))
                    {
                        lSafetyUsage[lSafetyStatus] += 1;
                    }
                    else
                    {
                        lSafetyUsage[lSafetyStatus] = 1;
                    }
                }

                Console.Write(".");
            }
            Console.WriteLine();
            foreach (SafetyStatus lSafetyStatus in lSafetyUsage.Keys)
            {
                Console.Write(lSafetyStatus.ToInteger());
                Console.Write(" | {0}", lSafetyStatus);
                Console.WriteLine(" | " + lSafetyUsage[lSafetyStatus].ToString());
            }

            MemFile lMemFile = new MemFile();

            lMemFile.WriteLine(lGameRecords.ToString());
            lMemFile.SaveFile(@"Regression\CZD\CZD-combined.sgf");

            SafetySolverType lSafetySolverType = SafetySolverType.Muller04;

            for (int i = 0; i < lGameRecords.Games.Count; i++)
            {
                GoBoard lGoBoard = new GoBoard(19);
                GameRecordBoardAdapter.Apply(lGameRecords[i], lGoBoard);
                //lGameRecords[i].Apply(lGoBoard);
                GameRecordBoardAdapter.UpdateTerritory(lGameRecords[i], lGoBoard);
                //lGameRecords[i].UpdateTerritory(lGoBoard);
                //Console.WriteLine(lGoBoard.ToString());
                Console.Write(i.ToString());
                Console.Write(" : ");
                Console.Write(lGoBoard.CountSafePoints(Color.Both, lSafetySolverType).ToString());
                Console.Write(" ");
                Console.Write(lGoBoard.CountSafePoints(Color.Black, lSafetySolverType).ToString());
                Console.Write(" ");
                Console.WriteLine(lGoBoard.CountSafePoints(Color.White, lSafetySolverType).ToString());
            }

            for (int i = 0; i < lGameRecords.Games.Count; i++)
            {
                MemFile lMemFile2 = new MemFile();
                lMemFile2.WriteLine(lGameRecords[i].ToString());
                lMemFile2.SaveFile(@"Regression\CZD\" + lGameRecords[i].GameName.Insert(3, "-") + ".sgf");
            }

            return(0);
        }