Annotation of 43BSDTahoe/games/backgammon/tutor.c, revision 1.1.1.1

1.1       root        1: /*
                      2:  * Copyright (c) 1980 Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms are permitted
                      6:  * provided that the above copyright notice and this paragraph are
                      7:  * duplicated in all such forms and that any documentation,
                      8:  * advertising materials, and other materials related to such
                      9:  * distribution and use acknowledge that the software was developed
                     10:  * by the University of California, Berkeley.  The name of the
                     11:  * University may not be used to endorse or promote products derived
                     12:  * from this software without specific prior written permission.
                     13:  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
                     14:  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
                     15:  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
                     16:  */
                     17: 
                     18: #ifndef lint
                     19: static char sccsid[] = "@(#)tutor.c    5.3 (Berkeley) 6/18/88";
                     20: #endif /* not lint */
                     21: 
                     22: #include "back.h"
                     23: #include "tutor.h"
                     24: 
                     25: extern int     maxmoves;
                     26: extern char    *finis[];
                     27: 
                     28: extern struct situatn  test[];
                     29: 
                     30: static char    better[] = "That is a legal move, but there is a better one.\n";
                     31: 
                     32: tutor ()  {
                     33:        register int    i, j;
                     34: 
                     35:        i = 0;
                     36:        begscr = 18;
                     37:        cturn = -1;
                     38:        home = 0;
                     39:        bar = 25;
                     40:        inptr = &in[0];
                     41:        inopp = &in[1];
                     42:        offptr = &off[0];
                     43:        offopp = &off[1];
                     44:        Colorptr = &color[0];
                     45:        colorptr = &color[2];
                     46:        colen = 5;
                     47:        wrboard();
                     48: 
                     49:        while (1)  {
                     50:                if (! brdeq(test[i].brd,board))  {
                     51:                        if (tflag && curr == 23)
                     52:                                curmove (18,0);
                     53:                        writel (better);
                     54:                        nexturn();
                     55:                        movback (mvlim);
                     56:                        if (tflag)  {
                     57:                                refresh();
                     58:                                clrest ();
                     59:                        }
                     60:                        if ((! tflag) || curr == 19)  {
                     61:                                proll();
                     62:                                writec ('\t');
                     63:                        }
                     64:                        else
                     65:                                curmove (curr > 19? curr-2: curr+4,25);
                     66:                        getmove();
                     67:                        if (cturn == 0)
                     68:                                leave();
                     69:                        continue;
                     70:                }
                     71:                if (tflag)
                     72:                        curmove (18,0);
                     73:                text (*test[i].com);
                     74:                if (! tflag)
                     75:                        writec ('\n');
                     76:                if (i == maxmoves)
                     77:                        break;
                     78:                D0 = test[i].roll1;
                     79:                D1 = test[i].roll2;
                     80:                d0 = 0;
                     81:                mvlim = 0;
                     82:                for (j = 0; j < 4; j++)  {
                     83:                        if (test[i].mp[j] == test[i].mg[j])
                     84:                                break;
                     85:                        p[j] = test[i].mp[j];
                     86:                        g[j] = test[i].mg[j];
                     87:                        mvlim++;
                     88:                }
                     89:                if (mvlim)
                     90:                        for (j = 0; j < mvlim; j++)
                     91:                                if (makmove(j))
                     92:                                        writel ("AARGH!!!\n");
                     93:                if (tflag)
                     94:                        refresh();
                     95:                nexturn();
                     96:                D0 = test[i].new1;
                     97:                D1 = test[i].new2;
                     98:                d0 = 0;
                     99:                i++;
                    100:                mvlim = movallow();
                    101:                if (mvlim)  {
                    102:                        if (tflag)
                    103:                                clrest();
                    104:                        proll();
                    105:                        writec('\t');
                    106:                        getmove();
                    107:                        if (tflag)
                    108:                                refresh();
                    109:                        if (cturn == 0)
                    110:                                leave();
                    111:                }
                    112:        }
                    113:        leave();
                    114: }
                    115: 
                    116: clrest ()  {
                    117:        register int    r, c, j;
                    118: 
                    119:        r = curr;
                    120:        c = curc;
                    121:        for (j = r+1; j < 24; j++)  {
                    122:                curmove (j,0);
                    123:                cline();
                    124:        }
                    125:        curmove (r,c);
                    126: }
                    127: 
                    128: brdeq (b1,b2)
                    129: register int  *b1, *b2;
                    130: 
                    131: {
                    132:        register int  *e;
                    133: 
                    134:        e = b1+26;
                    135:        while (b1 < e)
                    136:                if (*b1++ != *b2++)
                    137:                        return(0);
                    138:        return(1);
                    139: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.