Sunday, January 15, 2023

Soup

So, we have just entered the long, and cold part of winter, where we stay below

the freezing point night and day. Decided to go for comfort food and tried my hand at

making pea soup from scratch, yesterday, in the crock pot. It is a long process, because

the peas perform better if they are soaked in water before use. I soaked these for six

hours yesterday. Then made the soup, four hours, at high setting, in the crock pot.



                                                                                    
               

                                                                                   


I am keeping parsley in the fridge, and will be trying my creation later this afternoon...

                                                                          *     *     *

Found some reaaly funcode fordrawing cartoon trees with turtle. One ends up with three 

slightly different threes at each run:


                                                                


The code:

from turtle import Turtle, colormode, tracer, mainloop
from random import randrange
from time import perf_counter as clock

def symRandom(n):
return randrange(-n,n+1)

def randomize( branchlist, angledist, sizedist ):
return [ (angle+symRandom(angledist),
sizefactor*1.01**symRandom(sizedist))
for angle, sizefactor in branchlist ]

def randomfd( t, distance, parts, angledist ):
for i in range(parts):
t.left(symRandom(angledist))
t.forward( (1.0 * distance)/parts )

def tree(tlist, size, level, widthfactor, branchlists, angledist=10, sizedist=5):
if level > 0:
lst = []
brs = []
for t, branchlist in list(zip(tlist,branchlists)):
t.pensize( size * widthfactor )
t.pencolor( 255 - (180 - 11 * level + symRandom(15)),
180 - 11 * level + symRandom(15),
0 )
t.pendown()
randomfd(t, size, level, angledist )
yield 1
for angle, sizefactor in branchlist:
t.left(angle)
lst.append(t.clone())
brs.append(randomize(branchlist, angledist, sizedist))
t.right(angle)
for x in tree(lst, size*sizefactor, level-1, widthfactor, brs,
angledist, sizedist):
yield None


def start(t,x,y):
colormode(255)
t.reset()
t.speed(0)
#t.hideturtle()
t.left(90)
t.penup()
t.setpos(x,y)
t.pendown()

def doit1(level, pen):
pen.hideturtle()
start(pen, 20, -208)
t = tree( [pen], 80, level, 0.1, [[ (45,0.69), (0,0.65), (-45,0.71) ]] )
return t


def doit2(level, pen):
pen.hideturtle()
start(pen, -135, -130)
t = tree( [pen], 120, level, 0.1, [[ (45,0.69), (-45,0.71) ]] )
return t

def doit3(level, pen):
#pen.hideturtle()
start(pen, 190, -90)
t = tree( [pen], 100, level, 0.1, [[ (45,0.7), (0,0.72), (-45,0.65) ]] )
return t

# Hier 3 Baumgeneratoren:
def main():
p = Turtle()
p.ht()
tracer(75,0)
u = doit1(6, Turtle(undobuffersize=1))
s = doit2(7, Turtle(undobuffersize=1))
t = doit3(5, Turtle(undobuffersize=1))
a = clock()
while True:
done = 0
for b in u,s,t:
try:
b.__next__()
except:
done += 1
if done == 3:
break

tracer(1,10)
b = clock()
return "runtime: %.2f sec." % (b-a)

if __name__ == '__main__':
main()
mainloop()


It's like a puzzle, trying to understand what each part of the code does.

Have learned a few things so far. From where the pen goes, doit1 is the tree in the middle, doit2,

that on the left, doit three, the one on the right.

                                                                 



                                                                         


Level influences color.

...Trying to find the levers to change the behavior of the code!!


https://www.simplilearn.com/tutorials/python-tutorial/yield-in-python#:~:text=The%20Yield%20keyword%20in%20Python%20is%20similar%20to%20a%20return,of%20simply%20returning%20a%20value.

No comments: