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