// temp. for testing static void MatrixCompileToFile() { PatternCollection lPatterns = new PatternCollection(); if (!lPatterns.Load(@"Patterns/fuseki9.db")) { Console.WriteLine("ERROR: Unable to load patterns"); return; } Console.WriteLine("STATUS: Loaded " + lPatterns.Count + " Patterns."); SimpleTimer lTimer = new SimpleTimer(); Console.WriteLine(lTimer.StartTime.ToString()); DFAMatrixBuilder lDFAMatrixBuilder = new DFAMatrixBuilder(); lDFAMatrixBuilder.Add(lPatterns); Console.WriteLine(DateTime.Now.ToString()); lDFAMatrixBuilder.BuildThreaded(); Console.WriteLine(DateTime.Now.ToString()); Console.WriteLine("Seconds: " + lTimer.SecondsElapsed.ToString()); MemFile lMemFile = new MemFile(); lMemFile.Write(lDFAMatrixBuilder.GetMatrix().ToString()); lMemFile.SaveFile(@"Patterns/fuseki9.cdb"); }
public bool SaveSGFFile(string filename) { MemFile lMemFile = new MemFile(); lMemFile.Clear(); lMemFile.Write(ToString()); return(lMemFile.SaveFile(filename)); }
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; }
public bool SaveSGFFile(string filename) { MemFile lMemFile = new MemFile(); lMemFile.Clear(); lMemFile.Write(ToString()); return lMemFile.SaveFile(filename); }
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); }