Question

An L-System consists of a word over some alphabet and a set of rewrite rules for replacing symbols or subwords by other words. Words are associative, so we should define In[1]: = Sethttributes[rord, [Plat, OneIdentity\}] these attributes for our data type for words. Here is a word over the alphabet consisting of the three symbols $\mathrm{m}, 1$, and $\mathrm{r}$. Our set of rules consists of a single rule for replacing the symbol $\mathrm{m}$ by the given word. $$ \begin{aligned} & \text { In }[2]:=\operatorname{gen}=\operatorname{vord}[m, x, r, m, x, r, m] \\ & \text { Out }[2]=\operatorname{vord}[m, r, x, m, r, r, m] \\ & \text { In }[3]:=\operatorname{rules}=\{m \rightarrow \operatorname{gord}[m, 1, m, x, x, m, 1, m]\} \\ & \text { Out }[3]=\{m \rightarrow \operatorname{vord}[m, 1, m, x, r, m, 1, m]\} \end{aligned} $$ One application of the rules replaces every occurrence of m by a word; the result is $\operatorname{In}[4]:=\operatorname{gen} 1=\operatorname{gen} /$. rules flattened out, due to the attribute Flat. $$ \begin{aligned} & \text { Out }[4]=\operatorname{vord}[m, 1, m, r, r, m, 1, m, r, r, m, 1, m, r \text {, } \\ & \mathrm{r}, \mathrm{m}, 1, \mathrm{~m}, \mathrm{r}, \mathrm{r}, \mathrm{m}, 1, \mathrm{~m}, \mathrm{r}, \mathrm{r}, \mathrm{m}, \mathrm{l}, \mathrm{m}] \\ & \end{aligned} $$ We can visualize the resulting words using an idea from Turtle graphics, a simple graphic model used in the language Logo. The turtle sits originally at the origin and faces right. Each letter in our word is interpreted as a command for the turtle to change either its location by moving a certain distance in the current direction, or by turning a certain amount. As the turtle moves, it leaves a visible trail behind. (Figure Cant Copy) 1. Define a suitable data type for representing the possible states of the turtle. 2. Design a way to specify an interpretation of a word by giving the effect each letter of the alphabet has on the state of the turtle. 3. Program a function for converting a word to a list of points, given an interpretation and the start state of the turtle. 4. Plot the line connecting the points to obtain pictures similar to the ones given here. 5. Optionally remove duplicate points from the line before plotting it. The words will often consist of long sequences of turns between the moves, leading to many occurrences of the same point in lines. For better rendering, only one of a sequence of identical points should be drawn. Experiment with various generators, rule sets, and interpretations, such as the flowsnake. The alphabet consists of $\{\mathrm{m} 1, \mathrm{~m} 2, \mathrm{r}, 1\}$, the rules are $$ \begin{aligned} & \mathrm{m} 1 \rightarrow \text { word }[1, \mathrm{~m} 2, \mathrm{r}, \mathrm{m} 1, \mathrm{~m} 1, \mathrm{r}, \mathrm{r}, \mathrm{m} 1, \mathrm{r}, \mathrm{m} 2,1,1, \mathrm{~m} 2,1, \mathrm{~m} 1] \\ & \mathrm{m} 2 \rightarrow \operatorname{word}[\mathrm{m} 2, \mathrm{r}, \mathrm{m} 1, \mathrm{r}, \mathrm{r}, \mathrm{m} 1,1, \mathrm{~m} 2,1,1, \mathrm{~m} 2, \mathrm{~m} 2,1, \mathrm{~m} 1, \mathrm{r}] \end{aligned} $$ Both, $\mathrm{m} 1$ and $\mathrm{m} 2$ are interpreted as moves, and $\mathrm{r}$ and 1 as $60^{\circ}$ turns as before.

   An L-System consists of a word over some alphabet and a set of rewrite rules for replacing symbols or subwords by other words.
Words are associative, so we should define In[1]: = Sethttributes[rord, [Plat, OneIdentity\}] these attributes for our data type for words.
Here is a word over the alphabet consisting of the three symbols $\mathrm{m}, 1$, and $\mathrm{r}$.
Our set of rules consists of a single rule for replacing the symbol $\mathrm{m}$ by the given word.
$$
\begin{aligned}
& \text { In }[2]:=\operatorname{gen}=\operatorname{vord}[m, x, r, m, x, r, m] \\
& \text { Out }[2]=\operatorname{vord}[m, r, x, m, r, r, m] \\
& \text { In }[3]:=\operatorname{rules}=\{m \rightarrow \operatorname{gord}[m, 1, m, x, x, m, 1, m]\} \\
& \text { Out }[3]=\{m \rightarrow \operatorname{vord}[m, 1, m, x, r, m, 1, m]\}
\end{aligned}
$$
One application of the rules replaces every occurrence of m by a word; the result is $\operatorname{In}[4]:=\operatorname{gen} 1=\operatorname{gen} /$. rules flattened out, due to the attribute Flat.
$$
\begin{aligned}
& \text { Out }[4]=\operatorname{vord}[m, 1, m, r, r, m, 1, m, r, r, m, 1, m, r \text {, } \\
& \mathrm{r}, \mathrm{m}, 1, \mathrm{~m}, \mathrm{r}, \mathrm{r}, \mathrm{m}, 1, \mathrm{~m}, \mathrm{r}, \mathrm{r}, \mathrm{m}, \mathrm{l}, \mathrm{m}] \\
&
\end{aligned}
$$
We can visualize the resulting words using an idea from Turtle graphics, a simple graphic model used in the language Logo. The turtle sits originally at the origin and faces right. Each letter in our word is interpreted as a command for the turtle to change either its location by moving a certain distance in the current direction, or by turning a certain amount. As the turtle moves, it leaves a visible trail behind.
(Figure Cant Copy)
1. Define a suitable data type for representing the possible states of the turtle.
2. Design a way to specify an interpretation of a word by giving the effect each letter of the alphabet has on the state of the turtle.
3. Program a function for converting a word to a list of points, given an interpretation and the start state of the turtle.
4. Plot the line connecting the points to obtain pictures similar to the ones given here.
5. Optionally remove duplicate points from the line before plotting it. The words will often consist of long sequences of turns between the moves, leading to many occurrences of the same point in lines. For better rendering, only one of a sequence of identical points should be drawn.
Experiment with various generators, rule sets, and interpretations, such as the flowsnake. The alphabet consists of $\{\mathrm{m} 1, \mathrm{~m} 2, \mathrm{r}, 1\}$, the rules are
$$
\begin{aligned}
& \mathrm{m} 1 \rightarrow \text { word }[1, \mathrm{~m} 2, \mathrm{r}, \mathrm{m} 1, \mathrm{~m} 1, \mathrm{r}, \mathrm{r}, \mathrm{m} 1, \mathrm{r}, \mathrm{m} 2,1,1, \mathrm{~m} 2,1, \mathrm{~m} 1] \\
& \mathrm{m} 2 \rightarrow \operatorname{word}[\mathrm{m} 2, \mathrm{r}, \mathrm{m} 1, \mathrm{r}, \mathrm{r}, \mathrm{m} 1,1, \mathrm{~m} 2,1,1, \mathrm{~m} 2, \mathrm{~m} 2,1, \mathrm{~m} 1, \mathrm{r}]
\end{aligned}
$$
Both, $\mathrm{m} 1$ and $\mathrm{m} 2$ are interpreted as moves, and $\mathrm{r}$ and 1 as $60^{\circ}$ turns as before.
Show more…
Computer science with Mathematica: theory and practice for science, mathematics, and engineering
Computer science with Mathematica: theory and practice for science, mathematics, and engineering
Roman Maeder 1st Edition
Chapter 10, Problem 4 ↓

Instant Answer

verified

Step 1

- The state of the turtle can be represented by a tuple containing its current position (x, y coordinates) and its current direction (angle in degrees or radians). For example, the initial state could be `(0, 0, 0)` where the turtle starts at the origin (0, 0)  Show more…

Show all steps

lock
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
An L-System consists of a word over some alphabet and a set of rewrite rules for replacing symbols or subwords by other words. Words are associative, so we should define In[1]: = Sethttributes[rord, [Plat, OneIdentity\}] these attributes for our data type for words. Here is a word over the alphabet consisting of the three symbols $\mathrm{m}, 1$, and $\mathrm{r}$. Our set of rules consists of a single rule for replacing the symbol $\mathrm{m}$ by the given word. $$ \begin{aligned} & \text { In }[2]:=\operatorname{gen}=\operatorname{vord}[m, x, r, m, x, r, m] \\ & \text { Out }[2]=\operatorname{vord}[m, r, x, m, r, r, m] \\ & \text { In }[3]:=\operatorname{rules}=\{m \rightarrow \operatorname{gord}[m, 1, m, x, x, m, 1, m]\} \\ & \text { Out }[3]=\{m \rightarrow \operatorname{vord}[m, 1, m, x, r, m, 1, m]\} \end{aligned} $$ One application of the rules replaces every occurrence of m by a word; the result is $\operatorname{In}[4]:=\operatorname{gen} 1=\operatorname{gen} /$. rules flattened out, due to the attribute Flat. $$ \begin{aligned} & \text { Out }[4]=\operatorname{vord}[m, 1, m, r, r, m, 1, m, r, r, m, 1, m, r \text {, } \\ & \mathrm{r}, \mathrm{m}, 1, \mathrm{~m}, \mathrm{r}, \mathrm{r}, \mathrm{m}, 1, \mathrm{~m}, \mathrm{r}, \mathrm{r}, \mathrm{m}, \mathrm{l}, \mathrm{m}] \\ & \end{aligned} $$ We can visualize the resulting words using an idea from Turtle graphics, a simple graphic model used in the language Logo. The turtle sits originally at the origin and faces right. Each letter in our word is interpreted as a command for the turtle to change either its location by moving a certain distance in the current direction, or by turning a certain amount. As the turtle moves, it leaves a visible trail behind. (Figure Cant Copy) 1. Define a suitable data type for representing the possible states of the turtle. 2. Design a way to specify an interpretation of a word by giving the effect each letter of the alphabet has on the state of the turtle. 3. Program a function for converting a word to a list of points, given an interpretation and the start state of the turtle. 4. Plot the line connecting the points to obtain pictures similar to the ones given here. 5. Optionally remove duplicate points from the line before plotting it. The words will often consist of long sequences of turns between the moves, leading to many occurrences of the same point in lines. For better rendering, only one of a sequence of identical points should be drawn. Experiment with various generators, rule sets, and interpretations, such as the flowsnake. The alphabet consists of $\{\mathrm{m} 1, \mathrm{~m} 2, \mathrm{r}, 1\}$, the rules are $$ \begin{aligned} & \mathrm{m} 1 \rightarrow \text { word }[1, \mathrm{~m} 2, \mathrm{r}, \mathrm{m} 1, \mathrm{~m} 1, \mathrm{r}, \mathrm{r}, \mathrm{m} 1, \mathrm{r}, \mathrm{m} 2,1,1, \mathrm{~m} 2,1, \mathrm{~m} 1] \\ & \mathrm{m} 2 \rightarrow \operatorname{word}[\mathrm{m} 2, \mathrm{r}, \mathrm{m} 1, \mathrm{r}, \mathrm{r}, \mathrm{m} 1,1, \mathrm{~m} 2,1,1, \mathrm{~m} 2, \mathrm{~m} 2,1, \mathrm{~m} 1, \mathrm{r}] \end{aligned} $$ Both, $\mathrm{m} 1$ and $\mathrm{m} 2$ are interpreted as moves, and $\mathrm{r}$ and 1 as $60^{\circ}$ turns as before.
Close icon
Play audio
Feedback
Powered by NumerAI
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever