Avec des tuiles de "Truchet" de taille variable

[url=https://geogebra.org/python/index.html?name=truchet+1%2C2%2C3%2B&code=eJzdVt1umzAUvvdTeM0NHW4KpNrFVCa1jXY9ab2LqsolTmLVYGTMGq73MNNeY3uxHdsEDEm2Tpo6qVYE9nf%2Bj0%2FOYYI%2Fa6o0flJc82KNG1krnMkle4Mm0ew8Ss6TKLlAk7XiQjC8kir%2F%2BfXH9wov4UBh%2B00WmAqDUS25YoagFafFWjDLlUntJGKSYFnPpmjyoGQN6kCyemQ622C0UjLHihZLePG8lEq%2FRe6NNc8ZQmjJVjinW57XeSB4pdnpe4RhGQyn2EKL6M5i4CXmmBcOdXxm8RXAH1Ir06OeFm5BxXStCovZs3sYB3aBBVvSEE1NSlo3FEgb%2F3mhg5hcnFoQ7AGexr2tK2D7JA2T0cCr%2By%2B84g%2BCpR%2BpqJiTMuu65wudnd%2By3xxg322OS819Z%2F7MfmvZRbOWRbC4Itfk5s4jJkPqvKO2SUheSRLSLkhIAJkPUtDT5gQSNEzA7NUlAMInV0cS4NdHm4CLV5cA%2F5bHCfCr43YqS5px3aRxe86kkCpdRCQmsetZt1PBC3avNzx7LFhVpZGDk7FsshOOSUTahgfgQWmk02gaxWgLIUaosc8t9DXYJDFq2l2EUAnvRUIS4w1ayWLZBeIyc%2FaOwG8vKaTNGygKj3BAKzT6WqdPHgTNHk8c1Admj3sRwHracJg6zaVx1ZWPlpoKG4g52cBcgzbgwqXDSVnOS%2BNbX3imTWcbyTMWlP29QYFa5jQ13Gdev%2B4spvYZujvotLV3YhYTIy1ew7O8wwmR9NbHNpQaGQHZ42a8tnLAzOz5ZnA6MFN5c3NPtKN0GzGlZcmKZaCcRfvY0FqzWqXd3PZopTIetogZ2NQMbPB8zQLBCqC0k3VgBoIXC3o3mKmDie8URKQ17enoAvFmeMhJPMzQwNrzAfORMq0EY2WgB3XlvB3VAuCtf5dj0tjDcaH8U%2F%2FM2r%2FpF3fhMLt%2FTdCX%2Fq8PYfwCXuzXzejPvXczo7%2F338Xc7U0T3YbW5A42o6IJ2yL1PoLN4xd36hvT]Lien[/url]
Code
[code][br]#03/02/2024[br]#grille formés de façon aléatoire par des triangles de cotés 1,2 ou3.[br][br]from random import*[br]import time[br][br][br]def maximum(liste):[br] maxi = liste[0][br] for i in liste:[br] if i >= maxi:[br] maxi = i[br] return maxi[br] [br] [br]def triangle(x,y,taille):[br] r = randint(1,4)[br] if r ==1:[br] A = Point(x,y,is_visible=False)[br] B = Point(x+taille,y,is_visible=False)[br] C = Point(x+taille,y+taille,is_visible=False)[br] D = Point(x,y+taille,is_visible=False)[br] T = Polygon([A,B,C])[br] T2 = Polygon([A,D,C])[br] if r ==2:[br] A = Point(x,y,is_visible=False)[br] B = Point(x+taille,y,is_visible=False)[br] C = Point(x+taille,y+taille,is_visible=False)[br] D = Point(x,y+taille,is_visible=False)[br] T=Polygon([B,C,D])[br] T2=Polygon([D,A,B])[br] if r ==3:[br] A = Point(x,y,is_visible=False)[br] B = Point(x+taille,y,is_visible=False)[br] C = Point(x+taille,y+taille,is_visible=False)[br] D = Point(x,y+taille,is_visible=False)[br] T=Polygon([C,D,A])[br] T2=Polygon([A,B,C])[br] if r ==4:[br] A = Point(x,y,is_visible=False)[br] B = Point(x+taille,y,is_visible=False)[br] C = Point(x+taille,y+taille,is_visible=False)[br] D = Point(x,y+taille,is_visible=False)[br] T=Polygon([D,A,B])[br] T2=Polygon([B,C,D])[br] T.opacity=1[br] T.color=[0,1,1][br] T.line_thickness=0[br] T2.opacity=1[br] T2.color=[1,0,0][br] T2.line_thickness=0[br] [br]t=0.01[br]x = 0[br]y = 0[br]xmax = 21[br]ymax = 20[br][br]p = [2,2,1][br][br]fond=Polygon(Point(-6,-6,is_visible=False),Point(xmax+6,-6,is_visible=False),4)[br]fond.color="black"[br]fond.opacity=1[br]fond.line_thickness=0[br][br][br][br][br][br]while y<ymax:[br] total = 0[br] x = 0 [br] l = [][br] while total<xmax:[br] r = choice(p)[br] if total==xmax-1:[br] total=total+1[br] r=1[br] elif total==xmax-2:[br] rr = randint(1,2)[br] total=total+rr[br] r= rr[br] elif total==xmax-3:[br] rr = randint(1,3)[br] total=total+rr[br] r =rr[br] else:[br] total=total+r[br] [br] l.append(r)[br] [br] hauteur=maximum(l)[br] [br] print(l)[br] for a in range(len(l)):[br] [br] if l[a]==1:[br] for i in range(0,hauteur):[br] triangle(x,y+i,1) [br] [br] [br] time.sleep(t)[br] if l[a]==2:[br] if hauteur<=2:[br] triangle(x,y,2) [br] [br] [br] time.sleep(t)[br] else:[br] triangle(x,y,2) [br] [br] [br] time.sleep(t) [br] triangle(x,y+2,1)[br] [br] [br] [br] time.sleep(t)[br] [br] triangle(x+1,y+2,1) [br] [br] [br] time.sleep(t)[br] [br] if l[a]==3:[br] triangle(x,y,3) [br] time.sleep(t)[br] [br] x = x+ l[a] [br] y = y+hauteur[br] [br] [br] [br][br][/code]

Information: Avec des tuiles de "Truchet" de taille variable