We are here to serve you

[30% discount for US and UK students ! Get 10$ for referring a student in any programming or assignment task]
Amazing website I come across for academic help .I love to deal with them as they are the best one I ever deal with .They provide you work on time ( it was much faster for myself) rather than forum checking I prefer them .

Project Fractals and the Beauty of Nature"
Many fractals can be generated from descriptions in the Fractal Description
Language (.fdl). This language describes a start state of a fractal and a set
of rules how to progress to larger depths.
For example, to generate a Koch curve, we start with the initial (depth 0)
state F signifying a forward move, i.e., a straight line. The rule for expanding
to the next depth is given as a replacement rule.
F -> F L F R F L F
where L is a 60 degree turn to the left and R is a 120 degree turn to the right.
That is, we replace a straight line by a straight line, a left-turn, a straight
line, a sharp right-turn, a straight line, a left-turn, and a fourth and nal
straight line.
Thus, the state for depth 1 is F L F R F L F. To get to depth 2, we
have to apply the rule again to all positions of the state where it is possible,
i.e., we have to replace each of the four F by F L F R F L F. The result
is F L F R F L F L F L F R F L F R F L F R F L F L F L F R F L F
where the new sections are underlined to aid your understanding.
To get to depth 3, we would have to replace each of the 16 Fs by the right
side of the rule. For the sake of brevity, I leave this exercise to you.
Let us take a look at the le koch.fdl available from the project section
of the course home page.
start F
rule F -> F L F R F L F
length 2
depth 5
cmd F fd
cmd L lt 60
cmd R rt 120
The rst line give the start state, i.e., the
state F for depth 0. The second line give the
only rule needed for the Koch curve, i.e.,
to replace F by F L F R F L F. The third
line speci es the length of each segment, i.e.,
each straight line will be 2 units long. The
fourth line speci es that states should be ex-
panded to depth 5 before drawing the frac-
tal. Finally, the Lines 5 to 7 specify that F
is a straight line, L is a 60 degree left-turn
and R is a 120 degree right-turn.
Task 0 { Preparation
Download all the .fdl les from the course homepage (at least dragon.fdl,
fern.fdl, koch.fdl, sierpinski.fdl, sierpinski2.fdl, snowflake.fdl,
and tree.fdl.
4
Try to understand how these generate their respective fractals. If you
are new to the fractals project, have a look at the project description for
the rst part to get some inspiration. While most of the fractals are known,
dragon.fdl represents a dragon curve and sierpinski.fdl represents a
Sierpinski curve.
Task 1 { Representing and Applying Rules
A rule consists of a single letter for the left side and a list of letters for the
right side. Your task is to create a user-de ned type (= Python class) \Rule"
that represents such a rule. This class should have attributes for at least the
left side and the right side.
You also need to write a function that applies a rule to each (matching)
element of a list, i.e., that from the list ["F","L","F","R","F","L","F"] for
depth 1 of the Koch curve will generate the list [["F","L","F","R","F","L",
"F"],"L",["F","L","F","R","F","L","F"],"R",["F","L","F","R","F",
"L","F"],"L",["F","L","F","R","F","L","F"]].
Task 2 { Representing and Executing Commands
A command consists of a command string (such as fd, lt, rt, scale) and a
list of arguments. Your task is to create a user-de ned type (= Python class)
\Command" that represents a command. This class should have attributes
for at least the command string and the arguments.
You also need to write a function for executing a command. This func-
tion gets as an argument a turtle object and a length. The command with
command string lt and argument list ["60"] should execute the Python state-
ment lt(turtle, 60). The command scale multiplies the length with the
given
oat. Finally, the command nop simply does nothing (no operation).
Task 3 { Loading a Fractal Description Language File
A fractal consists of a start state represented by a list, a list of rules, a
mapping from single letters to commands, a length, and a depth.
Your task is to create a user-de ned type (= Python class) \Fractal" that
has at least the attributes described above. In addition, you should write a
function or method that executes all commands of a given state, i.e., goes
through a state list, uses the mapping from single letters to commands, and
executes these.
You also need to write a function that reads an .fdl le and creates a
Fractal object from it.
5
Task 4 { Generating Fractals
Now you are left with computing a new state from an old state. Your task is
to write a (recursive or iterative) function or method that for a given start
state, set of rules, and depth computes the state at that depth.
Finally, you have to put everything together such that you can load,
compute, and draw a fractal for a given le. To this end, you should import
the sys module and use as a lename the rst argument passed on the
command line, i.e., sys.argv[1]. You also need to write a function to
atten
the lists of lists obtained by rule applications into a list of elements those lists.
Task 5* { Support for Line Widths and Colors
The fractals look nice enough, but some colors and wider lines would make
them more pretty. Your challenge task is to extend the Fractal Descripton
language by the commands color and width where color gets a color name,
a color code or \random" as an argument while width gets a
oat. Random
colors can e.g. be generated by using format strings:
"#%02x%02x%02x" % (randint(0,255),randint(0,255),randint(0,255))
Here is an example for a nicer dragon curve:
start F X
rule X -> X R Y F
rule Y -> F X L Y
length 3
depth 13
color random
width 2.0
cmd F fd
cmd X nop
cmd Y nop
cmd L lt 90
cmd R rt 90
Note that this task is optional and does not have to


Solution Code

Fractal and the Beauty of Nature