def compo(n): '''Générateur de composition aléatoire''' L= [] for i in range(n): ori = randint(0,1) sens = randrange(-1,2,2) longueur = randint(2,4) x1 = randint(0,10) y1 = randint(0,10) if ori == 0: x2 = x1 y2 = y1+(longueur*sens) c1 = y1 c2 = y2 else : x2 = x1+(longueur*sens) y2 = y1 c1 = x1 c2 = x2 if c2 > 9: c1 = c1 - (c2-9) c2 = c1+(longueur*sens) elif c2 < 0: c1 = c1 - c2 c2 = c1+(longueur*sens) if ori == 0: L.append(bateau(x1,c1,x2,c2)) else : L.append(bateau(c1,y1,c2,y2)) return L