亀を時計回りに1週させる Forward 100 Right 100 Forward 100 Right 100 Forward 100 Right 100 Forward 100
28 :
亀を反時計回り1週させる Forward 100 Left 100 Forward 100 Left 100 Forward 100 Left 100 Forward 100
29 :
円運動はどうする?
30 :
どうするんだろ?
31 :
128角形を描くに決まってるじゃん。
32 :
微分的w
33 :
#一筆描き from turtle import * import time from random import seed, random def turn(d): if d: left(90) else: right(90) def draw(n, d, s): '''n:depth, d:direction (True:left, False:right), s:step''' if n == 0: return elif (n % 2): draw(n - 1, ~d, s); forward(s); turn(d) draw(n - 1, d, s); forward(s); draw(n - 1, d, s) turn(d); forward(s); draw(n - 1, ~d, s) else: color((.25 + random() / 2.0, .25 + random() / 2.0, .25 + random() / 2.0)) draw(n - 1, ~d, s); turn(d); forward(s); draw(n - 1, d, s) turn(~d); forward(s); turn(~d) draw(n - 1, d, s); forward(s); turn(d); draw(n - 1, ~d, s) if __name__ == '__main__': # demo(); time.sleep(1); goto((0, 0)); clear() seed(None) for n in xrange(1, 13): tracer(True if n < 5 else False) up(); goto((-30 * n, -30 * n)); write('depth=%d' % n, True); down(); if n % 2: left(90) draw(n, False, (24 / n) if n < 8 else 2 if n < 9 else 1); time.sleep(3); reset()
34 :
#非再帰のドラゴン曲線 from turtle import * import time from random import seed, random def edges(n): e = b = 0 for i in xrange(32): j = 1 if n & 2 ** (31 - i) else 0 if j != b: e += 1 b = j return e def draw(n, d, s): '''n:length, d:direction, s:step''' for i in xrange(n): color((.25 + random() / 2.0, .25 + random() / 2.0, .25 + random() / 2.0)) e = edges(i) % 4 right(((4 + e - d) % 4) * 90) turn(d, e) d = e forward(s) if __name__ == '__main__': # demo(); time.sleep(1); goto((0, 0)); clear() seed(None) for n in xrange(16): tracer(True if n < 5 else False) up(); goto((0, 0)); write('length=%d' % 2 ** n, True); down(); draw(2 ** n, 0, (100 / (n + 1)) if n < 12 else 2); time.sleep(3); reset()