Esempio n. 1
0
 /// <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);
 }
Esempio n. 2
0
File: Game.cs Progetto: 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);
     }
 }
Esempio n. 3
0
File: Game.cs Progetto: 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);
 }
Esempio n. 4
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();
     }
 }
Esempio n. 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();
     }
 }
Esempio n. 6
0
 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 ')'.");
 }
Esempio n. 7
0
        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 ')'.");
            }
        }
Esempio n. 8
0
 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);
     }
 }