예제 #1
0
        public void Test_GenerateFiles()
        {
            string libDir     = Path.GetFileNameWithoutExtension(CodeBase.Get(Assembly.GetExecutingAssembly()));
            string dataDir    = Props.Global.Get("bds.DataDir");
            string workingDir = Directory.GetCurrentDirectory() + @"..\..\..\..\";

            GameDefinition gd = XmlSerializerExt.Deserialize <GameDefinition>(
                Path.Combine(dataDir, "ai.pkr.metastrategy.kuhn.gamedef.1.xml"));

            using (TextWriter tw = new StreamWriter(Path.Combine(workingDir, "p1.gv")))
            {
                GenTree tree = new GenTree {
                    GameDef      = gd, Kind = GenTree.TreeKind.PlayerTree,
                    HeroPosition = 1
                };
                DeckGenNode root = new DeckGenNode(tree, gd.MinPlayers);

                Vis vis = new Vis {
                    Output = tw
                };

                SetVisAttributes(vis);
                //vis.ShowExpr.Add(new ExprFormatter("s[d].Node.Id", "id:{1}"));
                vis.Walk(tree, root);
            }

            using (TextWriter tw = new StreamWriter(Path.Combine(workingDir, "g.gv")))
            {
                GenTree tree = new GenTree
                {
                    GameDef      = gd,
                    Kind         = GenTree.TreeKind.GameTree,
                    HeroPosition = 0
                };
                DeckGenNode root = new DeckGenNode(tree, gd.MinPlayers);

                Vis vis = new Vis {
                    Output = tw
                };

                SetVisAttributes(vis);
                //vis.ShowExpr.Add(new ExprFormatter("s[d].Node.Id", "id:{1}"));
                vis.Walk(tree, root);
            }
        }
예제 #2
0
        /// <summary>
        /// Build a tree for position pos.
        /// </summary>
        public void Build(ActionTree atTree, int pos)
        {
            //GetChild = (GenTree t, DeckGenNode n, ref int i, out DeckGenNode c) =>
            //               {
            //                   GenNode c1;
            //                   GenTree.TreeGetChild(t, n, ref i, out c)
            //               };

            _pos = pos;

            _atTree = atTree;
            _atTree.Positions[pos] = new ActionTreeNode();

            GenTree genTree = new GenTree {
                GameDef = _atTree.GameDef, Kind = GenTree.TreeKind.ActionTree
            };
            DeckGenNode genRoot = new DeckGenNode(genTree, 2);

            NodesCount = 0;
            Walk(genTree, genRoot);
        }