Beispiel #1
0
        /// <summary>
        /// Converts a game tree
        /// </summary>
        /// <param name="tree">SGF game tree</param>
        /// <returns>Game tree root</returns>
        private GameTree ConvertTree(SgfGameTree tree)
        {
            var boardSizeInt = tree.GetPropertyInSequence("SZ")?.Value <int>() ?? 19;

            if (boardSizeInt == 0)
            {
                boardSizeInt = 19;
            }
            GameBoardSize boardSize = new GameBoardSize(boardSizeInt);
            var           converted = ConvertBranch(tree, boardSize);
            var           ruleset   = new ChineseRuleset(boardSize);

            // Post-processing
            converted.ForAllDescendants((node) => node.Branches, node =>
            {
                if (node.Parent == null)
                {
                    node.FillBoardStateOfRoot(boardSize, ruleset);
                }
                else
                {
                    node.FillBoardState(ruleset);
                }
            });
            var gameTree = new GameTree(new ChineseRuleset(boardSize), boardSize, converted);

            gameTree.LastNode = gameTree.GameTreeRoot;
            return(gameTree);
        }
Beispiel #2
0
        /// <summary>
        /// Finds application info
        /// </summary>
        /// <returns>Application info</returns>
        private ApplicationInfo FindApplicationInfo()
        {
            var values =
                _inputTree.GetPropertyInSequence("AP")
                ?.PropertyValues.First() as SgfComposePropertyValue <string, string>;
            string name    = values?.LeftValue ?? "";
            string version = values?.RightValue ?? "";

            return(new ApplicationInfo(name, version));
        }