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