Пример #1
0
        public bool RetrieveGames(GameRecords gameRecords, bool includeVariations)
        {
            GameRecord lGameRecord = new GameRecord();

            foreach (SGFNode lSGFNode in Nodes)
            {
                if (!lSGFNode.RetrieveGame(lGameRecord))
                {
                    return(false);
                }
            }

            if (Variations.Count == 0)
            {
                gameRecords.AddGame(lGameRecord);
                return(true);
            }

            if (includeVariations)
            {
                foreach (SGFSequence lSGFSequence in Variations)
                {
                    if (!lSGFSequence.RetrieveGames(gameRecords, includeVariations, lGameRecord))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Пример #2
0
        public bool RetrieveGames(GameRecords gameRecords, bool includeVariations)
        {
            foreach (SGFSequence lSGFSequence in Sequence)
            {
                if (!lSGFSequence.RetrieveGames(gameRecords, includeVariations))
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
        public static int Investigate(string directory, string mask)
        {
            GameRecords lGameRecords = new GameRecords();

            lGameRecords.Load(directory, mask, true);

            List <GameRecordFilter.Result> lResults = GameRecordFilter.Filter(lGameRecords, GameRecordFilter.FindMovesInProtectedAreas);

            foreach (GameRecordFilter.Result lResult in lResults)
            {
                Console.WriteLine(lResult.GameRecord.GameName + " (" + lResult.MoveNbr.ToString() + ") ->  " + CoordinateSystem.ToString2(lResult.GameRecord[lResult.MoveNbr + 1].Move, lResult.GameRecord.BoardSize));
            }

            return(0);
        }
Пример #4
0
        public static List <Result> Filter(GameRecords gameRecords, FilterFunction filterFunction)
        {
            List <Result> lResults = new List <Result>();

            foreach (GameRecord lGameRecord in gameRecords)
            {
                CoordinateSystem lCoord   = new CoordinateSystem(lGameRecord.BoardSize);
                GoBoard          lGoBoard = new GoBoard(lGameRecord.BoardSize);

                for (int i = 0; i < lGameRecord.Count - 1; i++)
                {
                    lGoBoard.PlayStone(lGameRecord[i].Move, lGameRecord[i].Player, false);

                    int   lNextMove;
                    Color lNextPlayer;

                    if (i >= lGameRecord.Count)
                    {
                        lNextMove   = CoordinateSystem.PASS;
                        lNextPlayer = Color.Empty;
                    }
                    else
                    {
                        lNextMove   = lGameRecord[i + 1].Move;
                        lNextPlayer = lGameRecord[i + 1].Player;
                    }

                    if (filterFunction(lGoBoard, lGameRecord[i].Player, lGameRecord[i].Move, lNextPlayer, lNextMove))
                    {
//                    {
//                        Console.WriteLine(lGameRecord.GameName + " (" + i.ToString() + ") ->  " + lCoord.ToString(lNextMove));
                        lResults.Add(new Result(lGameRecord, i));
                    }
//                    }
                }
            }

            return(lResults);
        }
Пример #5
0
        public static List<Result> Filter(GameRecords gameRecords, FilterFunction filterFunction)
        {
            List<Result> lResults = new List<Result>();

            foreach (GameRecord lGameRecord in gameRecords)
            {
                CoordinateSystem lCoord = new CoordinateSystem(lGameRecord.BoardSize);
                GoBoard lGoBoard = new GoBoard(lGameRecord.BoardSize);

                for (int i = 0; i < lGameRecord.Count - 1; i++)
                {
                    lGoBoard.PlayStone(lGameRecord[i].Move, lGameRecord[i].Player, false);

                    int lNextMove;
                    Color lNextPlayer;

                    if (i >= lGameRecord.Count)
                    {
                        lNextMove = CoordinateSystem.PASS;
                        lNextPlayer = Color.Empty;
                    }
                    else
                    {
                        lNextMove = lGameRecord[i + 1].Move;
                        lNextPlayer = lGameRecord[i + 1].Player;
                    }

                    if (filterFunction(lGoBoard, lGameRecord[i].Player, lGameRecord[i].Move, lNextPlayer, lNextMove))
            //                    {
            //                        Console.WriteLine(lGameRecord.GameName + " (" + i.ToString() + ") ->  " + lCoord.ToString(lNextMove));
                        lResults.Add(new Result(lGameRecord, i));
            //                    }
                }
            }

            return lResults;
        }
Пример #6
0
        public static int Investigate(string directory, string mask)
        {
            GameRecords lGameRecords = new GameRecords();
            lGameRecords.Load(directory, mask, true);

            List<GameRecordFilter.Result> lResults = GameRecordFilter.Filter(lGameRecords, GameRecordFilter.FindMovesInProtectedAreas);

            foreach (GameRecordFilter.Result lResult in lResults)
                Console.WriteLine(lResult.GameRecord.GameName + " (" + lResult.MoveNbr.ToString() + ") ->  " + CoordinateSystem.ToString2(lResult.GameRecord[lResult.MoveNbr + 1].Move, lResult.GameRecord.BoardSize));

            return 0;
        }
Пример #7
0
        public static int IGS31()
        {
            GameRecords lGameRecords = new GameRecords();
            SGFCollection lSGFCollection = new SGFCollection(@"Regression\IGS_31\Source\IGS_31_counted.sgf");
            lGameRecords.Load(lSGFCollection, 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\IGS_31\IGS_31-combined.sgf");

            SafetySolverType lSafetySolverType = SafetySolverType.Muller97;

            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\IGS_31\IGS_31-" + ((i + 1).ToString()) + ".sgf");
            }

            return 0;
        }
Пример #8
0
        public bool RetrieveGames(GameRecords gameRecords, bool includeVariations)
        {
            foreach (SGFSequence lSGFSequence in Sequence)
                if (!lSGFSequence.RetrieveGames(gameRecords, includeVariations))
                    return false;

            return true;
        }
Пример #9
0
        public bool RetrieveGames(GameRecords gameRecords, bool includeVariations)
        {
            GameRecord lGameRecord = new GameRecord();

            foreach (SGFNode lSGFNode in Nodes)
                if (!lSGFNode.RetrieveGame(lGameRecord))
                    return false;

            if (Variations.Count == 0)
            {
                gameRecords.AddGame(lGameRecord);
                return true;
            }

            if (includeVariations)
                foreach (SGFSequence lSGFSequence in Variations)
                    if (!lSGFSequence.RetrieveGames(gameRecords, includeVariations, lGameRecord))
                        return false;

            return true;
        }
Пример #10
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);
        }