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