GroIMP Module XL English

Spoken text

As explained in Unit 1, the language XL combines the object-oriented and imperative approach of the programming language JAVA and the turtle geometry with the rules-based approach of rewriting rules. It can therefore write and execute normal JAVA code within any XL program, which can also be linked with the turtle geometry. This can be useful, for example, to set conditions for the execution of the turtle interpretation, to set a certain color or to use arrays and functions.
In most cases the imperative JAVA code within an XL program has to be enclosed by curly braces. For the syntax of the JAVA language we refer to the literature on JAVA.
A small clarifying example is shown here, which contains imperative program code:
The color "red" and a point within the three-dimensional space are already assigned by "setShader" and "setTransform" in the module declaration of the bud. In addition to the parameter for the thickness, the bud gets the parameter "order", which represents the branching order. Following this, two variables with constant values are declared and defined. These are needed in the following rules.
In the grow() method the bud parameter "order" is eventually used for a condition query. The "b:" assigns to the object "Bud" the letter b as a name, which will be used for the parameter query. The rewriting rule for the bud is only executed if its "order" is less than or equal to the maximum valid branching order parameter. Within the rule, "order" is incremented for each of the two lateral buds by one.
The shown structure arises from these rules and conditions, because no new shoots are created out of lateral buds with an "order" of 3.
Based on this example you can see very well how imperative program code can be used to influence and control the structure development, which is based on the rewriting rules.



No comment has been posted yet.