1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
/****************************************************************************/
/** **/
/** Connect-4 Algorithm **/
/** **/
/** By Keith Pomakis **/
/** (kppomaki@jeeves.uwaterloo.ca) **/
/** **/
/** Fall, 1993 **/
/** **/
/****************************************************************************/
/** **/
/** See the file "c4.c" for documentation. **/
/** **/
/****************************************************************************/
#ifndef C4_DEFINED
#define C4_DEFINED
#define EMPTY 2
#ifndef Boolean
#define Boolean unsigned char
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
typedef struct {
char **board; /* The board configuration of the game state. */
/* board[x][y] specifies the position of the */
/* xth column and the yth row of the board, */
/* where column and row numbering starts at 0. */
/* (The 0th row is the bottom row.) */
/* A value of 0 specifies that the position is */
/* occupied by a piece owned by player 0, a */
/* value of 1 specifies that the position is */
/* occupied by a piece owned by player 1, and */
/* a value of EMPTY specifies that the */
/* position is unoccupied. */
long *(score_array[2]); /* An array specifying statistics on both */
/* players. score_array[0] specifies the */
/* statistics for player 0, while */
/* score_array[1] specifies the statistics for */
/* player 1. These statistics have little */
/* meaning outside the realm of the local */
/* functions of the "c4.c" file. */
long num_of_pieces; /* The number of pieces currently occupying */
/* board spaces. */
} Game_state;
/* See the file "c4.c" for documentation on the following functions. */
extern void poll(void (*poll_func)(void), long level);
extern void new_game(long width, long height, long num);
extern Boolean make_move(long player, long column);
extern long automatic_move(long player, long level);
extern Game_state get_game_state(void);
extern long score_of_player(long player);
extern Boolean is_winner(long player);
extern Boolean is_tie(void);
extern void win_coords(long player, long *x1, long *y1, long *x2, long *y2);
extern void end_game(void);
#endif /* C4_DEFINED */
|