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