1/*
2    Sjeng - a chess variants playing program
3    Copyright (C) 2000 Gian-Carlo Pascutto
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19    File: sjeng.h
20    Purpose: global definitions
21
22*/
23
24#ifndef SJENG_H
25#define SJENG_H
26
27#include "config.h"
28#include <ctype.h>
29#include <signal.h>
30#include <stdlib.h>
31#include <stdio.h>
32#include <string.h>
33#include <time.h>
34
35#ifdef HAVE_SYS_TIMEB_H
36#include <sys/timeb.h>
37#endif
38
39#define NDEBUG
40#include <assert.h>
41
42#define DIE (*(int *)(NULL) = 0)
43
44/* GCP : my code uses WHITE=0 and BLACK=1 so reverse this */
45
46#define WHITE 0
47#define BLACK 1
48
49#define ToMove (white_to_move ? 0 : 1)
50#define NotToMove (white_to_move ? 1 : 0)
51
52#define Hash(x,y) (hash ^= zobrist[(x)][(y)])
53
54#define Crazyhouse 0
55#define Bughouse 1
56#define Normal 2
57#define Suicide 3
58#define Losers 4
59
60#define Opening      0
61#define Middlegame   1
62#define Endgame      2
63
64#define mindepth 2
65
66/* define names for piece constants: */
67#define frame   0
68#define wpawn   1
69#define bpawn   2
70#define wknight 3
71#define bknight 4
72#define wking   5
73#define bking   6
74#define wrook   7
75#define brook   8
76#define wqueen  9
77#define bqueen  10
78#define wbishop 11
79#define bbishop 12
80#define npiece  13
81
82/* result flags: */
83#define no_result      0
84#define stalemate      1
85#define white_is_mated 2
86#define black_is_mated 3
87#define draw_by_fifty  4
88#define draw_by_rep    5
89
90/* arrays maybe ? */
91#undef FASTCALC
92#ifdef FASTCALC
93#define rank(square) ((((square)-26)/12)+1)
94#define file(square) ((((square)-26)%12)+1)
95#else
96#define rank(square) (rank[(square)])
97#define file(square) (file[(square)])
98#endif
99#define diagl(square) (diagl[(square)])
100#define diagr(square) (diagr[(square)])
101
102#ifndef INPROBECODE
103typedef enum {FALSE, TRUE} bool;
104#endif
105
106/* castle flags: */
107#define no_castle  0
108#define wck        1
109#define wcq        2
110#define bck        3
111#define bcq        4
112
113typedef struct {
114  int from;
115  int target;
116  int captured;
117  int promoted;
118  int castled;
119  int ep;
120} move_s;
121
122typedef struct {
123  int cap_num;
124  int was_promoted;
125  int epsq;
126  int fifty;
127} move_x;
128
129#if defined(HAVE_SYS_TIMEB_H) && (defined(HAVE_FTIME) || defined(HAVE_GETTIMEOFDAY))
130typedef struct timeb rtime_t;
131#else
132typedef time_t rtime_t;
133#endif
134
135#define STR_BUFF 256
136#define MOVE_BUFF 512
137#define INF 1000000
138#define PV_BUFF 300
139
140#define AddMaterial(x) Material += material[(x)]
141#define RemoveMaterial(x) Material -= material[(x)]
142
143#define UPPER 1
144#define LOWER 2
145#define EXACT 3
146#define HMISS 4
147#define DUMMY 0
148
149#define LOSS 0
150#define WIN 1
151#define DRAW 2
152
153#define max(x, y) ((x) > (y) ? (x) : (y))
154#define mix(x, y) ((x) < (y) ? (x) : (y))
155
156#endif
157