1 /* 2 * Copyright (c) 1980, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * %sccs.include.redist.c% 6 */ 7 8 #ifndef lint 9 static char sccsid[] = "@(#)allow.c 8.1 (Berkeley) 05/31/93"; 10 #endif /* not lint */ 11 12 #include "back.h" 13 14 movallow () { 15 16 register int i, m, iold; 17 int r; 18 19 if (d0) 20 swap; 21 m = (D0 == D1? 4: 2); 22 for (i = 0; i < 4; i++) 23 p[i] = bar; 24 i = iold = 0; 25 while (i < m) { 26 if (*offptr == 15) 27 break; 28 h[i] = 0; 29 if (board[bar]) { 30 if (i == 1 || m == 4) 31 g[i] = bar+cturn*D1; 32 else 33 g[i] = bar+cturn*D0; 34 if (r = makmove(i)) { 35 if (d0 || m == 4) 36 break; 37 swap; 38 movback (i); 39 if (i > iold) 40 iold = i; 41 for (i = 0; i < 4; i++) 42 p[i] = bar; 43 i = 0; 44 } else 45 i++; 46 continue; 47 } 48 if ((p[i] += cturn) == home) { 49 if (i > iold) 50 iold = i; 51 if (m == 2 && i) { 52 movback(i); 53 p[i--] = bar; 54 if (p[i] != bar) 55 continue; 56 else 57 break; 58 } 59 if (d0 || m == 4) 60 break; 61 swap; 62 movback (i); 63 for (i = 0; i < 4; i++) 64 p[i] = bar; 65 i = 0; 66 continue; 67 } 68 if (i == 1 || m == 4) 69 g[i] = p[i]+cturn*D1; 70 else 71 g[i] = p[i]+cturn*D0; 72 if (g[i]*cturn > home) { 73 if (*offptr >= 0) 74 g[i] = home; 75 else 76 continue; 77 } 78 if (board[p[i]]*cturn > 0 && (r = makmove(i)) == 0) 79 i++; 80 } 81 movback (i); 82 return (iold > i? iold: i); 83 } 84