Пример #1
0
    public string GenerateWord(DeterministicGrammar g, int iterations)
    {
        string word = g.axiom;

        for (int i = 0; i < iterations; i++)
        {
            //Debug.Log(i);
            string tmp = "";
            foreach (char c in word)
            {
                int j = 0;
                foreach (char symbol in g.V)
                {
                    if (symbol == c)
                    {
                        tmp += g.P[j];
                    }
                    //Debug.Log(symbol);
                    j++;
                }
                if (c == '+' || c == '-' || c == '[' || c == ']')
                {
                    tmp += c;
                }
            }
            //Debug.Log(tmp);
            word = tmp;
        }
        return(word);
    }
Пример #2
0
 public Tree(DeterministicGrammar g, float timeToGrow, float trunc_height, float trunc_radius, int delta_angle)
 {
     this.timeToGrow   = timeToGrow;
     this.g            = g;
     this.trunc_height = trunc_height * Random.Range(0.7f, 1.3f);
     this.trunc_radius = trunc_radius * Random.Range(0.7f, 1.3f);
     this.delta_angle  = (int)(delta_angle * Random.Range(0.7f, 1.3f));
     glucid            = g.glucid;
     water             = g.water;
     minerals          = g.minerals;
     genotype          = new List <float>();
     genotype.Add(trunc_height);
     genotype.Add(trunc_radius);
     genotype.Add(delta_angle);
     level   = 1;
     reserve = 0;
 }