Exemplo n.º 1
0
 public static void ToHTML(string directory, GameTree.GameTree tree)
 {
     ToHTML(directory, tree.Root, tree);
     foreach (int key in tree.Tree.Keys)
     {
         ToHTML(directory, tree.GetNode(key), tree);
     }
 }
Exemplo n.º 2
0
        // Given a game tree node, creates an HTML representation.
        public static void ToHTML(string directory, GameTreeNode root, GameTree.GameTree tree)
        {
            string file = directory + "node-" + root.ID + ".html";

            using (StreamWriter writer = new StreamWriter(file, false))
            {
                writer.WriteLine("<html>");
                writer.WriteLine("<body>");
                writer.WriteLine("<b>Plays</b><br />");
                writer.WriteLine(root.TimesPlayed + "<br /><br />");
                writer.WriteLine("<b>Wins</b><br />");
                writer.WriteLine(root.Wins + "<br /><br />");
                writer.WriteLine("<b>Interval</b><br />");
                writer.WriteLine(tree.GetInterval(root.ID) + "<br /><br />");
                if (root.State.Predicates.Count > 0)
                {
                    writer.WriteLine("<b>State</b><br />");
                }
                foreach (Predicate pred in root.State.Predicates)
                {
                    writer.WriteLine(pred + "<br />");
                }
                //if (root.Problem.Initial.Count > 0)
                //    writer.WriteLine("<br /><b>Observed State</b><br />");
                //foreach (Predicate pred in root.Problem.Initial)
                //    if ((bool)pred.Observing(root.Problem.Player))
                //        writer.WriteLine(pred + "<br />");
                if (root.Outgoing.Count > 0)
                {
                    writer.WriteLine("<br /><b>Enabled Actions</b><br />");
                    foreach (GameTreeEdge action in root.Outgoing)
                    {
                        if (action.Child != -1)
                        {
                            writer.WriteLine("<a href='node-" + action.Child + ".html'>" + action.Action + "</a><br />");
                        }
                        else
                        {
                            writer.WriteLine(action.Action + "<br />");
                        }
                    }
                }
                if (root.Incoming != null)
                {
                    if (root.Incoming.Parent != -1)
                    {
                        writer.WriteLine("<br /><b>Last State</b><br />");
                        writer.WriteLine("<a href='node-" + root.Incoming.Parent + ".html'>Parent ID " + root.Incoming.Parent + "</a><br />");
                    }
                }
                writer.WriteLine("</body>");
                writer.WriteLine("</html>");
            }
        }