-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathturtle_auf_lsd_milan.py
More file actions
77 lines (67 loc) · 1.98 KB
/
turtle_auf_lsd_milan.py
File metadata and controls
77 lines (67 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import random
import math
import turtle
last=[0,0]
ddd=True
ca=True
turtle.speed(0)
possibilities=[[],[],[],[]]
for i in range(4):
possibilities[i]=[[],[],[],[]]
print('bleep')
for j in range(4):
possibilities[i][j]=[[],[],[],[]]
for k in range(4):
possibilities[i][j][k]=0.5
while ddd:
while ca:
turtle.speed(0)
b=math.floor(random.random()*4)
int_b=int(b)
if(possibilities[last[0]][last[1]][int_b])>random.random():
if b == 0:
print('forward')
possibilities[last[0]][last[1]][int_b]+=0.05
for i in range(4):
possibilities[last[0]][last[1]][i]-=0.0125
if possibilities[last[0]][last[1]][i]<0:
possibilities[last[0]][last[1]][i]=0
if possibilities[last[0]][last[1]][i]>1:
possibilities[last[0]][last[1]][i]=1
turtle.setheading(90)
turtle.color([0,1,0])
elif b == 1:
print('left')
possibilities[last[0]][last[1]][int_b]+=0.05
for i in range(4):
possibilities[last[0]][last[1]][i]-=0.0125
if possibilities[last[0]][last[1]][i]<0:
possibilities[last[0]][last[1]][i]=0
if possibilities[last[0]][last[1]][i]>1:
possibilities[last[0]][last[1]][i]=1
turtle.setheading(180)
turtle.color([0,0,1])
elif b == 2:
print('back')
possibilities[last[0]][last[1]][int_b]+=0.05
for i in range(4):
possibilities[last[0]][last[1]][i]-=0.0125
if possibilities[last[0]][last[1]][i]<0:
possibilities[last[0]][last[1]][i]=0
if possibilities[last[0]][last[1]][i]>1:
possibilities[last[0]][last[1]][i]=1
turtle.setheading(270)
turtle.color([0,0,0])
elif b == 3:
print('right')
possibilities[last[0]][last[1]][int_b]+=0.05
for i in range(4):
possibilities[last[0]][last[1]][i]-=0.0125
if possibilities[last[0]][last[1]][i]<0:
possibilities[last[0]][last[1]][i]=0
if possibilities[last[0]][last[1]][i]>1:
possibilities[last[0]][last[1]][i]=1
turtle.setheading(0)
turtle.color([1,0,0])
turtle.fd(4)
last=[int_b,last[0]]