~noskcaj/ubuntu/vivid/four-in-a-row/3.14.2

« back to all changes in this revision

Viewing changes to src/connect4.h

  • Committer: Jackson Doak
  • Date: 2014-11-21 21:52:51 UTC
  • mfrom: (1.1.3)
  • Revision ID: noskcaj@ubuntu.com-20141121215251-jbqgpp0gc8lwmmsw
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/****************************************************************************
2
 
 *                                                                          *
3
 
 *                      Velena Source Code V1.0                             *
4
 
 *                   Written by Giuliano Bertoletti                         *
5
 
 *       Based on the knowledged approach of Louis Victor Allis             *
6
 
 *   Copyright (C) 1996-97 by Giuliano Bertoletti & GBE 32241 Software PR   *
7
 
 *                                                                          *
8
 
 ****************************************************************************
9
 
 
10
 
 Portable engine version.
11
 
 read the README file for further informations.
12
 
 
13
 
 ============================================================================
14
 
 
15
 
 Changes have been made to this code for inclusion with Gnect. It is
16
 
 released under the GNU General Public License with Giuliano's approval.
17
 
 The original and complete Velena Engine source code can be found at:
18
 
 
19
 
 http://www.ce.unipr.it/~gbe/velena.html
20
 
 
21
 
*/
22
 
 
23
 
 
24
 
#ifndef _CONNECT4_H_
25
 
#define _CONNECT4_H_ 1
26
 
 
27
 
 
28
 
#define WHITE_BOOK "white_ob.cn4.gz"
29
 
#define OPENINGBOOK_LENGTH 846986
30
 
#define OPENINGBOOK_CRC 0x82131150
31
 
 
32
 
 
33
 
#ifndef TRUE
34
 
#define TRUE  1
35
 
#endif
36
 
#ifndef FALSE
37
 
#define FALSE 0
38
 
#endif
39
 
 
40
 
#define YES        1
41
 
#define NO         0
42
 
#define ON         1
43
 
#define OFF        0
44
 
 
45
 
#define FULL       -1
46
 
#define EMPTY      0
47
 
#define WHITE      1
48
 
#define BLACK      2
49
 
#define SWITCHSIDE 3
50
 
 
51
 
#define WIN        2
52
 
#define DRAW       1
53
 
#define NOTHING    0
54
 
 
55
 
#define BOARDX     7
56
 
#define BOARDY     6
57
 
 
58
 
#define MAXSQUARES (BOARDX*BOARDY)
59
 
 
60
 
#define GROUPS     69
61
 
#define MAXSOLS    700
62
 
#define MAXGROUPS  50
63
 
#define TILES      4
64
 
 
65
 
#define MAXMEN     42
66
 
 
67
 
#define ELM(x,y) ((x)+((y)<<3))
68
 
 
69
 
#define ELX(n) ((n)&7)
70
 
#define ELY(n) ((n)>>3)
71
 
 
72
 
#define BOTH(x,y) ((x)+((y)<<6))
73
 
 
74
 
#define ALLOC_SOLUTIONS (9*GROUPS)
75
 
 
76
 
#define CHARS   0
77
 
#define VESAGR  1
78
 
 
79
 
#define SQ_a1   ELM(0,0)
80
 
#define SQ_a2   ELM(0,1)
81
 
#define SQ_a3   ELM(0,2)
82
 
#define SQ_a4   ELM(0,3)
83
 
#define SQ_a5   ELM(0,4)
84
 
#define SQ_a6   ELM(0,5)
85
 
 
86
 
#define SQ_b1   ELM(1,0)
87
 
#define SQ_b2   ELM(1,1)
88
 
#define SQ_b3   ELM(1,2)
89
 
#define SQ_b4   ELM(1,3)
90
 
#define SQ_b5   ELM(1,4)
91
 
#define SQ_b6   ELM(1,5)
92
 
 
93
 
#define SQ_c1   ELM(2,0)
94
 
#define SQ_c2   ELM(2,1)
95
 
#define SQ_c3   ELM(2,2)
96
 
#define SQ_c4   ELM(2,3)
97
 
#define SQ_c5   ELM(2,4)
98
 
#define SQ_c6   ELM(2,5)
99
 
 
100
 
#define SQ_d1   ELM(3,0)
101
 
#define SQ_d2   ELM(3,1)
102
 
#define SQ_d3   ELM(3,2)
103
 
#define SQ_d4   ELM(3,3)
104
 
#define SQ_d5   ELM(3,4)
105
 
#define SQ_d6   ELM(3,5)
106
 
 
107
 
#define SQ_e1   ELM(4,0)
108
 
#define SQ_e2   ELM(4,1)
109
 
#define SQ_e3   ELM(4,2)
110
 
#define SQ_e4   ELM(4,3)
111
 
#define SQ_e5   ELM(4,4)
112
 
#define SQ_e6   ELM(4,5)
113
 
 
114
 
#define SQ_f1   ELM(5,0)
115
 
#define SQ_f2   ELM(5,1)
116
 
#define SQ_f3   ELM(5,2)
117
 
#define SQ_f4   ELM(5,3)
118
 
#define SQ_f5   ELM(5,4)
119
 
#define SQ_f6   ELM(5,5)
120
 
 
121
 
#define SQ_g1   ELM(6,0)
122
 
#define SQ_g2   ELM(6,1)
123
 
#define SQ_g3   ELM(6,2)
124
 
#define SQ_g4   ELM(6,3)
125
 
#define SQ_g5   ELM(6,4)
126
 
#define SQ_g6   ELM(6,5)
127
 
 
128
 
 
129
 
 
130
 
struct solvable_groups {
131
 
  short square[64][16];
132
 
  short sqpnt[64];
133
 
};
134
 
 
135
 
 
136
 
struct solution {
137
 
  short valid;
138
 
  short solname;
139
 
  short solpoint[2];
140
 
  short sqinv[2 * TILES];
141
 
  short sqinvnumb;
142
 
  short solgroups[GROUPS];
143
 
  short solgroupsnumb;
144
 
};
145
 
 
146
 
 
147
 
struct intgp {
148
 
  short tgroups[GROUPS];
149
 
  short j, k;
150
 
  short mygroups[GROUPS];
151
 
};
152
 
 
153
 
 
154
 
struct board {
155
 
  short square[(BOARDX + 1) * (BOARDY + 2)];
156
 
  short wipesq[(BOARDX + 1) * (BOARDY + 2)];
157
 
  short usablegroup[GROUPS];
158
 
  short sqused[(BOARDX + 1) * (BOARDY + 2)];
159
 
  short stack[BOARDX + 1];
160
 
  short *groups[GROUPS][TILES];
161
 
  short xplace[GROUPS][TILES];
162
 
  short yplace[GROUPS][TILES];
163
 
  short turn;
164
 
  short moves[MAXMEN], choices[MAXMEN], mlist[MAXMEN];
165
 
  short filled;
166
 
 
167
 
  struct intgp intgp;
168
 
  struct solution *solution[ALLOC_SOLUTIONS];
169
 
  short sp;
170
 
  short problem_solved, solused;
171
 
  short oracle[2], oracle_guesses, lastguess, bestguess;
172
 
  long nodes_visited;
173
 
  short maxtreedepth;
174
 
 
175
 
  unsigned long rule[3];
176
 
 
177
 
  unsigned long instances[10];
178
 
 
179
 
  short wins[2], draws, lastwin;
180
 
  struct solvable_groups *solvable_groups;
181
 
 
182
 
  unsigned char *white_book, *black_book;
183
 
  long wbposit, bbposit;
184
 
  long lastob;
185
 
  short autotest, cpu, white_lev, black_lev;
186
 
  short videotype, usegraphics, enablegr;
187
 
  short debug;
188
 
};
189
 
 
190
 
struct board *veleng_init (void);
191
 
void veleng_free (struct board *board);
192
 
short playgame (char *input_str, struct board *board);
193
 
int get_random_int (int n);
194
 
 
195
 
#endif