Skip to content

Commit cc73325

Browse files
authored
Update README.md assignment 3
1 parent 6c8a1d5 commit cc73325

File tree

1 file changed

+70
-3
lines changed

1 file changed

+70
-3
lines changed

assignment-3/README.md

Lines changed: 70 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,82 @@ The `F` symbol means moving forward, the `+` symbol means turning left 90 degres
2424

2525
<b>F + F − F − F + F</b>
2626

27-
which corresponds to the following figure:
27+
which corresponds to the following figure:
28+
<p align="center">
29+
<img src="https://github.com/stef4k/Algorithms-and-data-structures-assignments/blob/main/assignment-3/images/koch_curve1.png" width="300" height="300" />
30+
</p>
2831

2932
If we apply the rule twice, we will get the string:
3033

3134
<b>F + F-F-F + F + F + F-F-F + F-F + F-F-F + F-F + F-F-F + F + F + F-F-F + F + F</b>
3235

33-
This gives us the following figure:
36+
This gives us the following figure:
37+
<p align="center">
38+
<img src="https://github.com/stef4k/Algorithms-and-data-structures-assignments/blob/main/assignment-3/images/koch_curve2.png" width="400" height="400" />
39+
</p>
40+
41+
If we apply the rule five times, we will get a much larger string, with 6,249 characters, which gives us the following shape:
42+
43+
<p align="center">
44+
<img src="https://github.com/stef4k/Algorithms-and-data-structures-assignments/blob/main/assignment-3/images/koch_curve5.png" width="600" height="500" />
45+
</p>
46+
47+
## Installation requirements
48+
Install the necessary library:
49+
50+
pip install matplotlib
51+
52+
## Running the script
53+
In order to run the script, execute the following command from cmd:
54+
55+
python lsystem.py [-m] [-d] <input_file> [output_file]
56+
57+
The program will either edit grammar files or find the grammar that describes a shape. This behavior will be determined by the presence of the -d parameter
58+
59+
## Grammar Editing
60+
61+
Firstly, if the user does not give the -d parameter. Then the <input_file> parameter is the name of the file that contains the L-system grammar and the parameters that will be used. For example for the koch curve, the file is:
62+
63+
{
64+
"axiom" : "F",
65+
"left_angle": 90.0,
66+
"right_angle": 90.0,
67+
"step_length": 5,
68+
"order": 5,
69+
"start_angle" : 0,
70+
"rules" : {
71+
"F": "F+F-F-F+F"
72+
}
73+
}
74+
75+
The file contains the following fields:
76+
* axiom: the axiom
77+
* left_angle: the angle of the left turn
78+
* right_angle: the angle of the right turn
79+
* step_length: the length of the step
80+
* order: the number of applications of the rules
81+
* start_angle: the value of the starting angle
82+
* rules: the rules of grammar
83+
84+
If the parameter -m is given, the program prints the result string as an output. If the user gives the [output_file] parameter, [output_file] is the name of a file to be created. This file will consist of lines. Each line of the file will contain two pairs of coordinates:
85+
86+
`(x1, y1) (x2, y2)`
87+
88+
## Examples
89+
### Example 1
90+
91+
### Example 2
92+
93+
### Example 3
94+
95+
### Example 4
96+
97+
### Example 5
98+
99+
### Example 6
100+
101+
### Example 7
34102

35-
If we apply the rule five times, we will get a much larger string, with 6,249 characters, which gives us the following shape:
36103

37104
##
38105
[Complete Greek assignment description](https://github.com/dmst-algorithms-course/assignment-2019-3/blob/master/assignment_2019_3.ipynb)

0 commit comments

Comments
 (0)