2 * backend.h -- Interface exported by XBoard back end
\r
3 * $Id: backend.h,v 2.1 2003/10/27 19:21:00 mann Exp $
\r
5 * Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts.
\r
6 * Enhancements Copyright 1992-95 Free Software Foundation, Inc.
\r
8 * The following terms apply to Digital Equipment Corporation's copyright
\r
9 * interest in XBoard:
\r
10 * ------------------------------------------------------------------------
\r
11 * All Rights Reserved
\r
13 * Permission to use, copy, modify, and distribute this software and its
\r
14 * documentation for any purpose and without fee is hereby granted,
\r
15 * provided that the above copyright notice appear in all copies and that
\r
16 * both that copyright notice and this permission notice appear in
\r
17 * supporting documentation, and that the name of Digital not be
\r
18 * used in advertising or publicity pertaining to distribution of the
\r
19 * software without specific, written prior permission.
\r
21 * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
\r
22 * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
\r
23 * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
\r
24 * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
\r
25 * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
\r
26 * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
\r
28 * ------------------------------------------------------------------------
\r
30 * The following terms apply to the enhanced version of XBoard distributed
\r
31 * by the Free Software Foundation:
\r
32 * ------------------------------------------------------------------------
\r
33 * This program is free software; you can redistribute it and/or modify
\r
34 * it under the terms of the GNU General Public License as published by
\r
35 * the Free Software Foundation; either version 2 of the License, or
\r
36 * (at your option) any later version.
\r
38 * This program is distributed in the hope that it will be useful,
\r
39 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
40 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
41 * GNU General Public License for more details.
\r
43 * You should have received a copy of the GNU General Public License
\r
44 * along with this program; if not, write to the Free Software
\r
45 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
\r
46 * ------------------------------------------------------------------------
\r
51 /* unsigned int 64 for engine nodes work and display */
\r
53 /* I don't know the name for this type of other compiler
\r
54 * If it not work, just modify here
\r
55 * This is for MS Visual Studio
\r
58 #define u64 unsigned __int64
\r
59 #define s64 signed __int64
\r
60 #define u64Display "%I64u"
\r
61 #define s64Display "%I64d"
\r
62 #define u64Const(c) (c ## UI64)
\r
63 #define s64Const(c) (c ## I64)
\r
66 * or dummy types for other compiler
\r
68 #define u64 unsigned long long
\r
69 #define s64 signed long long
\r
70 #define u64Display "%llu"
\r
71 #define s64Display "%lld"
\r
72 #define u64Const(c) (c ## ULL)
\r
73 #define s64Const(c) (c ## LL)
\r
77 #define u64 unsigned long long
\r
78 #define s64 signed long long
\r
79 #define u64Display "%llu"
\r
80 #define s64Display "%lld"
\r
81 #define u64Const(c) (c ## ull)
\r
82 #define s64Const(c) (c ## ll)
\r
86 #include "frontend.h"
\r
88 extern int gotPremove;
\r
89 extern GameMode gameMode;
\r
90 extern int pausing, cmailMsgLoaded, flipView;
\r
91 extern char white_holding[], black_holding[];
\r
92 extern int currentMove, backwardMostMove, forwardMostMove;
\r
93 extern int blackPlaysFirst;
\r
94 extern FILE *debugFP;
\r
95 extern char* programVersion;
\r
96 extern ProcRef firstProgramPR, secondProgramPR;
\r
97 extern Board boards[];
\r
99 char *CmailMsg P((void));
\r
100 /* Tord: Added the useFEN960 parameter in PositionToFEN() below */
\r
101 char *PositionToFEN P((int move, int useFEN960));
\r
102 void AlphaRank P((char *s, int n)); /* [HGM] Shogi move preprocessor */
\r
103 void EditPositionPasteFEN P((char *fen));
\r
104 void TimeDelay P((long ms));
\r
105 void SendMultiLineToICS P(( char *text ));
\r
106 void AnalysisPeriodicEvent P((int force));
\r
107 void SetWhiteToPlayEvent P((void));
\r
108 void SetBlackToPlayEvent P((void));
\r
109 void InitBackEnd1 P((void));
\r
110 void InitBackEnd2 P((void));
\r
111 int IsPromotion P((int fromX, int fromY, int toX, int toY));
\r
112 int InPalace P((int row, int column));
\r
113 int PieceForSquare P((int x, int y));
\r
114 int OKToStartUserMove P((int x, int y));
\r
115 void Reset P((int redraw, int init));
\r
116 void ResetGameEvent P((void));
\r
117 int LoadGame P((FILE *f, int n, char *title, int useList));
\r
118 int LoadGameFromFile P((char *filename, int n, char *title, int useList));
\r
119 int CmailLoadGame P((FILE *f, int n, char *title, int useList));
\r
120 int ReloadGame P((int offset));
\r
121 int SaveGame P((FILE *f, int dummy, char *dummy2));
\r
122 int SaveGameToFile P((char *filename, int append));
\r
123 int LoadPosition P((FILE *f, int n, char *title));
\r
124 int ReloadPosition P((int offset));
\r
125 int SavePosition P((FILE *f, int dummy, char *dummy2));
\r
126 void EditPositionEvent P((void));
\r
127 void FlipViewEvent P((void));
\r
128 void MachineWhiteEvent P((void));
\r
129 void MachineBlackEvent P((void));
\r
130 void TwoMachinesEvent P((void));
\r
131 void EditGameEvent P((void));
\r
132 void TrainingEvent P((void));
\r
133 void IcsClientEvent P((void));
\r
134 void ForwardEvent P((void));
\r
135 void BackwardEvent P((void));
\r
136 void ToEndEvent P((void));
\r
137 void ToStartEvent P((void));
\r
138 void ToNrEvent P((int to));
\r
139 void RevertEvent P((void));
\r
140 void RetractMoveEvent P((void));
\r
141 void MoveNowEvent P((void));
\r
142 void TruncateGameEvent P((void));
\r
143 void PauseEvent P((void));
\r
144 void CallFlagEvent P((void));
\r
145 void AcceptEvent P((void));
\r
146 void DeclineEvent P((void));
\r
147 void RematchEvent P((void));
\r
148 void DrawEvent P((void));
\r
149 void AbortEvent P((void));
\r
150 void AdjournEvent P((void));
\r
151 void ResignEvent P((void));
\r
152 void UserAdjudicationEvent P((int result));
\r
153 void StopObservingEvent P((void));
\r
154 void StopExaminingEvent P((void));
\r
155 void PonderNextMoveEvent P((int newState));
\r
156 void NewSettingeEvent P((int option, char *command, int value));
\r
157 void ShowThinkingEvent P(());
\r
158 void PeriodicUpdatesEvent P((int newState));
\r
159 void HintEvent P((void));
\r
160 void BookEvent P((void));
\r
161 void AboutGameEvent P((void));
\r
162 void ExitEvent P((int status));
\r
163 char *DefaultFileName P((char *));
\r
164 ChessMove UserMoveTest P((int fromX, int fromY, int toX, int toY, int promoChar));
\r
165 void UserMoveEvent P((int fromX, int fromY, int toX, int toY, int promoChar));
\r
166 void DecrementClocks P((void));
\r
167 char *TimeString P((long millisec));
\r
168 void AutoPlayGameLoop P((void));
\r
169 void AdjustClock P((Boolean which, int dir));
\r
170 void DisplayBothClocks P((void));
\r
171 void EditPositionMenuEvent P((ChessSquare selection, int x, int y));
\r
172 void DropMenuEvent P((ChessSquare selection, int x, int y));
\r
173 int ParseTimeControl P((char *tc, int ti, int mps));
\r
174 void ProcessICSInitScript P((FILE * f));
\r
175 void EditCommentEvent P((void));
\r
176 void ReplaceComment P((int index, char *text));
\r
177 int ReplaceTags P((char *tags, GameInfo *gi));/* returns nonzero on error */
\r
178 void AppendComment P((int index, char *text));
\r
179 void ReloadCmailMsgEvent P((int unregister));
\r
180 void MailMoveEvent P((void));
\r
181 void EditTagsEvent P((void));
\r
182 void GetMoveListEvent P((void));
\r
183 void ExitAnalyzeMode P((void));
\r
184 void AnalyzeModeEvent P((void));
\r
185 void AnalyzeFileEvent P((void));
\r
186 void DoEcho P((void));
\r
187 void DontEcho P((void));
\r
188 void TidyProgramName P((char *prog, char *host, char *buf));
\r
189 void AskQuestionEvent P((char *title, char *question,
\r
190 char *replyPrefix, char *which));
\r
191 Boolean ParseOneMove P((char *move, int moveNum,
\r
192 ChessMove *moveType, int *fromX, int *fromY,
\r
193 int *toX, int *toY, char *promoChar));
\r
194 char *VariantName P((VariantClass v));
\r
195 VariantClass StringToVariant P((char *e));
\r
196 double u64ToDouble P((u64 value));
\r
198 char *StrStr P((char *string, char *match));
\r
199 char *StrCaseStr P((char *string, char *match));
\r
200 char *StrSave P((char *s));
\r
201 char *StrSavePtr P((char *s, char **savePtr));
\r
204 int StrCaseCmp P((char *s1, char *s2));
\r
205 int ToLower P((int c));
\r
206 int ToUpper P((int c));
\r
208 #define StrCaseCmp Stricmp /* Use utility.library functions */
\r
209 #include <proto/utility.h>
\r
212 extern GameInfo gameInfo;
\r
214 /* ICS vars used with backend.c and zippy.c */
\r
215 #define ICS_GENERIC 0
\r
218 #define ICS_CHESSNET 3 /* not really supported */
\r
223 /* pgntags.c prototypes
\r
225 char *PGNTags P((GameInfo *));
\r
226 void PrintPGNTags P((FILE *f, GameInfo *));
\r
227 int ParsePGNTag P((char *, GameInfo *));
\r
228 char *PGNResult P((ChessMove result));
\r
231 /* gamelist.c prototypes
\r
233 /* A game node in the double linked list of games.
\r
235 typedef struct _ListGame {
\r
238 unsigned long offset; /* Byte offset of game within file. */
\r
239 GameInfo gameInfo; /* Note that some entries may be NULL. */
\r
242 extern List gameList;
\r
243 void ClearGameInfo P((GameInfo *));
\r
244 int GameListBuild P((FILE *));
\r
245 void GameListInitGameInfo P((GameInfo *));
\r
246 char *GameListLine P((int, GameInfo *));
\r
247 char * GameListLineFull P(( int, GameInfo *));
\r
249 extern char* StripHighlight P((char *)); /* returns static data */
\r
250 extern char* StripHighlightAndTitle P((char *)); /* returns static data */
\r
252 typedef enum { CheckBox, ComboBox, TextBox, Button, Spin, SaveButton } Control;
\r
254 typedef struct _OPT { // [HGM] options: descriptor of UCI-style option
\r
255 int value; // current setting, starts as default
\r
258 void *handle; // for use by front end
\r
259 char *textValue; // points to beginning of text value in name field
\r
260 char **choice; // points to array of combo choices in cps->combo
\r
262 char name[MSG_SIZ]; // holds both option name and text value
\r
265 typedef struct _CPS {
\r
269 InputSourceRef isr;
\r
270 char *twoMachinesColor; /* "white\n" or "black\n" */
\r
274 struct _CPS *other;
\r
276 char *computerString;
\r
277 int sendTime; /* 0=don't, 1=do, 2=test */
\r
278 int sendDrawOffers;
\r
281 int offeredDraw; /* countdown */
\r
283 int useSetboard; /* 0=use "edit"; 1=use "setboard" */
\r
284 int useSAN; /* 0=use coordinate notation; 1=use SAN */
\r
285 int usePing; /* 0=not OK to use ping; 1=OK */
\r
288 int usePlayother;/* 0=not OK to use playother; 1=OK */
\r
289 int useColors; /* 0=avoid obsolete white/black commands; 1=use them */
\r
290 int useUsermove; /* 0=just send move; 1=send "usermove move" */
\r
291 int sendICS; /* 0=don't use "ics" command; 1=do */
\r
292 int sendName; /* 0=don't use "name" command; 1=do */
\r
293 int sdKludge; /* 0=use "sd DEPTH" command; 1=use "depth\nDEPTH" */
\r
294 int stKludge; /* 0=use "st TIME" command; 1=use "level 1 TIME" */
\r
295 char tidy[MSG_SIZ];
\r
297 char variants[MSG_SIZ];
\r
298 int analysisSupport;
\r
300 int protocolVersion;
\r
303 /* Added by Tord: */
\r
304 int useFEN960; /* 0=use "KQkq" style FENs, 1=use "HAha" style FENs */
\r
305 int useOOCastle; /* 0="O-O" notation for castling, 1="king capture rook" notation */
\r
306 /* End of additions by Tord */
\r
308 int scoreIsAbsolute; /* [AS] 0=don't know (standard), 1=score is always from white side */
\r
309 int isUCI; /* [AS] 0=no (Winboard), 1=UCI (requires Polyglot) */
\r
310 int hasOwnBookUCI; /* [AS] 0=use GUI or Polyglot book, 1=has own book */
\r
312 /* [HGM] time odds */
\r
313 int timeOdds; /* factor through which we divide time for this engine */
\r
314 int debug; /* [HGM] ignore engine debug lines starting with '#' */
\r
315 int maxNrOfSessions; /* [HGM] secondary TC: max args in 'level' command */
\r
316 int accumulateTC; /* [HGM] secondary TC: how to handle extra sessions */
\r
317 int nps; /* [HGM] nps: factor for node count to replace time */
\r
319 int alphaRank; /* [HGM] shogi: engine uses shogi-type coordinates */
\r
320 int maxCores; /* [HGM] SMP: engine understands cores command */
\r
321 int memSize; /* [HGM] memsize: engine understands memory command */
\r
322 char egtFormats[MSG_SIZ]; /* [HGM] EGT: supported tablebase formats */
\r
323 int bookSuspend; /* [HGM] book: go was deferred because of book hit */
\r
324 int nrOptions; /* [HGM] options: remembered option="..." features */
\r
325 #define MAX_OPTIONS 50
\r
326 Option option[MAX_OPTIONS];
\r
328 char *comboList[10*MAX_OPTIONS];
\r
329 char *optionSettings;
\r
330 void *programLogo; /* [HGM] logo: bitmap of the logo */
\r
331 } ChessProgramState;
\r
333 extern ChessProgramState first, second;
\r
335 /* [AS] Search stats from chessprogram, for the played move */
\r
337 int score; /* Centipawns */
\r
338 int depth; /* Plies */
\r
339 int time; /* Milliseconds */
\r
340 } ChessProgramStats_Move;
\r
342 /* Search stats from chessprogram */
\r
344 char movelist[2*MSG_SIZ]; /* Last PV we were sent */
\r
345 int depth; /* Current search depth */
\r
346 int nr_moves; /* Total nr of root moves */
\r
347 int moves_left; /* Moves remaining to be searched */
\r
348 char move_name[MOVE_LEN]; /* Current move being searched, if provided */
\r
349 u64 nodes; /* # of nodes searched */
\r
350 int time; /* Search time (centiseconds) */
\r
351 int score; /* Score (centipawns) */
\r
352 int got_only_move; /* If last msg was "(only move)" */
\r
353 int got_fail; /* 0 - nothing, 1 - got "--", 2 - got "++" */
\r
354 int ok_to_send; /* handshaking between send & recv */
\r
355 int line_is_book; /* 1 if movelist is book moves */
\r
356 int seen_stat; /* 1 if we've seen the stat01: line */
\r
357 } ChessProgramStats;
\r
359 extern ChessProgramStats_Move pvInfoList[MAX_MOVES];
\r
360 extern shuffleOpenings;
\r
361 extern ChessProgramStats programStats;
\r
363 #endif /* _BACKEND */
\r