import numpy as np M = np.array([ [1]*4+[2]+[1]*4, [1]+7*[0]+[1], [1]*4+[2]+[1]*4, [0]*4+[2]+[0]*4, [0]*2+[1]*2+[2]+[1]*2+2*[0], [0]*2+[1]+3*[0]+[1]+2*[0], [2]+3*[1]+[2]+3*[1]+[2], [1]+3*[0]+[1]+3*[0]+[1], [1]*9]) pions=np.array([[0]*1+[3]*3+[0]*1+[4]*3+[0]*1]) arrivee=np.array([[0]*4+[5]*1+[0]*4]) plateau=np.concatenate((arrivee,M,pions),axis=0) import matplotlib.pyplot as plt def traceCercle(x,y,color='black'): r = 0.4 rx=r*0.8 ry=r T = np.linspace(0,2*np.pi,100) X = x+rx*np.cos(T) Y = y+ry*np.sin(T) plt.fill(X,Y,color) plt.draw() def affiche(plateau): plt.figure(1) plt.clf() xmin, xmax, ymin, ymax = -1,9, -1, 11 # Delimitation de la fenetre plt.axis([xmin,xmax,ymin,ymax]) for i in range(11): y = 10-i for j in range(9): x = j if plateau[i,j]==1: traceCercle(x,y,color='black') elif plateau[i,j]==2: traceCercle(x,y,'yellow') elif plateau[i,j]==3: traceCercle(x,y,'green') elif plateau[i,j]==4: traceCercle(x,y,'blue') elif plateau[i,j]==5: traceCercle(x,y,'red') plt.draw() barricade = 2 bleu = 3 vert = 4 def adversaire(couleur): if couleur == bleu: return vert else: return bleu def voisinage(i,j,couleur): L = [] for dx in (-1,1): if -1