Goal: The turtle creates irregular polygons with randomlychosen angles, sides, and interior colors.
Vocabulary: random, fill
to irregularpolygon
setc whatcolor
setpensize howthick
t2, pu setpos t1's "pos
t1, pd lt random 60
repeat (#sides  1) [
t1,
fd 30 + random 50
rt (360 / #sides)  (random 20) + (random 20)
]
towards "t2
fd distance "t2
pu lt 40 bk 30
setc random 140
fill fd 30 rt 40
setc whatcolor
end
to reset
ask [t1 t2] [home seth 0]
cg
end
Notes The basic concept here is that turtle t2 serves as home base while t1 draws all but the last side of a polygon with randomlychosen angles and side lengths; then t1 rejoins t2.
 Set the #sides slider to a maximum of 6, so that this project will create irregular triangles, quadrilaterals, pentagons, and hexagons.
 In the irregularpolygon procedure, fd 30 + random 50 means, "Move forward 30 plus a random number at least 0 and less than 50."
 The command to turn the turtle to the right is a bit complicated. For a regular polygon, the turtle turns rt 360 / #sides. For this project, the turtle makes two adjustments to that number:
rt (360 / #sides)  (random 20) + (random 20)
The turtle subtracts a number less than 20 and then adds another number less than 20. This means that sometimes the turtle will be turning right a bit more than 360 / #sides and sometimes it will be turning a bit less than 360 / #sides.
 This project uses two methods for one turtle to move to the other turtle's position. Before drawing the polygon, you may drag t1 anywhere on the page and t2 will follow it with one command: t2, setpos t1's "pos. When t1 completes the polygon, we use two commands instead:
towards "t2
fd distance "t2
In this way, t1 is facing in an appropriate direction after drawing the last side of the polygon.
 The turtle then puts its pen up, turns left, backs into the interior of the polygon, changes to a randomlyselected color (setc random 140), fills the area with this color, and returns to the position, heading, and color it held when it finished drawing the outline of the polygon.
What If?
Try increasing the maximum on the #sides slider to 8 or 10 or more. (Does the project still draw polygons? Do you need to adjust any numbers in the procedure?)
Challenge
Try different numbers after random to alter the range of possible angles and side lengths.
On Your Own  Project Ideas
Can you write a procedure that draws a specific type of irregular polygon, such as an isosceles triangle or a parallelogram?
