121205Sdist /* 2*60746Sbostic * Copyright (c) 1980, 1993 3*60746Sbostic * The Regents of the University of California. All rights reserved. 433487Sbostic * 542559Sbostic * %sccs.include.redist.c% 621205Sdist */ 76751Srrh 821205Sdist #ifndef lint 9*60746Sbostic static char sccsid[] = "@(#)allow.c 8.1 (Berkeley) 05/31/93"; 1033487Sbostic #endif /* not lint */ 1121205Sdist 126751Srrh #include "back.h" 136751Srrh movallow()146751Srrhmovallow () { 156751Srrh 166751Srrh register int i, m, iold; 176751Srrh int r; 186751Srrh 196751Srrh if (d0) 206751Srrh swap; 216751Srrh m = (D0 == D1? 4: 2); 226751Srrh for (i = 0; i < 4; i++) 236751Srrh p[i] = bar; 246751Srrh i = iold = 0; 256751Srrh while (i < m) { 266751Srrh if (*offptr == 15) 276751Srrh break; 286751Srrh h[i] = 0; 296751Srrh if (board[bar]) { 306751Srrh if (i == 1 || m == 4) 316751Srrh g[i] = bar+cturn*D1; 326751Srrh else 336751Srrh g[i] = bar+cturn*D0; 346751Srrh if (r = makmove(i)) { 356751Srrh if (d0 || m == 4) 366751Srrh break; 376751Srrh swap; 386751Srrh movback (i); 396751Srrh if (i > iold) 406751Srrh iold = i; 416751Srrh for (i = 0; i < 4; i++) 426751Srrh p[i] = bar; 436751Srrh i = 0; 446751Srrh } else 456751Srrh i++; 466751Srrh continue; 476751Srrh } 486751Srrh if ((p[i] += cturn) == home) { 496751Srrh if (i > iold) 506751Srrh iold = i; 516751Srrh if (m == 2 && i) { 526751Srrh movback(i); 536751Srrh p[i--] = bar; 546751Srrh if (p[i] != bar) 556751Srrh continue; 566751Srrh else 576751Srrh break; 586751Srrh } 596751Srrh if (d0 || m == 4) 606751Srrh break; 616751Srrh swap; 626751Srrh movback (i); 636751Srrh for (i = 0; i < 4; i++) 646751Srrh p[i] = bar; 656751Srrh i = 0; 666751Srrh continue; 676751Srrh } 686751Srrh if (i == 1 || m == 4) 696751Srrh g[i] = p[i]+cturn*D1; 706751Srrh else 716751Srrh g[i] = p[i]+cturn*D0; 726751Srrh if (g[i]*cturn > home) { 736751Srrh if (*offptr >= 0) 746751Srrh g[i] = home; 756751Srrh else 766751Srrh continue; 776751Srrh } 786751Srrh if (board[p[i]]*cturn > 0 && (r = makmove(i)) == 0) 796751Srrh i++; 806751Srrh } 816751Srrh movback (i); 826751Srrh return (iold > i? iold: i); 836751Srrh } 84