Dies ist eine alte Version des Dokuments!
import random
def werte(liste):
lnofood = [] lfood1 = [] lfood2 = [] lfood3 = [] lfood4 = [] lfood5 = [] lfood6 = [] lfood7 = [] lfood8 = [] lfood9 = [] lallfood = [] a = 0 b = 0 while a<len(liste): if a+1==len(liste): l = [] while b<a+1: l.append([liste[b][0],liste[b][1]]) b=b+1 if l != []: if 10*liste[a][2] == 0: lnofood.append(l) elif 10*liste[a][2] < 1: lfood1.append(l) elif 10*liste[a][2] < 2: lfood2.append(l) elif 10*liste[a][2] < 3: lfood3.append(l) elif 10*liste[a][2] < 4: lfood4.append(l) elif 10*liste[a][2] < 5: lfood5.append(l) elif 10*liste[a][2] < 6: lfood6.append(l) elif 10*liste[a][2] < 7: lfood7.append(l) elif 10*liste[a][2] < 8: lfood8.append(l) elif 10*liste[a][2] < 9: lfood9.append(l) else: lallfood.append(l)
else: if int(10*liste[a][2])!=int(10*liste[a+1][2]): l = [] while b<a+1: l.append([liste[b][0],liste[b][1]]) b=b+1 if l != []: if 10*liste[a][2] == 0: lnofood.append(l) elif 10*liste[a][2] < 1: lfood1.append(l) elif 10*liste[a][2] < 2: lfood2.append(l) elif 10*liste[a][2] < 3: lfood3.append(l) elif 10*liste[a][2] < 4: lfood4.append(l) elif 10*liste[a][2] < 5: lfood5.append(l) elif 10*liste[a][2] < 6: lfood6.append(l) elif 10*liste[a][2] < 7: lfood7.append(l) elif 10*liste[a][2] < 8: lfood8.append(l) elif 10*liste[a][2] < 9: lfood9.append(l) else: lallfood.append(l) a=a+1 return [lnofood,lfood1,lfood2,lfood3,lfood4,lfood5,lfood6,lfood7,lfood8,lfood9,lallfood]
n=0
movement_nofood=[] #Liste der Bewegungs-Schnipsel ohne Futter und movement_food=[] #mit Futter in Sicht
while n<1: #zufälliges erstellen von 20 Kreaturen-Wegen, im eigentlichen Code werden diese pro Kreatur in
n=n+1 x=0#Zähler l=[] #l gespeichert, also überflüssig while x<1000: #zufälliges erstellen von 10000 Bewegungsrunden pro Kreatur a=random.choice(range(0,10)) b=random.choice(range(0,10)) c=random.choice(range(0,101)) c=c/100 l.append([a,b,c]) #der Form [Winkel,Reichweite (oder andersrum), Futter] x=x+1 print(l) list_move=werte(l) #ausführen von werte mit der Liste der Bewegungen einer Kreatur l print(list_move) list_move_nofood=list_move[0] #aufteilen der Ausgabe in bewegung ohne Futter und list_move_food1=list_move[1] #bewegung mit Futter list_move_food2=list_move[2] list_move_food3=list_move[3] list_move_food4=list_move[4] list_move_food5=list_move[5] list_move_food6=list_move[6] list_move_food7=list_move[7] list_move_food8=list_move[8] list_move_food9=list_move[9] list_move_food10=list_move[10] for l in list_move_nofood: movement_nofood.append(l)