Last active
October 27, 2015 10:23
-
-
Save edprince/68b8dbc056651f2f3074 to your computer and use it in GitHub Desktop.
A recursive algorithm extending the koch snowflake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import turtle | |
from random import randint | |
u = 0 | |
turtle.speed(0) | |
turtle.delay(0) | |
#turtle.tracer(0, 0) | |
def koch(x, m): | |
if x < m: | |
turtle.forward(x) | |
else: | |
koch(x / 3, m) | |
turtle.left(60) | |
koch(x / 3, m) | |
turtle.right(120) | |
koch(x / 3, m) | |
turtle.left(60) | |
koch(x / 3, m) | |
def repeat(): | |
u = 0 | |
for x in range(3): | |
koch(500, 5) | |
turtle.right(120) | |
u += 1 | |
turtle.right(20) | |
if u < 1000000: | |
repeat() | |
repeat() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment