1*6772Srrh static char sccsid[] = " tutor.c 1.1 82/05/11 "; 2*6772Srrh 3*6772Srrh #include "back.h" 4*6772Srrh #include "tutor.h" 5*6772Srrh 6*6772Srrh extern int maxmoves; 7*6772Srrh extern char *finis[]; 8*6772Srrh 9*6772Srrh extern struct situatn test[]; 10*6772Srrh 11*6772Srrh static char better[] = "That is a legal move, but there is a better one.\n"; 12*6772Srrh 13*6772Srrh tutor () { 14*6772Srrh register int i, j; 15*6772Srrh 16*6772Srrh i = 0; 17*6772Srrh begscr = 18; 18*6772Srrh cturn = -1; 19*6772Srrh home = 0; 20*6772Srrh bar = 25; 21*6772Srrh inptr = &in[0]; 22*6772Srrh inopp = &in[1]; 23*6772Srrh offptr = &off[0]; 24*6772Srrh offopp = &off[1]; 25*6772Srrh Colorptr = &color[0]; 26*6772Srrh colorptr = &color[2]; 27*6772Srrh colen = 5; 28*6772Srrh wrboard(); 29*6772Srrh 30*6772Srrh while (1) { 31*6772Srrh if (! brdeq(test[i].brd,board)) { 32*6772Srrh if (tflag && curr == 23) 33*6772Srrh curmove (18,0); 34*6772Srrh writel (better); 35*6772Srrh nexturn(); 36*6772Srrh movback (mvlim); 37*6772Srrh if (tflag) { 38*6772Srrh refresh(); 39*6772Srrh clrest (); 40*6772Srrh } 41*6772Srrh if ((! tflag) || curr == 19) { 42*6772Srrh proll(); 43*6772Srrh writec ('\t'); 44*6772Srrh } 45*6772Srrh else 46*6772Srrh curmove (curr > 19? curr-2: curr+4,25); 47*6772Srrh getmove(); 48*6772Srrh if (cturn == 0) 49*6772Srrh leave(); 50*6772Srrh continue; 51*6772Srrh } 52*6772Srrh if (tflag) 53*6772Srrh curmove (18,0); 54*6772Srrh text (*test[i].com); 55*6772Srrh if (! tflag) 56*6772Srrh writec ('\n'); 57*6772Srrh if (i == maxmoves) 58*6772Srrh break; 59*6772Srrh D0 = test[i].roll1; 60*6772Srrh D1 = test[i].roll2; 61*6772Srrh d0 = 0; 62*6772Srrh mvlim = 0; 63*6772Srrh for (j = 0; j < 4; j++) { 64*6772Srrh if (test[i].mp[j] == test[i].mg[j]) 65*6772Srrh break; 66*6772Srrh p[j] = test[i].mp[j]; 67*6772Srrh g[j] = test[i].mg[j]; 68*6772Srrh mvlim++; 69*6772Srrh } 70*6772Srrh if (mvlim) 71*6772Srrh for (j = 0; j < mvlim; j++) 72*6772Srrh if (makmove(j)) 73*6772Srrh writel ("AARGH!!!\n"); 74*6772Srrh if (tflag) 75*6772Srrh refresh(); 76*6772Srrh nexturn(); 77*6772Srrh D0 = test[i].new1; 78*6772Srrh D1 = test[i].new2; 79*6772Srrh d0 = 0; 80*6772Srrh i++; 81*6772Srrh mvlim = movallow(); 82*6772Srrh if (mvlim) { 83*6772Srrh if (tflag) 84*6772Srrh clrest(); 85*6772Srrh proll(); 86*6772Srrh writec('\t'); 87*6772Srrh getmove(); 88*6772Srrh if (tflag) 89*6772Srrh refresh(); 90*6772Srrh if (cturn == 0) 91*6772Srrh leave(); 92*6772Srrh } 93*6772Srrh } 94*6772Srrh leave(); 95*6772Srrh } 96*6772Srrh 97*6772Srrh clrest () { 98*6772Srrh register int r, c, j; 99*6772Srrh 100*6772Srrh r = curr; 101*6772Srrh c = curc; 102*6772Srrh for (j = r+1; j < 24; j++) { 103*6772Srrh curmove (j,0); 104*6772Srrh cline(); 105*6772Srrh } 106*6772Srrh curmove (r,c); 107*6772Srrh } 108*6772Srrh 109*6772Srrh brdeq (b1,b2) 110*6772Srrh register int *b1, *b2; 111*6772Srrh 112*6772Srrh { 113*6772Srrh register int *e; 114*6772Srrh 115*6772Srrh e = b1+26; 116*6772Srrh while (b1 < e) 117*6772Srrh if (*b1++ != *b2++) 118*6772Srrh return(0); 119*6772Srrh return(1); 120*6772Srrh } 121