public static Axiom Iterate(List <Rule> axiom, Tree tree)
    {
        Axiom next = new Axiom();

        foreach (Rule r in axiom)
        {
            int roll = Random.Range(0, tree.allRules.Count);
            if (tree.allRules[roll].ContainsKey(r))
            {
                foreach (Rule rn in tree.allRules[roll][r])
                {
                    next.Add(rn);
                    rn.Run(tree);
                }
            }
            else
            {
                next.Add(r);
                r.Run(tree);
            }
        }
        return(next);
    }
示例#2
0
    public static Axiom GetRulesFromString(string sentence)
    {
        Axiom rules = new Axiom();

        foreach (char _c in sentence)
        {
            Rule r;
            if (Tree.ExistingRules.ContainsKey(_c))
            {
                r = Tree.ExistingRules[_c];
            }
            else
            {
                r = new UnknownRule(_c);
                Tree.ExistingRules[_c] = r;
            }
            rules.Add(r);
        }
        return(rules);
    }