コード例 #1
0
ファイル: Game.cs プロジェクト: paviad/GoSharp
 /// <summary>
 /// Constructs a root game object, along with a complete game tree from
 /// the specified SGFGameTree object.
 /// </summary>
 /// <param name="sgfGameTree">The SGF game tree object.</param>
 public Game(SGFGameTree sgfGameTree)
 {
     //GameInfo = CreateGameInfoFromSGF(sgfGameTree);
     //InitializeFromGameInfo();
     GameInfo = new GameInfo() { FreePlacedHandicap = true };
     CreateGameTree(sgfGameTree, this);
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: serd/GoSharp
 private static void CreateGameTree(SGFGameTree root, Game p)
 {
     if (p.GameInfo != null)
     {
         foreach (var m in root.Sequence.GetRootProperties())
         {
             if (PropertyHandlers.ContainsKey(m.Name))
             {
                 PropertyHandlers[m.Name](p, m);
             }
             if (!PropertiesToExclude.Contains(m.Name))
             {
                 p.sgfProperties.Add(m);
             }
         }
         p.InitializeFromGameInfo();
     }
     foreach (var m in root.Sequence.GetProperties())
     {
         if (PropertyHandlers.ContainsKey(m.Name))
         {
             p = PropertyHandlers[m.Name](p, m);
         }
         if (!PropertiesToExclude.Contains(m.Name))
         {
             p.sgfProperties.Add(m);
         }
     }
     foreach (var r in root.GameTrees)
     {
         CreateGameTree(r, p);
     }
 }
コード例 #3
0
ファイル: Game.cs プロジェクト: serd/GoSharp
 /// <summary>
 /// Constructs a root game object, along with a complete game tree from
 /// the specified SGFGameTree object.
 /// </summary>
 /// <param name="sgfGameTree">The SGF game tree object.</param>
 public Game(SGFGameTree sgfGameTree)
 {
     //GameInfo = CreateGameInfoFromSGF(sgfGameTree);
     //InitializeFromGameInfo();
     GameInfo = new GameInfo()
     {
         FreePlacedHandicap = true
     };
     CreateGameTree(sgfGameTree, this);
 }
コード例 #4
0
ファイル: SGFCollection.cs プロジェクト: nerai/GoSharp
 /// <summary>
 /// Parse an SGFCollection object from a TextReader.
 /// </summary>
 /// <param name="sr">The source TextReader.</param>
 public void Read(TextReader sr)
 {
     sr.EatWS();
     while ((char)sr.Peek() == '(')
     {
         var gameTree = new SGFGameTree();
         gameTree.Read(sr);
         GameTrees.Add(gameTree);
         sr.EatWS();
     }
 }
コード例 #5
0
 /// <summary>
 /// Parse an SGFCollection object from a TextReader.
 /// </summary>
 /// <param name="sr">The source TextReader.</param>
 public void Read(TextReader sr)
 {
     sr.EatWS();
     while ((char)sr.Peek() == '(')
     {
         var gameTree = new SGFGameTree();
         gameTree.Read(sr);
         GameTrees.Add(gameTree);
         sr.EatWS();
     }
 }
コード例 #6
0
ファイル: SGFGameTree.cs プロジェクト: nerai/GoSharp
 internal void Read(TextReader sr)
 {
     char c = (char)sr.Read();
     if (c != '(')
         throw new InvalidDataException("Game-tree doesn't begin with a '('.");
     Sequence.Read(sr);
     sr.EatWS();
     while ((char)sr.Peek() == '(')
     {
         SGFGameTree gameTree = new SGFGameTree();
         gameTree.Read(sr);
         GameTrees.Add(gameTree);
         sr.EatWS();
     }
     c = (char)sr.Read();
     if (c != ')')
         throw new InvalidDataException("Game-tree doesn't end with a ')'.");
 }
コード例 #7
0
ファイル: SGFGameTree.cs プロジェクト: serd/GoSharp
        internal void Read(TextReader sr)
        {
            char c = (char)sr.Read();

            if (c != '(')
            {
                throw new InvalidDataException("Game-tree doesn't begin with a '('.");
            }
            Sequence.Read(sr);
            sr.EatWS();
            while ((char)sr.Peek() == '(')
            {
                SGFGameTree gameTree = new SGFGameTree();
                gameTree.Read(sr);
                GameTrees.Add(gameTree);
                sr.EatWS();
            }
            c = (char)sr.Read();
            if (c != ')')
            {
                throw new InvalidDataException("Game-tree doesn't end with a ')'.");
            }
        }
コード例 #8
0
ファイル: Game.cs プロジェクト: nerai/GoSharp
 private static void CreateGameTree(SGFGameTree root, Game p)
 {
     if (p.GameInfo != null)
     {
         foreach (var m in root.Sequence.GetRootProperties())
         {
             if (PropertyHandlers.ContainsKey(m.Name))
                 PropertyHandlers[m.Name](p, m);
             if (!PropertiesToExclude.Contains(m.Name))
                 p.sgfProperties.Add(m);
         }
         p.InitializeFromGameInfo();
     }
     foreach (var m in root.Sequence.GetProperties())
     {
         if (PropertyHandlers.ContainsKey(m.Name))
             p = PropertyHandlers[m.Name](p, m);
         if (!PropertiesToExclude.Contains(m.Name))
             p.sgfProperties.Add(m);
     }
     foreach (var r in root.GameTrees)
     {
         CreateGameTree(r, p);
     }
 }