|
|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: T c
Length: 12208 (0x2fb0)
Types: TextFile
Names: »cubes.h«
└─⟦b20c6495f⟧ Bits:30007238 EUUGD18: Wien-båndet, efterår 1987
└─⟦this⟧ »EUUGD18/General/Cubes/cubes.h«
/* vi:set sw=4 ts=4: */
/*
** sccsid: @(#)cubes.h 5.1 (G.M. Paris) 89/01/22
*/
/*
**
** cubes 5.1 Copyright 1989 Gregory M. Paris
** Permission granted to redistribute on a no charge basis.
** All other rights are reserved.
**
*/
/*
** If you don't want Four_of_a_kind or Small_straight, then comment these out.
** Unfortunately, you'll have to recalculate the values in risktbl[] if you do.
** The existence of Jokers is controlled by a cubeserver command line option.
*/
#define FOUR 4 /* how many in a four of a kind (if defined) */
#define SMSTR 4 /* number of dice in small straight (if def) */
#define ASMSTR 5 /* number of dice in assembled straight (if def) */
/*
** Although you could change any of the following parameters, the nature of
** the game would be altered. Also, some things like 5o'kind are hard coded
** in places and would not change automatically. Best to leave be.
*/
#define SIDES 6 /* six sided dice */
#define NDICE 5 /* number of dice in set */
#define ONBOARD 500 /* turn score needed to get on scoreboard */
#define OFFBOARD 500 /* turn score needed to cross WINSCORE thresh */
#define WINSCORE 10000 /* minimum score needed to win in Standard game */
#define BLITZSCORE 7500 /* minimum score needed to win in Blitz game */
#define WINMARGIN 250 /* winner must best others by this margin */
/*
** These values are the basis for scoring. Again, if you change them, the
** play of the game will be altered. Leave them as they are.
*/
#define P_ACEMULT 10 /* ace is worth disproportionate amount */
#define P_AOKMULT 300 /* multiplier for all of a kind */
#define P_STRAIGHT 1500 /* points for straight */
#define P_ASMSTR 750 /* points for assembled straight */
#define P_4OKMULT 200 /* multiplier for three of a kind */
#define P_SMSTR 400 /* points for a small straight */
#define P_3OKMULT 100 /* multiplier for three of a kind */
#define P_ACE 100 /* points for single ace */
#define P_FIVE 50 /* points for single five */
#define P_JOKER 0 /* value of single Jokers */
#define P_JOKERMULT 30 /* <n>o'kind multiplier for Jokers */
/*
** The following defines are just symbolic values for numbers.
*/
#define BADFACE 0 /* impossible die face */
#define ACE 1 /* an ACE is a one, a scoring die */
#define DEUCE 2 /* an DEUCE is a two, the most worthless die */
#define THREE 3 /* how many in a Three_of_a_kind or the face name */
#define FIVE 5 /* FIVE is five, a scoring die */
#define JOKER 9 /* an imphysical die face and scoring die */
#define MESGLEN 128 /* length of message buffer */
#define NAMELEN 64 /* player name buffer length */
#define IDLEN 64 /* player identity buffer length */
#define DISPLEN 18 /* field width in client name display */
#define COMP 0 /* computer starts as player zero */
#define PLAYERS 10 /* max players (client score window limits) */
#define MINPLR 4 /* min players at game begining */
#define MINCOMP 2 /* min computers at game beginning */
#define WRITETIMO 20 /* timeout on socket writes */
#define READTIMO 60 /* timeout on socket reads */
#define MAXTIMO 3 /* too many timeouts -- goodbye! */
/*
** The ANCIENT value is used to prune old records from the history.
** The two credit values give additional grace to players as a multiplier
** of the number of games played.
*/
#define ANCIENT ((long)(nhist + 1)) /* depends on number of players */
#define ANALCREDIT 0 /* games played credit in histanal */
#define WRITECREDIT 5 /* games played credit in histwrite */
/*
** To mark asynchronous requests, we prepend each with ASYNCMARK.
** It should not be a character that would normally be typed.
*/
#define ASYNCMARK '\1' /* control-A */
/*
** Message numbers. Defined as enum so that we can keep them
** sequential without much trouble. This allows the dispatching
** function in the client to be faster, since we can avoid doing
** a linear search of the action table by using a function array.
XXX We assume that enums are ints for use in sprintf() calls.
*/
#define M_BASE 100 /* lowest message number */
typedef enum {
M_NOOP = M_BASE, /* no operation (usually heartbeat) */
M_INFO, /* informational or status messages */
M_HELP, /* help messages */
M_DICE, /* complete dice status */
M_PARM, /* game parameters */
M_PLAY, /* play-by-play on other players */
M_HELO, /* hello message */
M_DOWN, /* shutdown message */
M_RQID, /* id request */
M_WORP, /* watch or play? */
M_SORP, /* wait (spider) or play? */
M_ACTV, /* you are an active player */
M_AUTO, /* you are on autopilot */
M_WAIT, /* you are waiting to be added */
M_VOYR, /* you are now a voyeur */
M_SPDR, /* you are now a spider */
M_TURN, /* Player %d, ... up with %d points. */
M_NWIN, /* game over, no winner */
M_OVER, /* Player %d has won the game! */
M_RANK, /* player rank at end of game */
M_CPLR, /* clear all players */
M_UARE, /* you are player %d */
M_PNUM, /* player %d %s */
M_FARE, /* farewell %d %s */
M_NOBS, /* %d observer[s] */
M_MSCO, /* You now have %d points. */
M_OSCO, /* Player %d now has %d points. */
M_ANOG, /* play another game? */
M_RFST, /* Ready to roll? */
M_KEEP, /* %d points: */
M_ARGE, /* argument error */
M_BADM /* bad message */
} m_num;
#define M_LAST (int)M_BADM /* highest message number */
/*
** Definitions for status queries. For now, only one query
** type, and only two status responses are supported.
*/
#define STATLEN 512 /* max length of status response */
#define Q_ROSTER '\1' /* query: current player roster */
#define S_IDLE '\1' /* status: idle */
#define S_ROSTER '\2' /* status: current player roster */
#define S_UNRECOG '\177' /* status: unrecognized query */
/*
** Some stuff for converting numbers to names. Probably should be elsewhere.
*/
extern char *numnames[][2];
#define NUMBER(n) (numnames[n][0])
#ifdef lint
#define FACE(show,ndice) (numnames[show][ndice]) /* fake to shut up lint */
#else lint
#define FACE(show,ndice) (numnames[show][(ndice)!=1])
#endif lint
/*
** boolean: remind me never to do this again
*/
typedef enum { False, True } boolean;
/*
** diestat: the four states a die can be in
*/
typedef enum { Free, Held, Rolled, Taken } diestat;
/*
** combination: names for all scoring combinations
*/
typedef enum {
Previous = -1, Nothing, Joker, Five, Ace, Three_of_a_kind,
Small_straight, Four_of_a_kind, Asm_straight, Straight, All_of_a_kind
} combination;
/*
** Currently, defining DESC does nothing useful.
*/
/*#define DESC 1 /* scoring description (future use) */
#ifdef DESC
/*
** scoredesc: complete description of a scoring combination
*/
typedef struct {
combination sc_comb; /* the type of combination */
short sc_num; /* how many of this combination */
short sc_face; /* face value for N_of_a_kind */
} scoredesc;
#endif DESC
/*
** diceset: structure for tracking status of all dice
*/
typedef struct {
int d_face[NDICE]; /* number showing on each die */
diestat d_stat[NDICE]; /* status of each die */
combination d_comb[NDICE]; /* die's scoring combination */
#ifdef DESC
scoredesc d_desc[NDICE]; /* list of combinations scored */
#endif DESC
combination d_best; /* best combination scored */
boolean d_again; /* true if rolling again */
int d_rolling; /* number of dice rolling */
int d_pts_roll; /* points due to last roll */
int d_pts_dice; /* points by this set of NDICE */
int d_pts_turn; /* points accumulated this turn */
int d_pts_max; /* max points showing this turn */
char d_mesg[MESGLEN]; /* status message */
} diceset;
/*
** winpref: player game type preference
*/
typedef enum {
Nopref, /* don't care */
Standard, /* game to WINSCORE */
Blitz, /* game to BLITZSCORE */
Fickle, /* for computer use */
Fstand, /* Standard or quit */
Fblitz, /* Blitz or quit */
} winpref;
/*
** blitzmode: when the server will play Blitz games
*/
typedef enum {
Noblitz, /* never to be played */
Onrequest, /* only when requested */
Workhours, /* default during working hours */
Enforced, /* enforced during working hours */
} blitzmode;
/*
** cstat: player/connection status
*/
typedef enum {
Inactive, /* no player */
Watching, /* human voyeur */
Waiting, /* human waiting to get in */
Spider, /* human waiting for another human */
Active, /* active human player */
Computer, /* active computer player */
} cstat;
/*
** strategy: description of a computer player strategy
*/
typedef struct {
int (*s_func)(); /* strategy function */
char *s_name; /* name of strategy */
} strategy;
/*
** temper: description of a computer player temperament
*/
typedef struct {
boolean (*t_func)(); /* temperament function */
char *t_name; /* name of temperament */
} temper;
/*
** computer: complete description of a computer player
*/
typedef struct {
char *c_name; /* computer player name */
strategy *c_strategy; /* pointer into strategy table */
temper *c_temper; /* pointer into temperament table */
winpref c_pref; /* gametype preference */
} computer;
/*
** player: player/connection status
*/
typedef struct {
cstat p_stat; /* connection status */
int p_fd; /* communications socket */
int p_timeouts; /* number of timeouts */
int p_score; /* player score */
int p_squander; /* points rolled away */
int p_mood; /* computer mood value */
winpref p_pref; /* winscore preference */
boolean p_onboard; /* True if player on board */
computer *p_computer; /* pointer into computer table */
char p_name[NAMELEN]; /* player name */
char p_id[IDLEN]; /* "unique" player id */
} player;
/*
** Computer moods have no meaning other than that defined
** by each temperament that uses the p_mood value.
*/
#define NOMOOD 0 /* no mood selected */
#define MAXMOOD 5 /* moods 1 through MAXMOOD */
/*
** graphtype: type of graphics the terminal supports
*/
typedef enum {
Nographics, Digital, Zenith,
} graphtype;
/*
** history: player scoring history
*/
#define H_MVWINMULT 10000L /* to avoid floating point stuff */
typedef struct {
long h_points; /* lifetime total number of points */
long h_avgturn; /* lifetime average points per turn */
long h_wins; /* lifetime number of games won */
long h_games; /* lifetime number of games played */
long h_mvpoints; /* moving sum of game points */
long h_mvavgturn; /* moving sum of avg points per turn */
long h_mvwins; /* mov sum of games won times H_MVWINMULT */
long h_mvgames; /* games used to calculate h_mv values */
long h_lastgame; /* last game played in */
long h_weight; /* weighted value of record */
long h_rank; /* ranking based on weight */
computer *h_computer; /* pointer into computer table */
char h_id[IDLEN]; /* "unique" player id */
} history;
/*
** ptstype: history points type
*/
typedef enum { Lifetime, Recent, Combined } ptstype;
/*
** risk: rolling risks/expectations
*/
typedef struct {
double r_p_any; /* probability of scoring anything (assumes mix) */
double r_p_all; /* probability of scoring all (assumes mix) */
double r_p_aok; /* prob. of completing All_of_a_kind in non-scoring */
int r_e_mix; /* <rolled> with a mix of held dice */
int r_e_aces; /* <rolled> with held dice all aces (no 3o'kind) */
int r_e_fives; /* <rolled> with held dice all fives (no 3o'kind) */
int r_e_jokers; /* <rolled> with held dice all jokers (no 3o'kind) */
} risk;
/*
** enterlate: what to do about a game in progress or about waiting
*/
typedef enum {
Ask, Watch, Play, Wait
} enterlate;
/*
** Definitions for convenient use of select().
*/
#ifndef FD_ZERO
/*
XXX: This system is missing the FD_ macros for select, so it's
XXX: probably a 4.2BSDish system. That means that the fd_set
XXX: type is probably just a single int, so just fake it here.
*/
#define FD_ZERO(p) ((p)->fds_bits[0] = 0)
#define FD_SET(n,p) ((p)->fds_bits[0] |= 1L << (n))
#define FD_ISSET(n,p) (((p)->fds_bits[0] & (1L << (n))) != 0)
#endif FD_ZERO
#define NOSEL ((fd_set *)0)
#define HANG ((struct timeval *)0)