%Pile des cases du chemin pair PileChemin[]; numeric indiceChemin; indiceChemin=0; vardef RAZPileChemin= pair PileChemin[]; indiceChemin:=0; enddef; def PushChemin(expr tt)= if indiceChemin<1: PileChemin[1]:=tt; indiceChemin:=1; else: PileChemin[indiceChemin+1]:=tt; indiceChemin:=indiceChemin+1; fi; enddef; def PopChemin= if indiceChemin<1: RAZPileChemin; for k=-1 upto LargeurLaby: for l=-1 upto LongueurLaby: if (k=-1) or (k=LargeurLaby) or (l=-1) or (l=LongueurLaby): CaseExploree[k][l]:=true; else: CaseExploree[k][l]:=false; fi; endfor; endfor; Mobile:=Depart; PushChemin((choixligneD,choixcolonneD)); CaseExploree[choixligneD][choixcolonneD]:=true; VoisinDispo(choixligneD,choixcolonneD); else: if indiceChemin>0: CaseExploree[xpart(PileChemin[indiceChemin])][ypart(PileChemin[indiceChemin])]:=true; fi; indiceChemin:=indiceChemin-1; fi; enddef; def PopCheminMathAlea= if indiceChemin<1: RAZPileChemin; for k=-1 upto LargeurLaby: for l=-1 upto LongueurLaby: if (k=-1) or (k=LargeurLaby) or (l=-1) or (l=LongueurLaby): CaseExploree[k][l]:=true; else: CaseExploree[k][l]:=false; fi; endfor; endfor; Mobile:=Depart; if Entree="Nord": CaseExploree[choixligneD-1][choixcolonneD]:=true; elseif Entree="Sud": CaseExploree[choixligneD+1][choixcolonneD]:=true; elseif Entree="Est": CaseExploree[choixligneD][choixcolonneD+1]:=true; elseif Entree="Ouest": CaseExploree[choixligneD][choixcolonneD-1]:=true; fi; if SortieUnique: if (Sortie="Est") or (Sortie="Ouest"): for k=0 upto LargeurLaby-1: if k<>choixligneA: CaseExploree[k][choixcolonneA]:=true; fi; endfor; elseif (Sortie="Nord") or (Sortie="Sud"): for k=0 upto LongueurLaby-1: if k<>choixcolonneA: CaseExploree[choixligneA][k]:=true; fi; endfor; fi; fi; PushChemin((choixligneD,choixcolonneD)); CaseExploree[choixligneD][choixcolonneD]:=true; VoisinDispo(choixligneD,choixcolonneD); else: if indiceChemin>0: CaseExploree[xpart(PileChemin[indiceChemin])][ypart(PileChemin[indiceChemin])]:=true; fi; indiceChemin:=indiceChemin-1; fi; enddef; %Pile des cases voisines de la case parcourue pair PileVoisin[]; numeric indiceVoisin; indiceVoisin=0; vardef RAZPileVoisin= indiceVoisin:=0; enddef; def PushVoisin(expr tt)= if indiceVoisin<1: PileVoisin[1]:=tt; indiceVoisin:=1; else: PileVoisin[indiceVoisin+1]:=tt; indiceVoisin:=indiceVoisin+1; fi; enddef; def PopVoisin= if indiceVoisin<0: %message("La pile n'existe pas"); else: indiceVoisin:=indiceVoisin-1; fi; enddef; vardef VoisinDispo(expr la,lo)= RAZPileVoisin; numeric nbvoisin; nbvoisin=0; if (la>-1) and (la-1) and (lo