w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Robotics - Recursive function for fractal.

I'm thinking this is what you want to do

x = number of interations
l = lenth(wait time)
def fractal(x, l):
    if (x == 1):
        forward(l/3)
    else:
        fractal((x-1), l/3)
    turnLeft(1,0.55) #60 degrees
    if (x == 1):
        forward(l/3)
    else:
        fractal((x-1), l/3)
    turnRight(1, 1.1) #120 degree turn
    if (x == 1):
        forward(l/3)
    else:
        fractal((x-1), l/3)
    turnLeft(1, 0.55)#60 degree turn
    if (x == 1):
        forward(l/3)
    else:
        fractal((x-1), l/3)




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.