|
|
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: * @(#)back.h 5.3 (Berkeley) 6/18/88 ! 18: */ ! 19: ! 20: #include <sgtty.h> ! 21: ! 22: #define rnum(r) (random()%r) ! 23: #define D0 dice[0] ! 24: #define D1 dice[1] ! 25: #define swap {D0 ^= D1; D1 ^= D0; D0 ^= D1; d0 = 1-d0;} ! 26: ! 27: /* ! 28: * ! 29: * Some numerical conventions: ! 30: * ! 31: * Arrays have white's value in [0], red in [1]. ! 32: * Numeric values which are one color or the other use ! 33: * -1 for white, 1 for red. ! 34: * Hence, white will be negative values, red positive one. ! 35: * This makes a lot of sense since white is going in decending ! 36: * order around the board, and red is ascending. ! 37: * ! 38: */ ! 39: ! 40: char EXEC[]; /* object for main program */ ! 41: char TEACH[]; /* object for tutorial program */ ! 42: ! 43: int pnum; /* color of player: ! 44: -1 = white ! 45: 1 = red ! 46: 0 = both ! 47: 2 = not yet init'ed */ ! 48: char args[100]; /* args passed to teachgammon and back */ ! 49: int acnt; /* length of args */ ! 50: int aflag; /* flag to ask for rules or instructions */ ! 51: int bflag; /* flag for automatic board printing */ ! 52: int cflag; /* case conversion flag */ ! 53: int hflag; /* flag for cleaning screen */ ! 54: int mflag; /* backgammon flag */ ! 55: int raflag; /* 'roll again' flag for recovered game */ ! 56: int rflag; /* recovered game flag */ ! 57: int tflag; /* cursor addressing flag */ ! 58: int rfl; /* saved value of rflag */ ! 59: int iroll; /* special flag for inputting rolls */ ! 60: int board[26]; /* board: negative values are white, ! 61: positive are red */ ! 62: int dice[2]; /* value of dice */ ! 63: int mvlim; /* 'move limit': max. number of moves */ ! 64: int mvl; /* working copy of mvlim */ ! 65: int p[5]; /* starting position of moves */ ! 66: int g[5]; /* ending position of moves (goals) */ ! 67: int h[4]; /* flag for each move if a man was hit */ ! 68: int cturn; /* whose turn it currently is: ! 69: -1 = white ! 70: 1 = red ! 71: 0 = just quitted ! 72: -2 = white just lost ! 73: 2 = red just lost */ ! 74: int d0; /* flag if dice have been reversed from ! 75: original position */ ! 76: int table[6][6]; /* odds table for possible rolls */ ! 77: int rscore; /* red's score */ ! 78: int wscore; /* white's score */ ! 79: int gvalue; /* value of game (64 max.) */ ! 80: int dlast; /* who doubled last (0 = neither) */ ! 81: int bar; /* position of bar for current player */ ! 82: int home; /* position of home for current player */ ! 83: int off[2]; /* number of men off board */ ! 84: int *offptr; /* pointer to off for current player */ ! 85: int *offopp; /* pointer to off for opponent */ ! 86: int in[2]; /* number of men in inner table */ ! 87: int *inptr; /* pointer to in for current player */ ! 88: int *inopp; /* pointer to in for opponent */ ! 89: ! 90: int ncin; /* number of characters in cin */ ! 91: char cin[100]; /* input line of current move ! 92: (used for reconstructing input after ! 93: a backspace) */ ! 94: ! 95: char *color[]; ! 96: /* colors as strings */ ! 97: char **colorptr; /* color of current player */ ! 98: char **Colorptr; /* color of current player, capitalized */ ! 99: int colen; /* length of color of current player */ ! 100: ! 101: struct sgttyb tty; /* tty information buffer */ ! 102: int old; /* original tty status */ ! 103: int noech; /* original tty status without echo */ ! 104: int raw; /* raw tty status, no echo */ ! 105: ! 106: int curr; /* row position of cursor */ ! 107: int curc; /* column position of cursor */ ! 108: int begscr; /* 'beginning' of screen ! 109: (not including board) */ ! 110: ! 111: int getout(); /* function to exit backgammon cleanly */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.