1 /* accesseurs sur ligne et colonne*/
2 :-use_module(library(assoc)).
5 ordonne((X,Y1),(X,Y2),(X,Ym),(X,YM)):-
8 ordonne((X1,Y1),(X2,Y2),(X1,Y1),(X2,Y2)):-
10 ordonne((X1,Y1),(X2,Y2),(X2,Y2),(X1,Y1)):-
15 glissement(ro,d,Conf1,Conf2,Xr,Y):-
16 gen_assoc(ro,Conf1,[1-(Xr,Y)]),
17 gen_assoc(vi,Conf1,[1-(Xv,Y),2-(Xv,Yp)]),
18 Xv is Xr +2,Xp is Xr+1,Yp is Y +1,
19 put_assoc(ro,Conf1,[1-(Xp,Y)],Conf1b),
20 put_assoc(vi,Conf1b,[1-(Xr,Y),2-(Xr,Yp)],Conf2).
23 glissement(ro,g,Conf1,Conf2,Xr,Y):-
24 gen_assoc(ro,Conf1,[1-(Xr,Y)]),
25 gen_assoc(vi,Conf1,[1-(Xv,Y),2-(Xv,Yp)]),
26 Xv is Xr -1,Xp is Xr+1,Yp is Y +1,
27 put_assoc(ro,Conf1,[1-(Xv,Y)],Conf1b),
28 put_assoc(vi,Conf1b,[1-(Xp,Y),2-(Xp,Yp)],Conf2).
31 glissement(ro,b,Conf1,Conf2,Xr,Y):-
32 gen_assoc(ro,Conf1,[1-(Xr,Y)]),
33 gen_assoc(vi,Conf1,[1-(Xr,Yv),2-(Xp,Yv)]),
34 Xp is Xr +1, Yv is Y+2,Yp is Y+1,
35 put_assoc(ro,Conf1,[1-(Xr,Yp)],Conf1b),
36 put_assoc(vi,Conf1b,[1-(Xr,Y),2-(Xp,Y)],Conf2).
39 glissement(ro,h,Conf1,Conf2,Xr,Y):-
40 gen_assoc(ro,Conf1,[1-(Xr,Y)]),
41 gen_assoc(vi,Conf1,[1-(Xr,Yv),2-(Xp,Yv)]),
42 Yv is Y-1,Yp is Y+1,Xp is Xr +1,
43 put_assoc(ro,Conf1,[1-(Xr,Yv)],Conf1b),
44 put_assoc(vi,Conf1b,[1-(Xr,Yp),2-(Xp,Yp)],Conf2).
47 glissement(no,d,Conf1,Conf2,Xn1,Yn1):-
48 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
49 gen_assoc(vi,Conf1,[1-(Xv,Yn1),2-(Xv,Yv2)]),
50 Xv is Xn1+1,Yv2 is Yn1+1,
51 ordonne((Xv,Yn1),(Xn2,Yn2),No1,No2),
52 put_assoc(no,Conf1,[1-No1,2-No2],Conf1b),
53 put_assoc(vi,Conf1b,[1-(Xn1,Yn1),2-(Xn1,Yv2)],Conf2).
56 glissement(no,d,Conf1,Conf2,Xn2,Yn2):-
57 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
58 gen_assoc(vi,Conf1,[1-(Xv,Yn2),2-(Xv,Yv2)]),
59 Xv is Xn2+1,Yv2 is Yn2+1,
60 put_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xv,Yn2)],Conf1b),
61 put_assoc(vi,Conf1b,[1-(Xn2,Yn2),2-(Xn2,Yv2)],Conf2).
64 glissement(no,g,Conf1,Conf2,Xn1,Yn1):-
65 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
66 gen_assoc(vi,Conf1,[1-(Xv,Yn1),2-(Xv,Yv2)]),
67 Xv is Xn1-1,Yv2 is Yn1+1,
68 put_assoc(no,Conf1,[1-(Xv,Yn1),2-(Xn2,Yn2)],Conf1b),
69 put_assoc(vi,Conf1b,[1-(Xn1,Yn1),2-(Xn1,Yv2)],Conf2).
72 glissement(no,g,Conf1,Conf2,Xn2,Yn2):-
73 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
74 gen_assoc(vi,Conf1,[1-(Xv,Yn2),2-(Xv,Yv2)]),
75 Xv is Xn2-1,Yv2 is Yn2+1,
76 ordonne((Xv,Yn2),(Xn1,Yn1),No1,No2),
77 put_assoc(no,Conf1,[1-No1,2-No2],Conf1b),
78 put_assoc(vi,Conf1b,[1-(Xn2,Yn2),2-(Xn2,Yv2)],Conf2).
81 glissement(no,b,Conf1,Conf2,Xn1,Yn1):-
82 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
83 gen_assoc(vi,Conf1,[1-(Xn1,Yv1),2-Nv2]),
84 Yn1p is Yn1+1,Yv1 is Yn1+2,
85 put_assoc(no,Conf1,[1-(Xn1,Yn1p),2-(Xn2,Yn2)],Conf1b),
86 put_assoc(vi,Conf1b,[1-(Xn1,Yn1),2-Nv2],Conf2).
89 glissement(no,b,Conf1,Conf2,Xn1,Yn1):-
90 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
91 gen_assoc(vi,Conf1,[1-Nv1,2-(Xn1,Yv1)]),
92 Yn1p is Yn1+1,Yv1 is Yn1+2,
93 put_assoc(no,Conf1,[1-(Xn1,Yn1p),2-(Xn2,Yn2)],Conf1b),
94 put_assoc(vi,Conf1b,[1-Nv1,2-(Xn1,Yn1)],Conf2).
97 glissement(no,b,Conf1,Conf2,Xn2,Yn2):-
98 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
99 gen_assoc(vi,Conf1,[1-(Xn2,Yv1),2-Nv2]),
100 Yn2p is Yn2+1,Yv1 is Yn2+2,
101 put_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2p)],Conf1b),
102 put_assoc(vi,Conf1b,[1-(Xn2,Yn2),2-Nv2],Conf2).
105 glissement(no,b,Conf1,Conf2,Xn2,Yn2):-
106 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
107 gen_assoc(vi,Conf1,[1-Nv1,2-(Xn2,Yv2)]),
108 Yn2p is Yn2+1,Yv2 is Yn2+2,
109 put_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2p)],Conf1b),
110 put_assoc(vi,Conf1b,[1-Nv1,2-(Xn2,Yn2)],Conf2).
113 glissement(no,h,Conf1,Conf2,Xn1,Yn1):-
114 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
115 gen_assoc(vi,Conf1,[1-(Xn1,Yv1),2-Nv2]),
116 Yv1p is Yn1+1,Yv1 is Yn1-1,
117 put_assoc(no,Conf1,[1-(Xn1,Yv1),2-(Xn2,Yn2)],Conf1h),
118 put_assoc(vi,Conf1h,[1-(Xn1,Yv1p),2-Nv2],Conf2).
121 glissement(no,h,Conf1,Conf2,Xn1,Yn1):-
122 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
123 gen_assoc(vi,Conf1,[1-Nv1,2-(Xn1,Yv1)]),
124 Yv1p is Yn1+1,Yv1 is Yn1-1,
125 put_assoc(no,Conf1,[1-(Xn1,Yv1),2-(Xn2,Yn2)],Conf1h),
126 put_assoc(vi,Conf1h,[1-Nv1,2-(Xn1,Yv1p)],Conf2).
129 glissement(no,h,Conf1,Conf2,Xn2,Yn2):-
130 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
131 gen_assoc(vi,Conf1,[1-(Xn2,Yv1),2-Nv2]),
132 Yv1p is Yn2+1,Yv1 is Yn2-1,
133 put_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yv1)],Conf1h),
134 put_assoc(vi,Conf1h,[1-(Xn2,Yv1p),2-Nv2],Conf2).
137 glissement(no,h,Conf1,Conf2,Xn2,Yn2):-
138 gen_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
139 gen_assoc(vi,Conf1,[1-Nv1,2-(Xn2,Yv2)]),
140 Yv2p is Yn2+1,Yv2 is Yn2-1,
141 put_assoc(no,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yv2)],Conf1h),
142 put_assoc(vi,Conf1h,[1-Nv1,2-(Xn2,Yv2p)],Conf2).
145 glissement(ja,d,Conf1,Conf2,Xn1,Yn1):-
146 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
147 gen_assoc(vi,Conf1,[1-(Xv,Yn1),2-(Xv,Yv2)]),
148 Xv is Xn1+1,Yv2 is Yn1+1,
149 ordonne((Xv,Yn1),(Xn2,Yn2),Ja1,Ja2),
150 put_assoc(ja,Conf1,[1-Ja1,2-Ja2],Conf1b),
151 put_assoc(vi,Conf1b,[1-(Xn1,Yn1),2-(Xn1,Yv2)],Conf2).
154 glissement(ja,d,Conf1,Conf2,Xn2,Yn2):-
155 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
156 gen_assoc(vi,Conf1,[1-(Xv,Yn2),2-(Xv,Yv2)]),
157 Xv is Xn2+1,Yv2 is Yn2+1,
158 put_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xv,Yn2)],Conf1b),
159 put_assoc(vi,Conf1b,[1-(Xn2,Yn2),2-(Xn2,Yv2)],Conf2).
162 glissement(ja,g,Conf1,Conf2,Xn1,Yn1):-
163 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
164 gen_assoc(vi,Conf1,[1-(Xv,Yn1),2-(Xv,Yv2)]),
165 Xv is Xn1-1,Yv2 is Yn1+1,
166 put_assoc(ja,Conf1,[1-(Xv,Yn1),2-(Xn2,Yn2)],Conf1b),
167 put_assoc(vi,Conf1b,[1-(Xn1,Yn1),2-(Xn1,Yv2)],Conf2).
170 glissement(ja,g,Conf1,Conf2,Xn2,Yn2):-
171 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
172 gen_assoc(vi,Conf1,[1-(Xv,Yn2),2-(Xv,Yv2)]),
173 Xv is Xn2-1,Yv2 is Yn2+1,
174 ordonne((Xv,Yn2),(Xn1,Yn1),Ja1,Ja2),
175 put_assoc(ja,Conf1,[1-Ja1,2-Ja2],Conf1b),
176 put_assoc(vi,Conf1b,[1-(Xn2,Yn2),2-(Xn2,Yv2)],Conf2).
179 glissement(ja,b,Conf1,Conf2,Xn1,Yn1):-
180 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
181 gen_assoc(vi,Conf1,[1-(Xn1,Yv1),2-Nv2]),
182 Yn1p is Yn1+1,Yv1 is Yn1+2,
183 put_assoc(ja,Conf1,[1-(Xn1,Yn1p),2-(Xn2,Yn2)],Conf1b),
184 put_assoc(vi,Conf1b,[1-(Xn1,Yn1),2-Nv2],Conf2).
187 glissement(ja,b,Conf1,Conf2,Xn1,Yn1):-
188 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
189 gen_assoc(vi,Conf1,[1-Nv1,2-(Xn1,Yv1)]),
190 Yn1p is Yn1+1,Yv1 is Yn1+2,
191 put_assoc(ja,Conf1,[1-(Xn1,Yn1p),2-(Xn2,Yn2)],Conf1b),
192 put_assoc(vi,Conf1b,[1-Nv1,2-(Xn1,Yn1)],Conf2).
195 glissement(ja,b,Conf1,Conf2,Xn2,Yn2):-
196 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
197 gen_assoc(vi,Conf1,[1-(Xn2,Yv1),2-Nv2]),
198 Yn2p is Yn2+1,Yv1 is Yn2+2,
199 put_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2p)],Conf1b),
200 put_assoc(vi,Conf1b,[1-(Xn2,Yn2),2-Nv2],Conf2).
203 glissement(ja,b,Conf1,Conf2,Xn2,Yn2):-
204 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
205 gen_assoc(vi,Conf1,[1-Nv1,2-(Xn2,Yv2)]),
206 Yn2p is Yn2+1,Yv2 is Yn2+2,
207 put_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2p)],Conf1b),
208 put_assoc(vi,Conf1b,[1-Nv1,2-(Xn2,Yn2)],Conf2).
211 glissement(ja,h,Conf1,Conf2,Xn1,Yn1):-
212 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
213 gen_assoc(vi,Conf1,[1-(Xn1,Yv1),2-Nv2]),
214 Yv1p is Yn1+1,Yv1 is Yn1-1,
215 put_assoc(ja,Conf1,[1-(Xn1,Yv1),2-(Xn2,Yn2)],Conf1h),
216 put_assoc(vi,Conf1h,[1-(Xn1,Yv1p),2-Nv2],Conf2).
219 glissement(ja,h,Conf1,Conf2,Xn1,Yn1):-
220 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
221 gen_assoc(vi,Conf1,[1-Nv1,2-(Xn1,Yv1)]),
222 Yv1p is Yn1+1,Yv1 is Yn1-1,
223 put_assoc(ja,Conf1,[1-(Xn1,Yv1),2-(Xn2,Yn2)],Conf1h),
224 put_assoc(vi,Conf1h,[1-Nv1,2-(Xn1,Yv1p)],Conf2).
227 glissement(ja,h,Conf1,Conf2,Xn2,Yn2):-
228 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
229 gen_assoc(vi,Conf1,[1-(Xn2,Yv1),2-Nv2]),
230 Yv1p is Yn2+1,Yv1 is Yn2-1,
231 put_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yv1)],Conf1h),
232 put_assoc(vi,Conf1h,[1-(Xn2,Yv1p),2-Nv2],Conf2).
235 glissement(ja,h,Conf1,Conf2,Xn2,Yn2):-
236 gen_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yn2)]),
237 gen_assoc(vi,Conf1,[1-Nv1,2-(Xn2,Yv2)]),
238 Yv2p is Yn2+1,Yv2 is Yn2-1,
239 put_assoc(ja,Conf1,[1-(Xn1,Yn1),2-(Xn2,Yv2)],Conf1h),
240 put_assoc(vi,Conf1h,[1-Nv1,2-(Xn2,Yv2p)],Conf2).
243 glissement(bl,d,Conf1,Conf2,Xb,Yb):-
244 gen_assoc(bl,Conf1,[1-(Xb,Yb)]),
245 gen_assoc(vi,Conf1,[1-(Xv1,Yb),2-Nv2]),
246 Xv1 is Xb +2,Xp is Xb+1,
247 put_assoc(bl,Conf1,[1-(Xp,Yb)],Conf1b),
248 put_assoc(vi,Conf1b,[1-(Xb,Yb),2-Nv2],Conf2).
251 glissement(bl,d,Conf1,Conf2,Xb,Yb):-
252 gen_assoc(bl,Conf1,[1-(Xb,Yb)]),
253 gen_assoc(vi,Conf1,[1-(Xv1,Yv1),2-(Xv2,Yb)]),
254 Xv2 is Xb +2,Xp is Xb+1,
255 put_assoc(bl,Conf1,[1-(Xp,Yb)],Conf1b),
256 ordonne((Xv1,Yv1),(Xb,Yb),Nv1,Nv2),
257 put_assoc(vi,Conf1b,[1-Nv1,2-Nv2],Conf2).
261 glissement(bl,d,Conf1,Conf2,Xb,Yb):-
262 gen_assoc(bl,Conf1,[1-(Xb,Yb)]),
263 gen_assoc(vi,Conf1,[1-(Xv1,Yb),2-V2]),
264 Xv1 is Xb-1,Xp is Xb+1,
265 ordonne((Xp,Yb),V2,V1p,V2p),
266 put_assoc(bl,Conf1,[1-(Xv1,Yb)],Conf1b),
267 put_assoc(vi,Conf1b,[1-V1p,2-V2p],Conf2).
271 glissement(bl,b,Conf1,Conf2,Xb,Yb):-
272 gen_assoc(bl,Conf1,[1-(Xb,Yb)]),
273 gen_assoc(vi,Conf1,[1-(Xb,Yv1),2-(Xv2,Yv1)]),
274 Yv1 is Yb+1, Xv2 is Xb +1,
275 put_assoc(bl,Conf1,[1-(Xb,Yv1)],Conf1b),
276 put_assoc(vi,Conf1b,[1-(Xb,Yb),2-(Xv2,Yb)],Conf2).
279 glissement(bl,h,Conf1,Conf2,Xb,Yb):-
280 gen_assoc(bl,Conf1,[1-(Xb,Yb)]),
281 gen_assoc(vi,Conf1,[1-(Xb,Yv1),2-(Xv2,Yv1)]),
282 Yv1 is Yb-1, Xv2 is Xb +1,
283 put_assoc(bl,Conf1,[1-(Xb,Yv1)],Conf1b),
284 put_assoc(vi,Conf1b,[1-(Xb,Yb),2-(Xv2,Yb)],Conf2).
287 glissement(ma,d,Conf1,Conf2,Xm1,Ym1):-
288 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-(Xm2,Ym2)]),
289 gen_assoc(vi,Conf1,[1-(Xv1,Ym1),2-Nv2]),
291 ordonne((Xv1,Ym1),(Xm2,Ym2),Nm1,Nm2),
292 put_assoc(ma,Conf1,[1-Nm1,2-Nm2],Conf1b),
293 put_assoc(vi,Conf1b,[1-(Xm1,Ym1),2-Nv2],Conf2).
296 glissement(ma,d,Conf1,Conf2,Xm1,Ym1):-
297 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-(Xm2,Ym2)]),
298 gen_assoc(vi,Conf1,[1-(Xv1,Yv1),2-(Xv2,Ym1)]),
300 ordonne((Xv2,Ym1),(Xm2,Ym2),Nm1,Nm2),
301 put_assoc(ma,Conf1,[1-Nm1,2-Nm2],Conf1b),
302 ordonne((Xv1,Yv1),(Xm1,Ym1),Nv1,Nv2),
303 put_assoc(vi,Conf1b,[1-Nv1,2-Nv2],Conf2).
306 glissement(ma,d,Conf1,Conf2,Xm2,Ym2):-
307 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-(Xm2,Ym2)]),
308 gen_assoc(vi,Conf1,[1-(Xv1,Ym2),2-Nv2]),
310 put_assoc(ma,Conf1,[1-(Xm1,Ym1),2-(Xv1,Ym2)],Conf1b),
311 put_assoc(vi,Conf1b,[1-(Xm2,Ym2),2-Nv2],Conf2).
314 glissement(ma,d,Conf1,Conf2,Xm2,Ym2):-
315 gen_assoc(ma,Conf1,[1-M1,2-(Xm2,Ym2)]),
316 gen_assoc(vi,Conf1,[1-Nv1,2-(Xv2,Ym2)]),
318 put_assoc(ma,Conf1,[1-M1,2-(Xv2,Ym2)],Conf1b),
319 ordonne(Nv1,(Xm2,Ym2),Nv1,Nv2),
320 put_assoc(vi,Conf1b,[1-Nv1,2-Nv2],Conf2).
324 glissement(ma,g,Conf1,Conf2,Xm1,Ym1):-
325 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-M2]),
326 gen_assoc(vi,Conf1,[1-(Xv1,Ym1),2-Nv2]),
328 put_assoc(ma,Conf1,[1-(Xv1,Ym1),2-M2],Conf1b),
329 ordonne((Xm1,Ym1),Nv2,Nv1p,Nv2p),
330 put_assoc(vi,Conf1b,[1-Nv1p,2-Nv2p],Conf2).
333 glissement(ma,g,Conf1,Conf2,Xm1,Ym1):-
334 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-M2]),
335 gen_assoc(vi,Conf1,[1-V1,2-(Xv2,Ym1)]),
337 put_assoc(ma,Conf1,[1-(Xv2,Ym1),2-M2],Conf1b),
338 put_assoc(vi,Conf1b,[1-V1,2-(Xm1,Ym1)],Conf2).
341 glissement(ma,g,Conf1,Conf2,Xm2,Ym2):-
342 gen_assoc(ma,Conf1,[1-M1,2-(Xm2,Ym2)]),
343 gen_assoc(vi,Conf1,[1-(Xv1,Ym2),2-V2]),
345 ordonne(M1,(Xv1,Ym2),M1p,M2p),
346 put_assoc(ma,Conf1,[1-M1p,2-M2p],Conf1b),
347 ordonne((Xm2,Ym2),V2,V1p,V2p),
348 put_assoc(vi,Conf1b,[1-V1p,2-V2p],Conf2).
351 glissement(ma,g,Conf1,Conf2,Xm2,Ym2):-
352 gen_assoc(ma,Conf1,[1-M1,2-(Xm2,Ym2)]),
353 gen_assoc(vi,Conf1,[1-V1,2-(Xv2,Ym2)]),
355 ordonne(M1,(Xv2,Ym2),M1p,M2p),
356 put_assoc(ma,Conf1,[1-M1p,2-M2p],Conf1b),
357 put_assoc(vi,Conf1b,[1-V1,2-(Xm2,Ym2)],Conf2).
361 glissement(ma,b,Conf1,Conf2,Xm1,Ym1):-
362 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-M2]),
363 gen_assoc(vi,Conf1,[1-(Xm1,Yv1),2-Nv2]),
365 put_assoc(ma,Conf1,[1-(Xm1,Yv1),2-M2],Conf1b),
366 put_assoc(vi,Conf1b,[1-(Xm1,Ym1),2-Nv2],Conf2).
369 glissement(ma,b,Conf1,Conf2,Xm1,Ym1):-
370 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-M2]),
371 gen_assoc(vi,Conf1,[1-V1,2-(Xm1,Yv2)]),
373 put_assoc(ma,Conf1,[1-(Xm1,Yv2),2-M2],Conf1b),
374 put_assoc(vi,Conf1b,[1-V1,2-(Xm1,Ym1)],Conf2).
377 glissement(ma,b,Conf1,Conf2,Xm2,Ym2):-
378 gen_assoc(ma,Conf1,[1-M1,2-(Xm2,Ym2)]),
379 gen_assoc(vi,Conf1,[1-(Xm2,Yv1),2-V2]),
381 put_assoc(ma,Conf1,[1-M1,2-(Xm2,Yv1)],Conf1b),
382 put_assoc(vi,Conf1b,[1-(Xm2,Ym2),2-V2],Conf2).
385 glissement(ma,b,Conf1,Conf2,Xm2,Ym2):-
386 gen_assoc(ma,Conf1,[1-M1,2-(Xm2,Ym2)]),
387 gen_assoc(vi,Conf1,[1-V1,2-(Xm2,Yv2)]),
389 put_assoc(ma,Conf1,[1-M1,2-(Xm2,Yv2)],Conf1b),
390 put_assoc(vi,Conf1b,[1-V1,2-(Xm2,Ym2)],Conf2).
393 glissement(ma,h,Conf1,Conf2,Xm1,Ym1):-
394 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-M2]),
395 gen_assoc(vi,Conf1,[1-(Xm1,Yv1),2-V2]),
397 put_assoc(ma,Conf1,[1-(Xm1,Yv1),2-M2],Conf1b),
398 put_assoc(vi,Conf1b,[1-(Xm1,Ym1),2-V2],Conf2).
401 glissement(ma,h,Conf1,Conf2,Xm1,Ym1):-
402 gen_assoc(ma,Conf1,[1-(Xm1,Ym1),2-M2]),
403 gen_assoc(vi,Conf1,[1-V1,2-(Xm1,Yv2)]),
405 put_assoc(ma,Conf1,[1-(Xm1,Yv2),2-M2],Conf1b),
406 put_assoc(vi,Conf1b,[1-V1,2-(Xm1,Ym1)],Conf2).
409 glissement(ma,h,Conf1,Conf2,Xm2,Ym2):-
410 gen_assoc(ma,Conf1,[1-M1,2-(Xm2,Ym2)]),
411 gen_assoc(vi,Conf1,[1-(Xm2,Yv1),2-V2]),
413 put_assoc(ma,Conf1,[1-M1,2-(Xm2,Yv1)],Conf1b),
414 put_assoc(vi,Conf1b,[1-(Xm2,Ym2),2-V2],Conf2).
417 glissement(ma,h,Conf1,Conf2,Xm2,Ym2):-
418 gen_assoc(ma,Conf1,[1-M1,2-(Xm2,Ym2)]),
419 gen_assoc(vi,Conf1,[1-V1,2-(Xm2,Yv2)]),
421 put_assoc(ma,Conf1,[1-M1,2-(Xm2,Yv2)],Conf1b),
422 put_assoc(vi,Conf1b,[1-V1,2-(Xm2,Ym2)],Conf2).
424 /**********Reste le bois ********/
427 glissement(bo,d,Conf1,Conf2,Xm1,Ym1):-
428 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-(Xm2,Ym2)]),
429 gen_assoc(vi,Conf1,[1-(Xv1,Ym1),2-Nv2]),
431 ordonne((Xv1,Ym1),(Xm2,Ym2),Nm1,Nm2),
432 put_assoc(bo,Conf1,[1-Nm1,2-Nm2],Conf1b),
433 put_assoc(vi,Conf1b,[1-(Xm1,Ym1),2-Nv2],Conf2).
436 glissement(bo,d,Conf1,Conf2,Xm1,Ym1):-
437 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-(Xm2,Ym2)]),
438 gen_assoc(vi,Conf1,[1-(Xv1,Yv1),2-(Xv2,Ym1)]),
440 ordonne((Xv2,Ym1),(Xm2,Ym2),Nm1,Nm2),
441 put_assoc(bo,Conf1,[1-Nm1,2-Nm2],Conf1b),
442 ordonne((Xv1,Yv1),(Xm1,Ym1),Nv1,Nv2),
443 put_assoc(vi,Conf1b,[1-Nv1,2-Nv2],Conf2).
446 glissement(bo,d,Conf1,Conf2,Xm2,Ym2):-
447 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-(Xm2,Ym2)]),
448 gen_assoc(vi,Conf1,[1-(Xv1,Ym2),2-Nv2]),
450 put_assoc(bo,Conf1,[1-(Xm1,Ym1),2-(Xv1,Ym2)],Conf1b),
451 put_assoc(vi,Conf1b,[1-(Xm2,Ym2),2-Nv2],Conf2).
454 glissement(bo,d,Conf1,Conf2,Xm2,Ym2):-
455 gen_assoc(bo,Conf1,[1-M1,2-(Xm2,Ym2)]),
456 gen_assoc(vi,Conf1,[1-Nv1,2-(Xv2,Ym2)]),
458 put_assoc(bo,Conf1,[1-M1,2-(Xv2,Ym2)],Conf1b),
459 ordonne(Nv1,(Xm2,Ym2),Nv1,Nv2),
460 put_assoc(vi,Conf1b,[1-Nv1,2-Nv2],Conf2).
464 glissement(bo,g,Conf1,Conf2,Xm1,Ym1):-
465 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-M2]),
466 gen_assoc(vi,Conf1,[1-(Xv1,Ym1),2-Nv2]),
468 put_assoc(bo,Conf1,[1-(Xv1,Ym1),2-M2],Conf1b),
469 ordonne((Xm1,Ym1),Nv2,Nv1p,Nv2p),
470 put_assoc(vi,Conf1b,[1-Nv1p,2-Nv2p],Conf2).
473 glissement(bo,g,Conf1,Conf2,Xm1,Ym1):-
474 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-M2]),
475 gen_assoc(vi,Conf1,[1-V1,2-(Xv2,Ym1)]),
477 put_assoc(bo,Conf1,[1-(Xv2,Ym1),2-M2],Conf1b),
478 put_assoc(vi,Conf1b,[1-V1,2-(Xm1,Ym1)],Conf2).
481 glissement(bo,g,Conf1,Conf2,Xm2,Ym2):-
482 gen_assoc(bo,Conf1,[1-M1,2-(Xm2,Ym2)]),
483 gen_assoc(vi,Conf1,[1-(Xv1,Ym2),2-V2]),
485 ordonne(M1,(Xv1,Ym2),M1p,M2p),
486 put_assoc(bo,Conf1,[1-M1p,2-M2p],Conf1b),
487 ordonne((Xm2,Ym2),V2,V1p,V2p),
488 put_assoc(vi,Conf1b,[1-V1p,2-V2p],Conf2).
491 glissement(bo,g,Conf1,Conf2,Xm2,Ym2):-
492 gen_assoc(bo,Conf1,[1-M1,2-(Xm2,Ym2)]),
493 gen_assoc(vi,Conf1,[1-V1,2-(Xv2,Ym2)]),
495 ordonne(M1,(Xv2,Ym2),M1p,M2p),
496 put_assoc(bo,Conf1,[1-M1p,2-M2p],Conf1b),
497 put_assoc(vi,Conf1b,[1-V1,2-(Xm2,Ym2)],Conf2).
501 glissement(bo,b,Conf1,Conf2,Xm1,Ym1):-
502 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-M2]),
503 gen_assoc(vi,Conf1,[1-(Xm1,Yv1),2-Nv2]),
505 put_assoc(bo,Conf1,[1-(Xm1,Yv1),2-M2],Conf1b),
506 put_assoc(vi,Conf1b,[1-(Xm1,Ym1),2-Nv2],Conf2).
509 glissement(bo,b,Conf1,Conf2,Xm1,Ym1):-
510 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-M2]),
511 gen_assoc(vi,Conf1,[1-V1,2-(Xm1,Yv2)]),
513 put_assoc(bo,Conf1,[1-(Xm1,Yv2),2-M2],Conf1b),
514 put_assoc(vi,Conf1b,[1-V1,2-(Xm1,Ym1)],Conf2).
517 glissement(bo,b,Conf1,Conf2,Xm2,Ym2):-
518 gen_assoc(bo,Conf1,[1-M1,2-(Xm2,Ym2)]),
519 gen_assoc(vi,Conf1,[1-(Xm2,Yv1),2-V2]),
521 put_assoc(bo,Conf1,[1-M1,2-(Xm2,Yv1)],Conf1b),
522 put_assoc(vi,Conf1b,[1-(Xm2,Ym2),2-V2],Conf2).
525 glissement(bo,b,Conf1,Conf2,Xm2,Ym2):-
526 gen_assoc(bo,Conf1,[1-M1,2-(Xm2,Ym2)]),
527 gen_assoc(vi,Conf1,[1-V1,2-(Xm2,Yv2)]),
529 put_assoc(bo,Conf1,[1-M1,2-(Xm2,Yv2)],Conf1b),
530 put_assoc(vi,Conf1b,[1-V1,2-(Xm2,Ym2)],Conf2).
533 glissement(bo,h,Conf1,Conf2,Xm1,Ym1):-
534 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-M2]),
535 gen_assoc(vi,Conf1,[1-(Xm1,Yv1),2-V2]),
537 put_assoc(bo,Conf1,[1-(Xm1,Yv1),2-M2],Conf1b),
538 put_assoc(vi,Conf1b,[1-(Xm1,Ym1),2-V2],Conf2).
541 glissement(bo,h,Conf1,Conf2,Xm1,Ym1):-
542 gen_assoc(bo,Conf1,[1-(Xm1,Ym1),2-M2]),
543 gen_assoc(vi,Conf1,[1-V1,2-(Xm1,Yv2)]),
545 put_assoc(bo,Conf1,[1-(Xm1,Yv2),2-M2],Conf1b),
546 put_assoc(vi,Conf1b,[1-V1,2-(Xm1,Ym1)],Conf2).
549 glissement(bo,h,Conf1,Conf2,Xm2,Ym2):-
550 gen_assoc(bo,Conf1,[1-M1,2-(Xm2,Ym2)]),
551 gen_assoc(vi,Conf1,[1-(Xm2,Yv1),2-V2]),
553 put_assoc(bo,Conf1,[1-M1,2-(Xm2,Yv1)],Conf1b),
554 put_assoc(vi,Conf1b,[1-(Xm2,Ym2),2-V2],Conf2).
557 glissement(bo,h,Conf1,Conf2,Xm2,Ym2):-
558 gen_assoc(bo,Conf1,[1-M1,2-(Xm2,Ym2)]),
559 gen_assoc(vi,Conf1,[1-V1,2-(Xm2,Yv2)]),
561 put_assoc(bo,Conf1,[1-M1,2-(Xm2,Yv2)],Conf1b),
562 put_assoc(vi,Conf1b,[1-V1,2-(Xm2,Ym2)],Conf2).
565 retour(L,Col,d,L,Cp,g):-
567 retour(L,Col,g,L,Cp,d):-
569 retour(Lig,C,h,Lp,C,b):-
571 retour(Lig,C,b,Lp,C,h):-
575 gl_time(P,D,Confa,Confb):-
577 glissement(P,D,Confa,Confb),
580 write('depl : '),writeln(DT3).
586 /* Tous les successeurs d une configuration */
587 successeurs(Confa-Chemins,L):-
589 Confb-[((Lig,Col),D)|Chemins],
590 gl_ok(_,D,Confa,Confb,Lig,Col),
593 successeurs_liste(L,Sl):-
594 maplist(successeurs,L,Lp),
596 list_to_assoc(Lpp,A),
601 /* regarde si le premier parametre appartient
602 \81à la liste donn
\81é en second parametre. Si c est le cas,
603 retourne le chemin */
610 appartient(Conf1-_,[Conf1-_|_]):-!.
611 appartient(Conf1-C,[_|L]):-
612 appartient(Conf1-C,L).
616 difference([El|L1],L2,Res):-
619 difference(L1,L2,Res).
620 difference([El|L1],L2,[El|Res]):-
621 difference(L1,L2,Res).
628 but([Conf-Chemin|_],Chemin):-final(Conf),!.
629 but([_|L],Chemin):-but(L,Chemin).
632 largeur(Atraiter,_,_,Res):-
635 largeur(Atraiter,Visites,C,Res):-
637 write('boucle'), writeln(C),
639 successeurs_liste(Atraiter,Succ),
641 write('taille succ : '),writeln(Taille),
644 append(Atraiter,Visites,Visites2),
646 difference(Succ,Visites2,Atraiter2),
649 write('successeur : '),writeln(DT1),
650 write('difference : '),writeln(DT3),
651 largeur(Atraiter2,Visites2,Cp,Res).
655 largeur([X-[]],[],0,Res).
665 ja-[1-(0,0),2-(3,0)],
667 no-[1-(0,2),2-(3,2)],
669 ma-[1-(0,4),2-(3,4)],
670 bo-[1-(1,3),2-(2,3)],
671 vi-[1-(1,4),2-(2,4)]],
675 gen_assoc(no,X,[1-(1,3),2-(3,3)]),
676 gen_assoc(bl,X,[1-(1,2)]),
677 gen_assoc(ma,X,[1-(0,3),_]).
680 gen_assoc(no,X,[1-(1,3),2-(2,3)]),