Arrowhead Curve Project - Implementing L-systems in Java

Verified

Added on  2019/09/18

|1
|393
|487
Project
AI Summary
This project focuses on implementing Sierpinski's Arrowhead Curve using Java. The assignment requires students to implement the L-system rules, which involve production rules for the characters A, B, +, and -. The program uses an AnimatedTurtle to draw the curve, with A and B representing forward movement, and + and - representing 60-degree turns. The solution must avoid recursion and implement the methods in ArrowheadCurve.java that have TODO comments. Students are expected to submit only the ArrowheadCurve.java file. Desklib provides this assignment solution, along with other helpful resources like past papers and solved assignments, to aid students in their studies.
Document Page
Background
In the late 1960's the biologist and botanist, Aristid Lindenmayer, created L-systems (Links to an
external site.) to describe and model plant growth. He published a book entitled The Algorithimic
Beauty of Plants, that shows the use of these systems (see link to PDF in modules on Canvas).
An L-system consists of an alphabet which is simply a String containing the characters used, a initial
(or axiom) String consisting of characters from the alphabet, and then a collection of production rules
for transforming one generation into another.
On this exam, you will only be dealing with one particular L-system -- Sierpinski's Arrowhead Curve.
So in this case the alphabet consists of "AB+-". The initial generation is "A". The production rules
are (A → +B−A−B+), (B → −A+B+A−). This means that when nextGen is called with "A", the only
rule that applies is the first production rule and so a new String is created that contains only
"+B−A−B+". If nextGen were called on that, the process is the same -- namely for each character
we look at the production rules to see if one applies and then replace that in the result string with the
production.
So here is a full look at nextGen for "+B−A−B+":
Character Production
rule Result so far
+ none +
B B → −A+B+A− +−A+B+A−
- none +−A+B+A−-
A A → +B−A−B+ +−A+B+A−-+B−A−B+
- none +−A+B+A−-+B−A−B+-
B B → −A+B+A− +−A+B+A−-+B−A−B+-−A+B+A−
+ none +−A+B+A−-+B−A−B+-−A+B+A−+
So the result of nextGen("+B−A−B+") is "+−A+B+A−-+B−A−B+-−A+B+A−+".
Given a String that represents a generation, you can use an AnimatedTurtle to draw that String by
following the rules that A and B mean move forward and + means turn left 60 degrees and - means
turn right 60 degrees.
Requirements
Download, unzip, and open the starter project in IntelliJ. You must fill in the methods in the
ArrowheadCurve.java file.
Your program must not use recursion.
You must implement each of the methods in ArrowheadCurve.java that have TODO comments.
What to Submit
Submit only your ArrowheadCurve.java file.
tabler-icon-diamond-filled.svg

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
[object Object]