Remove more CRs.
[ttt.git] / ver3 / ttt.h
1 #ifndef TTT_H_
2 #define TTT_H_
3
4 #define ALPHA_BETA_SEARCH 1
5
6 #define TRUE (1)
7 #define FALSE (0)
8
9 #define IN
10 #define OUT
11
12 typedef unsigned int BOOL;
13
14 //
15 // Constants for each state a board square can be in and a programmer
16 // defined type for these states.
17 //
18 #define X_MARK (-1)
19 #define EMPTY  (0)
20 #define O_MARK (+1)
21 #define TIE    (+2)
22 #define OPPOSITE_MARK(m) ((m) * -1)
23 #define X_OR_O(m) (((m) == X_MARK) || \
24                    ((m) == O_MARK))
25
26 typedef signed char SQUARE;
27 #define IS_SQUARE_EMPTY(x) (x == EMPTY)
28
29 //
30 // A (simple) representation of a tic tac toe position
31 //
32 #define BOARD_SIZE (5)
33
34 typedef struct _POSITION
35 {
36     SQUARE sWhoseTurn;
37     SQUARE sBoard[BOARD_SIZE][BOARD_SIZE];
38     int iVSums[BOARD_SIZE];
39     int iHSums[BOARD_SIZE];
40     int iDSums[2];
41     unsigned int uNumEmpty;
42 } POSITION;
43
44 #define NUM_TO_HPOS(x)   ((x) % BOARD_SIZE)
45 #define NUM_TO_VPOS(x)   ((x) / BOARD_SIZE)
46 #define VALID_SUM(x)     (((x) <= BOARD_SIZE) && \
47                           ((x) >= -BOARD_SIZE))
48
49 //
50 // A representation of a move in a tic tac toe game
51 //
52 typedef unsigned int COORD;
53
54 typedef struct _MOVE
55 {
56     COORD cHpos;
57     COORD cVpos;
58     SQUARE sMark;
59 } MOVE;
60
61 //
62 // Score values
63 //
64 #define INFINITY (+100)
65 #define DRAWSCORE (0)
66
67 //
68 // An assert mechanism
69 //
70 #ifdef DEBUG
71 #define ASSERT(x)       if (x)    \
72                         { ; }     \
73                         else      \
74                         { (void) _assert(__FILE__, __LINE__); }
75 #else
76 #define ASSERT(x)       ;
77 #endif /* DEBUG */
78
79 #endif /* TTT_H_ */