/// <summary> /// Create an SGFCollection object from a stream. /// </summary> public static SGFCollection Create(Stream stream) { var sgf = new SGFCollection(); using (var tr = new StreamReader(stream, Encoding.UTF8)) { sgf.Read(tr); } return(sgf); }
/// <summary> /// Parses an SGF game file and creates a list of games. /// </summary> /// <param name="path">The path to the SGF file.</param> /// <returns>A List<Game> containing all game trees in the SGF file.</returns> public static List <Game> SerializeFromSGF(string path) { using (StreamReader sr = new StreamReader(path, ASCIIEncoding.ASCII)) { SGFCollection coll = new SGFCollection(); coll.Read(sr); List <Game> games = new List <Game>(); foreach (var c in coll.GameTrees) { games.Add(new Game(c)); } return(games); } }
/// <summary> /// Parses an SGF game file and creates a list of games. /// </summary> /// <param name="path">The path to the SGF file.</param> /// <returns>A List<Game> containing all game trees in the SGF file.</returns> public static List<Game> SerializeFromSGF(string path) { using (StreamReader sr = new StreamReader(path, ASCIIEncoding.ASCII)) { SGFCollection coll = new SGFCollection(); coll.Read(sr); List<Game> games = new List<Game>(); foreach (var c in coll.GameTrees) games.Add(new Game(c)); return games; } }