Remove more CRs.
[ttt.git] / ver4 / 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 typedef struct _POSITION
33 {
34     SQUARE sWhoseTurn;
35     int **sBoard;
36     //SQUARE sBoard[BOARD_SIZE][BOARD_SIZE];
37     int *iVSums;
38     //int iVSums[BOARD_SIZE];
39     int *iHSums;
40     //int iHSums[BOARD_SIZE];
41     int iDSums[2];
42     unsigned int uNumEmpty;
43 } POSITION;
44
45 #define NUM_TO_HPOS(x)   ((x) % g_uBoardSize)
46 #define NUM_TO_VPOS(x)   ((x) / g_uBoardSize)
47 #define VALID_SUM(x)     (abs(x) <= g_uBoardSize)
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  
80 void
81 _assert(char *sz, unsigned int i)
82 {
83     fprintf(stderr, "Assertion failed in %s at line %u.\n", sz, i);
84 #if defined(WIN32)
85         __asm int 3;
86 #elif defined(__unix__)
87     asm("int3\n");
88 #else
89     #error foo
90 #endif
91 }
92
93 #endif /* TTT_H_ */