generators.regularTreeGrammar:
( { S0, S, P, UD, U, +-, +, L1, L2, L3 },
  { leg1:0, leg2:0, leg3:0, legMove1:1, legMove2:1, ant:6, scaleDown:1,
    smallStep:2, medStep:2, bigStep:2,
    one:1, two:2, three:3,
    up1:1, up2:1,
    plus:1, flip:1 },
  {
    S0 -> ant[leg1,leg2,leg3,leg1,leg2,leg3] weight 0,
       % S0 and this rule are only needed to reduce the time needed
       % for the grammar's first `advance' step during initialization
    S0 -> smallStep[P,S],
    S0 -> medStep[P,S],
    S0 -> bigStep[P,S],
    S0 -> P weight .5, 
    S -> smallStep[P,S],
    S -> medStep[P,S],
    S -> bigStep[P,S],
    S -> P weight .5, 
    P -> one[UD],
    P -> two[UD, UD],
    P -> three[UD,UD,UD],
    UD -> U,
    UD -> flip[U],
    U  -> up1[U],
    U  -> up2[U],
    U  -> +-,
    +- -> +,
    +- -> flip[+],
    +  -> plus[+],
    +  -> plus[ant[L1,L2,L3,L1,L2,L3]],
    L1 -> legMove2[leg1],
    L1 -> leg1,
    L2 -> legMove1[leg2],
    L2 -> leg2,
    L3 -> legMove1[leg3],
    L3 -> legMove2[leg3],
    L3 -> leg3
   },
  S0 )
