This is the mail archive of the
gcc-prs@gcc.gnu.org
mailing list for the GCC project.
c/6109: Internal compiler error in schedule_insns, at sched-rgn.c:3070
- From: saurabh dot kb at btinternet dot com
- To: gcc-gnats at gcc dot gnu dot org
- Date: 30 Mar 2002 17:15:37 -0000
- Subject: c/6109: Internal compiler error in schedule_insns, at sched-rgn.c:3070
- Reply-to: saurabh dot kb at btinternet dot com
>Number: 6109
>Category: c
>Synopsis: Internal compiler error in schedule_insns, at sched-rgn.c:3070
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Sat Mar 30 09:16:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator: saurabh.kb@btinternet.com
>Release: gcc version 3.0.4 Configured with: ./configure --verbose --enable-threads=win32 --with-system-zlib --disable-nls --disable-shared --enable-static --with-gnu-as --with-gnu-ld --program-suffix=3 --enable-languages=c,c++ --disable-libgcj --
>Organization:
>Environment:
CYGWIN_NT-5.1 SKNET-01 1.3.10(0.51/3/2) 2002-02-25 11:14 i686 unknown
>Description:
When trying to compile crafty (chess engine), version 18.9, gcc (3.0.4) ICEed in file utility.c (preprocessed source included).
>How-To-Repeat:
The command used to compile was:
$ gcc3 -pipe -D_REENTRANT -mcpu=athlon -O3 -Wall -fomit-frame-pointer -funroll-loops -ffast-math -malign-double -fexpensive-optimizations -finline-funct
ions -finline -foptimize-register-move -fregmove -fschedule-insns -fschedule-insns2 -DCOMPACT_ATTACKS -DUSE_ATTACK_FUNCTIONS -DUSE_ASSEMBLY_A
-DUSE_ASSEMBLY_B -DFAST -DLINUX -c utility.c
GCC said:
gcc3: Warning: -pipe ignored because -save-temps specified
Reading specs from /usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/specs
Configured with: ./configure --verbose --enable-threads=win32 --with-system-zlib --disable-nls --disable-shared --enable-static --with-gnu-as --with-gnu-ld --program-suffix=3 --enable-languages=c,c++ --disable-libgcj --disable-checking --enable-sjlj-exceptions --host=i686-pc-cygwin --enable-haifa --with-ld=/usr/local/bin/ld.exe --with-as=/usr/local/bin/as.exe
Thread model: win32
gcc version 3.0.4
/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/cpp0.exe -lang-c -v -D__GNUC__=3 -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=4 -D_X86_=1 -D_X86_=1 -Asystem=winnt -D__OPTIMIZE__ -D__FAST_MATH__ -D__STDC_HOSTED__=1 -Wall -Acpu=i386 -Amachine=i386 -Di386 -D__i386 -D__i386__ -D__tune_athlon__ -D__stdcall=__attribute__((__stdcall__)) -D__cdecl=__attribute__((__cdecl__)) -D_stdcall=__attribute__((__stdcall__)) -D_cdecl=__attribute__((__cdecl__)) -D__declspec(x)=__attribute__((x)) -D__i386__ -D__i386 -D__CYGWIN32__ -D__CYGWIN__ -Dunix -D__unix__ -D__unix -isystem /usr/local/include -idirafter /usr/local/i686-pc-cygwin/include -idirafter /usr/include -idirafter /usr/local/i686-pc-cygwin/include/w32api -idirafter /usr/include/w32api -D_REENTRANT -DCOMPACT_ATTACKS -DUSE_ATTACK_FUNCTIONS -DUSE_ASSEMBLY_A -DUSE_ASSEMBLY_B -DFAST -DLINUX utility.c utility.i
ignoring nonexistent directory "/usr/local/i686-pc-cygwin/include"
ignoring nonexistent directory "/usr/local/i686-pc-cygwin/include/w32api"
GNU CPP version 3.0.4 (cpplib) (80386, BSD syntax)
ignoring nonexistent directory "NONE/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/local/include
/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include
/usr/include
/usr/include/w32api
End of search list.
/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/cc1.exe -fpreprocessed utility.i -quiet -dumpbase utility.c -mcpu=athlon -malign-double -O3 -Wall -version -fomit-frame-pointer -funroll-loops -ffast-math -fexpensive-optimizations -finline-functions -finline -foptimize-register-move -fregmove -fschedule-insns -fschedule-insns2 -o utility.s
GNU CPP version 3.0.4 (cpplib) (80386, BSD syntax)
GNU C version 3.0.4 (i686-pc-cygwin)
compiled by GNU C version 2.95.3-5 (cygwin special).
utility.c: In function `DisplayTreeState':
utility.c:521: Internal compiler error in schedule_insns, at sched-rgn.c:3070
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://www.gnu.org/software/gcc/bugs.html> for instructions.
>Fix:
Compile with different options.
>Release-Note:
>Audit-Trail:
>Unformatted:
disable-checking --enable-sjlj-exceptions --host=i686-pc-cygwin --enable-haifa --with-ld=/usr/local/bin/ld.exe --with-as=/usr/local/bin/as.exe Thread model: win32
----gnatsweb-attachment----
Content-Type: text/plain; name="utility.i"
Content-Disposition: inline; filename="utility.i"
# 1 "utility.c"
# 1 "/usr/include/stdio.h" 1 3
# 32 "/usr/include/stdio.h" 3
# 1 "/usr/include/_ansi.h" 1 3
# 15 "/usr/include/_ansi.h" 3
# 1 "/usr/include/sys/config.h" 1 3
# 129 "/usr/include/sys/config.h" 3
typedef short int __int16_t;
typedef unsigned short int __uint16_t;
typedef int __int32_t;
typedef unsigned int __uint32_t;
typedef long long __int64_t;
typedef unsigned long long __uint64_t;
# 16 "/usr/include/_ansi.h" 2 3
# 33 "/usr/include/stdio.h" 2 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 1 3
# 199 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 3
typedef unsigned int size_t;
# 38 "/usr/include/stdio.h" 2 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stdarg.h" 1 3
# 43 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stdarg.h" 3
typedef __builtin_va_list __gnuc_va_list;
# 41 "/usr/include/stdio.h" 2 3
# 1 "/usr/include/sys/reent.h" 1 3
# 13 "/usr/include/sys/reent.h" 3
# 1 "/usr/include/_ansi.h" 1 3
# 14 "/usr/include/sys/reent.h" 2 3
# 1 "/usr/include/sys/_types.h" 1 3
# 12 "/usr/include/sys/_types.h" 3
typedef long _off_t;
typedef long _ssize_t;
# 15 "/usr/include/sys/reent.h" 2 3
# 28 "/usr/include/sys/reent.h" 3
typedef __uint32_t __ULong;
struct _glue
{
struct _glue *_next;
int _niobs;
struct __sFILE *_iobs;
};
struct _Bigint
{
struct _Bigint *_next;
int _k, _maxwds, _sign, _wds;
__ULong _x[1];
};
struct __tm
{
int __tm_sec;
int __tm_min;
int __tm_hour;
int __tm_mday;
int __tm_mon;
int __tm_year;
int __tm_wday;
int __tm_yday;
int __tm_isdst;
};
# 71 "/usr/include/sys/reent.h" 3
struct _atexit {
struct _atexit *_next;
int _ind;
void (*_fns[32])(void);
};
# 90 "/usr/include/sys/reent.h" 3
struct __sbuf {
unsigned char *_base;
int _size;
};
typedef long _fpos_t;
# 151 "/usr/include/sys/reent.h" 3
struct __sFILE {
unsigned char *_p;
int _r;
int _w;
short _flags;
short _file;
struct __sbuf _bf;
int _lbfsize;
void * _cookie;
_ssize_t __attribute__((__cdecl__)) (*_read) (void * _cookie, char *_buf, int _n);
_ssize_t __attribute__((__cdecl__)) (*_write) (void * _cookie, const char *_buf, int _n);
_fpos_t __attribute__((__cdecl__)) (*_seek) (void * _cookie, _fpos_t _offset, int _whence);
int __attribute__((__cdecl__)) (*_close) (void * _cookie);
struct __sbuf _ub;
unsigned char *_up;
int _ur;
unsigned char _ubuf[3];
unsigned char _nbuf[1];
struct __sbuf _lb;
int _blksize;
int _offset;
struct _reent *_data;
};
# 215 "/usr/include/sys/reent.h" 3
struct _rand48 {
unsigned short _seed[3];
unsigned short _mult[3];
unsigned short _add;
};
# 365 "/usr/include/sys/reent.h" 3
struct _reent
{
int _errno;
struct __sFILE *_stdin, *_stdout, *_stderr;
int _inc;
char _emergency[25];
int _current_category;
const char *_current_locale;
int __sdidinit;
void __attribute__((__cdecl__)) (*__cleanup) (struct _reent *);
struct _Bigint *_result;
int _result_k;
struct _Bigint *_p5s;
struct _Bigint **_freelist;
int _cvtlen;
char *_cvtbuf;
union
{
struct
{
unsigned int _unused_rand;
char * _unused_strtok_last;
char _asctime_buf[26];
struct __tm _localtime_buf;
int _gamma_signgam;
__extension__ unsigned long long _rand_next;
struct _rand48 _r48;
} _reent;
struct
{
unsigned char * _nextf[30];
unsigned int _nmalloc[30];
} _unused;
} _new;
struct _atexit *_atexit;
struct _atexit _atexit0;
void (**(_sig_func))(int);
struct _glue __sglue;
struct __sFILE __sf[3];
};
# 470 "/usr/include/sys/reent.h" 3
extern struct _reent *_impure_ptr ;
void _reclaim_reent (struct _reent *);
# 49 "/usr/include/stdio.h" 2 3
typedef _fpos_t fpos_t;
typedef struct __sFILE FILE;
# 150 "/usr/include/stdio.h" 3
FILE * __attribute__((__cdecl__)) tmpfile (void);
char * __attribute__((__cdecl__)) tmpnam (char *);
int __attribute__((__cdecl__)) fclose (FILE *);
int __attribute__((__cdecl__)) fflush (FILE *);
FILE * __attribute__((__cdecl__)) freopen (const char *, const char *, FILE *);
void __attribute__((__cdecl__)) setbuf (FILE *, char *);
int __attribute__((__cdecl__)) setvbuf (FILE *, char *, int, size_t);
int __attribute__((__cdecl__)) fprintf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) fscanf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) printf (const char *, ...);
int __attribute__((__cdecl__)) scanf (const char *, ...);
int __attribute__((__cdecl__)) sscanf (const char *, const char *, ...);
int __attribute__((__cdecl__)) vfprintf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vprintf (const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsprintf (char *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) fgetc (FILE *);
char * __attribute__((__cdecl__)) fgets (char *, int, FILE *);
int __attribute__((__cdecl__)) fputc (int, FILE *);
int __attribute__((__cdecl__)) fputs (const char *, FILE *);
int __attribute__((__cdecl__)) getc (FILE *);
int __attribute__((__cdecl__)) getchar (void);
char * __attribute__((__cdecl__)) gets (char *);
int __attribute__((__cdecl__)) putc (int, FILE *);
int __attribute__((__cdecl__)) putchar (int);
int __attribute__((__cdecl__)) puts (const char *);
int __attribute__((__cdecl__)) ungetc (int, FILE *);
size_t __attribute__((__cdecl__)) fread (void *, size_t _size, size_t _n, FILE *);
size_t __attribute__((__cdecl__)) fwrite (const void * , size_t _size, size_t _n, FILE *);
int __attribute__((__cdecl__)) fgetpos (FILE *, fpos_t *);
int __attribute__((__cdecl__)) fseek (FILE *, long, int);
int __attribute__((__cdecl__)) fsetpos (FILE *, const fpos_t *);
long __attribute__((__cdecl__)) ftell ( FILE *);
void __attribute__((__cdecl__)) rewind (FILE *);
void __attribute__((__cdecl__)) clearerr (FILE *);
int __attribute__((__cdecl__)) feof (FILE *);
int __attribute__((__cdecl__)) ferror (FILE *);
void __attribute__((__cdecl__)) perror (const char *);
FILE * __attribute__((__cdecl__)) fopen (const char *_name, const char *_type);
int __attribute__((__cdecl__)) sprintf (char *, const char *, ...);
int __attribute__((__cdecl__)) remove (const char *);
int __attribute__((__cdecl__)) rename (const char *, const char *);
int __attribute__((__cdecl__)) vfiprintf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) iprintf (const char *, ...);
int __attribute__((__cdecl__)) fiprintf (FILE *, const char *, ...);
int __attribute__((__cdecl__)) siprintf (char *, const char *, ...);
char * __attribute__((__cdecl__)) tempnam (const char *, const char *);
int __attribute__((__cdecl__)) vsnprintf (char *, size_t, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vfscanf (FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vscanf (const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) vsscanf (const char *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) snprintf (char *, size_t, const char *, ...);
# 214 "/usr/include/stdio.h" 3
FILE * __attribute__((__cdecl__)) fdopen (int, const char *);
int __attribute__((__cdecl__)) fileno (FILE *);
int __attribute__((__cdecl__)) getw (FILE *);
int __attribute__((__cdecl__)) pclose (FILE *);
FILE * __attribute__((__cdecl__)) popen (const char *, const char *);
int __attribute__((__cdecl__)) putw (int, FILE *);
void __attribute__((__cdecl__)) setbuffer (FILE *, char *, int);
int __attribute__((__cdecl__)) setlinebuf (FILE *);
FILE * __attribute__((__cdecl__)) _fdopen_r (struct _reent *, int, const char *);
FILE * __attribute__((__cdecl__)) _fopen_r (struct _reent *, const char *, const char *);
int __attribute__((__cdecl__)) _fscanf_r (struct _reent *, FILE *, const char *, ...);
int __attribute__((__cdecl__)) _getchar_r (struct _reent *);
char * __attribute__((__cdecl__)) _gets_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _iprintf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _mkstemp_r (struct _reent *, char *);
char * __attribute__((__cdecl__)) _mktemp_r (struct _reent *, char *);
void __attribute__((__cdecl__)) _perror_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _printf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _putchar_r (struct _reent *, int);
int __attribute__((__cdecl__)) _puts_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _remove_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) _rename_r (struct _reent *, const char *_old, const char *_new);
int __attribute__((__cdecl__)) _scanf_r (struct _reent *, const char *, ...);
int __attribute__((__cdecl__)) _sprintf_r (struct _reent *, char *, const char *, ...);
int __attribute__((__cdecl__)) _snprintf_r (struct _reent *, char *, size_t, const char *, ...);
int __attribute__((__cdecl__)) _sscanf_r (struct _reent *, const char *, const char *, ...);
char * __attribute__((__cdecl__)) _tempnam_r (struct _reent *, const char *, const char *);
FILE * __attribute__((__cdecl__)) _tmpfile_r (struct _reent *);
char * __attribute__((__cdecl__)) _tmpnam_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _vfprintf_r (struct _reent *, FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vprintf_r (struct _reent *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsprintf_r (struct _reent *, char *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsnprintf_r (struct _reent *, char *, size_t, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vfscanf_r (struct _reent *, FILE *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vscanf_r (struct _reent *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) _vsscanf_r (struct _reent *, const char *, const char *, __gnuc_va_list);
int __attribute__((__cdecl__)) __srget (FILE *);
int __attribute__((__cdecl__)) __swbuf (int, FILE *);
FILE *__attribute__((__cdecl__)) funopen (const void * _cookie, int (*readfn)(void * _cookie, char *_buf, int _n), int (*writefn)(void * _cookie, const char *_buf, int _n), fpos_t (*seekfn)(void * _cookie, fpos_t _off, int _whence), int (*closefn)(void * _cookie));
# 288 "/usr/include/stdio.h" 3
static __inline__ int __sgetc(FILE *__p)
{
int __c = (--(__p)->_r < 0 ? __srget(__p) : (int)(*(__p)->_p++));
if ((__p->_flags & 0x4000) && (__c == '\r'))
{
int __c2 = (--(__p)->_r < 0 ? __srget(__p) : (int)(*(__p)->_p++));
if (__c2 == '\n')
__c = __c2;
else
ungetc(__c2, __p);
}
return __c;
}
# 2 "utility.c" 2
# 1 "/usr/include/stdlib.h" 1 3
# 13 "/usr/include/stdlib.h" 3
# 1 "/usr/include/_ansi.h" 1 3
# 14 "/usr/include/stdlib.h" 2 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 1 3
# 287 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 3
typedef short unsigned int wchar_t;
# 18 "/usr/include/stdlib.h" 2 3
# 1 "/usr/include/sys/reent.h" 1 3
# 20 "/usr/include/stdlib.h" 2 3
# 1 "/usr/include/alloca.h" 1 3
# 10 "/usr/include/alloca.h" 3
# 1 "/usr/include/_ansi.h" 1 3
# 11 "/usr/include/alloca.h" 2 3
# 1 "/usr/include/sys/reent.h" 1 3
# 12 "/usr/include/alloca.h" 2 3
# 23 "/usr/include/stdlib.h" 2 3
typedef struct
{
int quot;
int rem;
} div_t;
typedef struct
{
long quot;
long rem;
} ldiv_t;
# 46 "/usr/include/stdlib.h" 3
extern __attribute__((dllimport)) int __mb_cur_max;
void __attribute__((__cdecl__)) abort (void) __attribute__ ((noreturn));
int __attribute__((__cdecl__)) abs (int);
int __attribute__((__cdecl__)) atexit (void (*__func)(void));
double __attribute__((__cdecl__)) atof (const char *__nptr);
float __attribute__((__cdecl__)) atoff (const char *__nptr);
int __attribute__((__cdecl__)) atoi (const char *__nptr);
long __attribute__((__cdecl__)) atol (const char *__nptr);
void * __attribute__((__cdecl__)) bsearch (const void * __key, const void * __base, size_t __nmemb, size_t __size, int (* __attribute__((__cdecl__)) _compar) (const void *, const void *));
void * __attribute__((__cdecl__)) calloc (size_t __nmemb, size_t __size);
div_t __attribute__((__cdecl__)) div (int __numer, int __denom);
void __attribute__((__cdecl__)) exit (int __status) __attribute__ ((noreturn));
void __attribute__((__cdecl__)) free (void *);
char * __attribute__((__cdecl__)) getenv (const char *__string);
char * __attribute__((__cdecl__)) _getenv_r (struct _reent *, const char *__string);
char * __attribute__((__cdecl__)) _findenv (const char *, int *);
char * __attribute__((__cdecl__)) _findenv_r (struct _reent *, const char *, int *);
long __attribute__((__cdecl__)) labs (long);
ldiv_t __attribute__((__cdecl__)) ldiv (long __numer, long __denom);
void * __attribute__((__cdecl__)) malloc (size_t __size);
int __attribute__((__cdecl__)) mblen (const char *, size_t);
int __attribute__((__cdecl__)) _mblen_r (struct _reent *, const char *, size_t, int *);
int __attribute__((__cdecl__)) mbtowc (wchar_t *, const char *, size_t);
int __attribute__((__cdecl__)) _mbtowc_r (struct _reent *, wchar_t *, const char *, size_t, int *);
int __attribute__((__cdecl__)) wctomb (char *, wchar_t);
int __attribute__((__cdecl__)) _wctomb_r (struct _reent *, char *, wchar_t, int *);
size_t __attribute__((__cdecl__)) mbstowcs (wchar_t *, const char *, size_t);
size_t __attribute__((__cdecl__)) _mbstowcs_r (struct _reent *, wchar_t *, const char *, size_t, int *);
size_t __attribute__((__cdecl__)) wcstombs (char *, const wchar_t *, size_t);
size_t __attribute__((__cdecl__)) _wcstombs_r (struct _reent *, char *, const wchar_t *, size_t, int *);
int __attribute__((__cdecl__)) mkstemp (char *);
char * __attribute__((__cdecl__)) mktemp (char *);
void __attribute__((__cdecl__)) qsort (void * __base, size_t __nmemb, size_t __size, int(*_compar)(const void *, const void *));
int __attribute__((__cdecl__)) rand (void);
void * __attribute__((__cdecl__)) realloc (void * __r, size_t __size);
void __attribute__((__cdecl__)) srand (unsigned __seed);
double __attribute__((__cdecl__)) strtod (const char *__n, char **__end_PTR);
double __attribute__((__cdecl__)) _strtod_r (struct _reent *,const char *__n, char **__end_PTR);
float __attribute__((__cdecl__)) strtodf (const char *__n, char **__end_PTR);
long __attribute__((__cdecl__)) strtol (const char *__n, char **__end_PTR, int __base);
long __attribute__((__cdecl__)) _strtol_r (struct _reent *,const char *__n, char **__end_PTR, int __base);
unsigned long __attribute__((__cdecl__)) strtoul (const char *__n, char **__end_PTR, int __base);
unsigned long __attribute__((__cdecl__)) _strtoul_r (struct _reent *,const char *__n, char **__end_PTR, int __base);
int __attribute__((__cdecl__)) system (const char *__string);
int __attribute__((__cdecl__)) putenv (const char *__string);
int __attribute__((__cdecl__)) _putenv_r (struct _reent *, const char *__string);
int __attribute__((__cdecl__)) setenv (const char *__string, const char *__value, int __overwrite);
int __attribute__((__cdecl__)) _setenv_r (struct _reent *, const char *__string, const char *__value, int __overwrite);
char * __attribute__((__cdecl__)) gcvt (double,int,char *);
char * __attribute__((__cdecl__)) gcvtf (float,int,char *);
char * __attribute__((__cdecl__)) fcvt (double,int,int *,int *);
char * __attribute__((__cdecl__)) fcvtf (float,int,int *,int *);
char * __attribute__((__cdecl__)) ecvt (double,int,int *,int *);
char * __attribute__((__cdecl__)) ecvtbuf (double, int, int*, int*, char *);
char * __attribute__((__cdecl__)) fcvtbuf (double, int, int*, int*, char *);
char * __attribute__((__cdecl__)) ecvtf (float,int,int *,int *);
char * __attribute__((__cdecl__)) dtoa (double, int, int, int *, int*, char**);
int __attribute__((__cdecl__)) rand_r (unsigned *__seed);
double __attribute__((__cdecl__)) drand48 (void);
double __attribute__((__cdecl__)) _drand48_r (struct _reent *);
double __attribute__((__cdecl__)) erand48 (unsigned short [3]);
double __attribute__((__cdecl__)) _erand48_r (struct _reent *, unsigned short [3]);
long __attribute__((__cdecl__)) jrand48 (unsigned short [3]);
long __attribute__((__cdecl__)) _jrand48_r (struct _reent *, unsigned short [3]);
void __attribute__((__cdecl__)) lcong48 (unsigned short [7]);
void __attribute__((__cdecl__)) _lcong48_r (struct _reent *, unsigned short [7]);
long __attribute__((__cdecl__)) lrand48 (void);
long __attribute__((__cdecl__)) _lrand48_r (struct _reent *);
long __attribute__((__cdecl__)) mrand48 (void);
long __attribute__((__cdecl__)) _mrand48_r (struct _reent *);
long __attribute__((__cdecl__)) nrand48 (unsigned short [3]);
long __attribute__((__cdecl__)) _nrand48_r (struct _reent *, unsigned short [3]);
unsigned short *
__attribute__((__cdecl__)) seed48 (unsigned short [3]);
unsigned short *
__attribute__((__cdecl__)) _seed48_r (struct _reent *, unsigned short [3]);
void __attribute__((__cdecl__)) srand48 (long);
void __attribute__((__cdecl__)) _srand48_r (struct _reent *, long);
long long __attribute__((__cdecl__)) strtoll (const char *__n, char **__end_PTR, int __base);
long long __attribute__((__cdecl__)) _strtoll_r (struct _reent *, const char *__n, char **__end_PTR, int __base);
unsigned long long __attribute__((__cdecl__)) strtoull (const char *__n, char **__end_PTR, int __base);
unsigned long long __attribute__((__cdecl__)) _strtoull_r (struct _reent *, const char *__n, char **__end_PTR, int __base);
char * __attribute__((__cdecl__)) realpath (const char *, char *);
void __attribute__((__cdecl__)) unsetenv (const char *__string);
void __attribute__((__cdecl__)) _unsetenv_r (struct _reent *, const char *__string);
int __attribute__((__cdecl__)) random (void);
long __attribute__((__cdecl__)) srandom (unsigned __seed);
char * __attribute__((__cdecl__)) ptsname (int);
int __attribute__((__cdecl__)) grantpt (int);
int __attribute__((__cdecl__)) unlockpt (int);
char * __attribute__((__cdecl__)) _dtoa_r (struct _reent *, double, int, int, int *, int*, char**);
void * __attribute__((__cdecl__)) _malloc_r (struct _reent *, size_t);
void * __attribute__((__cdecl__)) _calloc_r (struct _reent *, size_t, size_t);
void __attribute__((__cdecl__)) _free_r (struct _reent *, void *);
void * __attribute__((__cdecl__)) _realloc_r (struct _reent *, void *, size_t);
void __attribute__((__cdecl__)) _mstats_r (struct _reent *, char *);
int __attribute__((__cdecl__)) _system_r (struct _reent *, const char *);
void __attribute__((__cdecl__)) __eprintf (const char *, const char *, unsigned int, const char *);
# 3 "utility.c" 2
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stdarg.h" 1 3
# 110 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stdarg.h" 3
typedef __gnuc_va_list va_list;
# 4 "utility.c" 2
# 1 "/usr/include/string.h" 1 3
# 14 "/usr/include/string.h" 3
# 1 "/usr/include/_ansi.h" 1 3
# 15 "/usr/include/string.h" 2 3
# 1 "/usr/include/sys/reent.h" 1 3
# 16 "/usr/include/string.h" 2 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 1 3
# 19 "/usr/include/string.h" 2 3
void * __attribute__((__cdecl__)) memchr (const void *, int, size_t);
int __attribute__((__cdecl__)) memcmp (const void *, const void *, size_t);
void * __attribute__((__cdecl__)) memcpy (void *, const void *, size_t);
void * __attribute__((__cdecl__)) memmove (void *, const void *, size_t);
void * __attribute__((__cdecl__)) memset (void *, int, size_t);
char *__attribute__((__cdecl__)) strcat (char *, const char *);
char *__attribute__((__cdecl__)) strchr (const char *, int);
int __attribute__((__cdecl__)) strcmp (const char *, const char *);
int __attribute__((__cdecl__)) strcoll (const char *, const char *);
char *__attribute__((__cdecl__)) strcpy (char *, const char *);
size_t __attribute__((__cdecl__)) strcspn (const char *, const char *);
char *__attribute__((__cdecl__)) strerror (int);
size_t __attribute__((__cdecl__)) strlen (const char *);
char *__attribute__((__cdecl__)) strncat (char *, const char *, size_t);
int __attribute__((__cdecl__)) strncmp (const char *, const char *, size_t);
char *__attribute__((__cdecl__)) strncpy (char *, const char *, size_t);
char *__attribute__((__cdecl__)) strpbrk (const char *, const char *);
char *__attribute__((__cdecl__)) strrchr (const char *, int);
size_t __attribute__((__cdecl__)) strspn (const char *, const char *);
char *__attribute__((__cdecl__)) strstr (const char *, const char *);
char *__attribute__((__cdecl__)) strtok (char *, const char *);
size_t __attribute__((__cdecl__)) strxfrm (char *, const char *, size_t);
char *__attribute__((__cdecl__)) strtok_r (char *, const char *, char **);
int __attribute__((__cdecl__)) bcmp (const char *, const char *, size_t);
void __attribute__((__cdecl__)) bcopy (const char *, char *, size_t);
void __attribute__((__cdecl__)) bzero (char *, size_t);
int __attribute__((__cdecl__)) ffs (int);
char *__attribute__((__cdecl__)) index (const char *, int);
void * __attribute__((__cdecl__)) memccpy (void *, const void *, int, size_t);
char *__attribute__((__cdecl__)) rindex (const char *, int);
int __attribute__((__cdecl__)) strcasecmp (const char *, const char *);
char *__attribute__((__cdecl__)) strdup (const char *);
char *__attribute__((__cdecl__)) _strdup_r (struct _reent *, const char *);
int __attribute__((__cdecl__)) strncasecmp (const char *, const char *, size_t);
char *__attribute__((__cdecl__)) strsep (char **, const char *);
char *__attribute__((__cdecl__)) strlwr (char *);
char *__attribute__((__cdecl__)) strupr (char *);
const char *__attribute__((__cdecl__)) strsignal (int __signo);
int __attribute__((__cdecl__)) strtosigno (const char *__name);
# 5 "utility.c" 2
# 1 "/usr/include/errno.h" 1 3
# 1 "/usr/include/sys/errno.h" 1 3
# 11 "/usr/include/sys/errno.h" 3
# 1 "/usr/include/sys/reent.h" 1 3
# 12 "/usr/include/sys/errno.h" 2 3
extern int *__errno (void);
extern __attribute__((dllimport)) const char * const _sys_errlist[];
extern __attribute__((dllimport)) int _sys_nerr;
extern __attribute__((dllimport)) const char * const sys_errlist[];
extern __attribute__((dllimport)) int sys_nerr;
# 2 "/usr/include/errno.h" 2 3
# 6 "utility.c" 2
# 1 "/usr/include/ctype.h" 1 3
# 1 "/usr/include/_ansi.h" 1 3
# 8 "/usr/include/ctype.h" 2 3
int __attribute__((__cdecl__)) isalnum (int __c);
int __attribute__((__cdecl__)) isalpha (int __c);
int __attribute__((__cdecl__)) iscntrl (int __c);
int __attribute__((__cdecl__)) isdigit (int __c);
int __attribute__((__cdecl__)) isgraph (int __c);
int __attribute__((__cdecl__)) islower (int __c);
int __attribute__((__cdecl__)) isprint (int __c);
int __attribute__((__cdecl__)) ispunct (int __c);
int __attribute__((__cdecl__)) isspace (int __c);
int __attribute__((__cdecl__)) isupper (int __c);
int __attribute__((__cdecl__)) isxdigit (int __c);
int __attribute__((__cdecl__)) tolower (int __c);
int __attribute__((__cdecl__)) toupper (int __c);
int __attribute__((__cdecl__)) isascii (int __c);
int __attribute__((__cdecl__)) toascii (int __c);
int __attribute__((__cdecl__)) _tolower (int __c);
int __attribute__((__cdecl__)) _toupper (int __c);
# 39 "/usr/include/ctype.h" 3
extern __attribute__((dllimport)) const char _ctype_[];
# 7 "utility.c" 2
# 1 "chess.h" 1
# 214 "chess.h"
# 1 "lock.h" 1
# 215 "chess.h" 2
# 250 "chess.h"
typedef unsigned long long BITBOARD;
# 1 "/usr/include/time.h" 1 3
# 10 "/usr/include/time.h" 3
# 1 "/usr/include/_ansi.h" 1 3
# 11 "/usr/include/time.h" 2 3
# 21 "/usr/include/time.h" 3
# 1 "/usr/include/machine/time.h" 1 3
# 22 "/usr/include/time.h" 2 3
# 30 "/usr/include/time.h" 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 1 3
# 31 "/usr/include/time.h" 2 3
# 1 "/usr/include/sys/types.h" 1 3
# 31 "/usr/include/sys/types.h" 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 1 3
# 147 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 3
typedef int ptrdiff_t;
# 32 "/usr/include/sys/types.h" 2 3
# 1 "/usr/include/machine/types.h" 1 3
# 33 "/usr/include/sys/types.h" 2 3
# 54 "/usr/include/sys/types.h" 3
typedef unsigned char u_char;
typedef unsigned short u_short;
typedef unsigned int u_int;
typedef unsigned long u_long;
typedef unsigned short ushort;
typedef unsigned int uint;
typedef unsigned long clock_t;
typedef long time_t;
struct timespec {
time_t tv_sec;
long tv_nsec;
};
struct itimerspec {
struct timespec it_interval;
struct timespec it_value;
};
typedef long daddr_t;
typedef char * caddr_t;
typedef unsigned long ino_t;
# 101 "/usr/include/sys/types.h" 3
typedef unsigned long vm_offset_t;
typedef unsigned long vm_size_t;
typedef char int8_t;
typedef unsigned char u_int8_t;
typedef short int16_t;
typedef unsigned short u_int16_t;
typedef int int32_t;
typedef unsigned int u_int32_t;
typedef long long int64_t;
typedef unsigned long long u_int64_t;
typedef int32_t register_t;
# 128 "/usr/include/sys/types.h" 3
typedef short dev_t;
# 138 "/usr/include/sys/types.h" 3
typedef int pid_t;
typedef long key_t;
typedef long ssize_t;
typedef char * addr_t;
typedef int mode_t;
# 157 "/usr/include/sys/types.h" 3
typedef unsigned short nlink_t;
# 179 "/usr/include/sys/types.h" 3
typedef long fd_mask;
typedef struct _types_fd_set {
fd_mask fds_bits[(((64)+(((sizeof (fd_mask) * 8))-1))/((sizeof (fd_mask) * 8)))];
} _types_fd_set;
# 215 "/usr/include/sys/types.h" 3
typedef unsigned long clockid_t;
typedef unsigned long timer_t;
typedef long useconds_t;
# 1 "/usr/include/sys/features.h" 1 3
# 229 "/usr/include/sys/types.h" 2 3
# 333 "/usr/include/sys/types.h" 3
# 1 "/usr/include/cygwin/types.h" 1 3
# 20 "/usr/include/cygwin/types.h" 3
typedef long __off32_t;
typedef long long __off64_t;
typedef __off32_t off_t;
typedef unsigned short __uid16_t;
typedef unsigned short __gid16_t;
typedef unsigned long __uid32_t;
typedef unsigned long __gid32_t;
typedef __uid16_t uid_t;
typedef __gid16_t gid_t;
typedef void *pthread_t;
typedef void *pthread_mutex_t;
typedef void *pthread_key_t;
typedef void *pthread_attr_t;
typedef void *pthread_mutexattr_t;
typedef void *pthread_condattr_t;
typedef void *pthread_cond_t;
typedef struct
{
pthread_mutex_t mutex;
int state;
}
pthread_once_t;
typedef void *pthread_rwlock_t;
typedef void *pthread_rwlockattr_t;
# 334 "/usr/include/sys/types.h" 2 3
# 33 "/usr/include/time.h" 2 3
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
};
clock_t __attribute__((__cdecl__)) clock (void);
double __attribute__((__cdecl__)) difftime (time_t _time2, time_t _time1);
time_t __attribute__((__cdecl__)) mktime (struct tm *_timeptr);
time_t __attribute__((__cdecl__)) time (time_t *_timer);
char *__attribute__((__cdecl__)) asctime (const struct tm *_tblock);
char *__attribute__((__cdecl__)) ctime (const time_t *_time);
struct tm *__attribute__((__cdecl__)) gmtime (const time_t *_timer);
struct tm *__attribute__((__cdecl__)) localtime (const time_t *_timer);
size_t __attribute__((__cdecl__)) strftime (char *_s, size_t _maxsize, const char *_fmt, const struct tm *_t);
char *__attribute__((__cdecl__)) asctime_r (const struct tm *, char *);
char *__attribute__((__cdecl__)) ctime_r (const time_t *, char *);
struct tm *__attribute__((__cdecl__)) gmtime_r (const time_t *, struct tm *);
struct tm *__attribute__((__cdecl__)) localtime_r (const time_t *, struct tm *);
char *__attribute__((__cdecl__)) strptime (const char *, const char *, struct tm *);
extern __attribute__((dllimport)) time_t _timezone;
extern __attribute__((dllimport)) int _daylight;
extern __attribute__((dllimport)) char *_tzname[2];
# 82 "/usr/include/time.h" 3
char *__attribute__((__cdecl__)) timezone (void);
void __attribute__((__cdecl__)) tzset (void);
# 1 "/usr/include/sys/features.h" 1 3
# 89 "/usr/include/time.h" 2 3
# 255 "chess.h" 2
typedef enum { A1,B1,C1,D1,E1,F1,G1,H1,
A2,B2,C2,D2,E2,F2,G2,H2,
A3,B3,C3,D3,E3,F3,G3,H3,
A4,B4,C4,D4,E4,F4,G4,H4,
A5,B5,C5,D5,E5,F5,G5,H5,
A6,B6,C6,D6,E6,F6,G6,H6,
A7,B7,C7,D7,E7,F7,G7,H7,
A8,B8,C8,D8,E8,F8,G8,H8,
BAD_SQUARE } squares;
typedef enum {FILEA, FILEB, FILEC, FILED, FILEE, FILEF, FILEG, FILEH} files;
typedef enum {RANK1, RANK2, RANK3, RANK4, RANK5, RANK6, RANK7, RANK8} ranks;
typedef enum {none=0, pawn=1, knight=2, king=3,
bishop=5, rook=6, queen=7} PIECE;
typedef enum {empty_v=0, pawn_v=1, knight_v=3,
bishop_v=3, rook_v=5, queen_v=9} PIECE_V;
typedef enum {no_extension=0, check_extension=1, recapture_extension=2,
passed_pawn_extension=4, one_reply_extension=8,
mate_extension=16} EXTENSIONS;
typedef enum {cpu, elapsed, microseconds} TIME_TYPE;
typedef enum {think=1, puzzle=2, book=3, annotate=4} SEARCH_TYPE;
typedef enum {normal_mode, tournament_mode} PLAYING_MODE;
typedef enum {crafty, opponent} PLAYER;
typedef enum {book_learning=1, position_learning=2,
result_learning=4} LEARNING_MODE;
typedef struct {
unsigned char enpassant_target;
signed char w_castle;
signed char b_castle;
unsigned char rule_50_moves;
} SEARCH_POSITION;
typedef struct {
int move1;
int move2;
} KILLER;
typedef struct {
BITBOARD w_occupied;
BITBOARD b_occupied;
BITBOARD occupied_rl90;
BITBOARD occupied_rl45;
BITBOARD occupied_rr45;
BITBOARD rooks_queens;
BITBOARD bishops_queens;
BITBOARD w_pawn;
BITBOARD w_knight;
BITBOARD w_bishop;
BITBOARD w_rook;
BITBOARD w_queen;
BITBOARD b_pawn;
BITBOARD b_knight;
BITBOARD b_bishop;
BITBOARD b_rook;
BITBOARD b_queen;
BITBOARD hash_key;
unsigned int pawn_hash_key;
int material_evaluation;
signed char white_king;
signed char black_king;
signed char board[64];
signed char white_pieces;
signed char white_minors;
signed char white_majors;
signed char white_pawns;
signed char black_pieces;
signed char black_minors;
signed char black_majors;
signed char black_pawns;
signed char total_pieces;
} POSITION;
typedef struct {
BITBOARD word1;
BITBOARD word2;
} HASH_ENTRY;
typedef struct {
unsigned int key;
short p_score;
unsigned char passed_b;
unsigned char black_defects_k;
unsigned char black_defects_q;
unsigned char passed_w;
unsigned char white_defects_k;
unsigned char white_defects_q;
unsigned char protected;
unsigned char outside;
unsigned char candidates_w;
unsigned char candidates_b;
unsigned char allw;
unsigned char allb;
} PAWN_HASH_ENTRY;
typedef struct {
int path[65];
unsigned char pathh;
unsigned char pathl;
unsigned char pathd;
} PATH;
typedef struct {
int phase;
int remaining;
int *last;
} NEXT_MOVE;
typedef struct {
BITBOARD nodes;
int move;
unsigned char status;
} ROOT_MOVE;
typedef struct {
BITBOARD position;
unsigned int status_played;
float learn;
int CAP_score;
} BOOK_POSITION;
typedef struct {
unsigned char position[8];
unsigned char status;
unsigned char percent_play;
} BB_POSITION;
struct tree {
POSITION pos;
PAWN_HASH_ENTRY pawn_score;
NEXT_MOVE next_status[65];
BITBOARD save_hash_key[65 +2];
BITBOARD replist_w[128];
BITBOARD replist_b[128];
BITBOARD *rephead_w;
BITBOARD *rephead_b;
BITBOARD all_pawns;
SEARCH_POSITION position[65 +2];
unsigned int save_pawn_hash_key[65 +2];
int current_move[65];
int hash_move[65];
int *last[65];
PATH pv[65];
unsigned int nodes_searched;
unsigned int fail_high;
unsigned int fail_high_first;
unsigned int evaluations;
unsigned int transposition_probes;
unsigned int transposition_hits;
unsigned int pawn_probes;
unsigned int pawn_hits;
unsigned int egtb_probes;
unsigned int egtb_probes_successful;
unsigned int check_extensions_done;
unsigned int recapture_extensions_done;
unsigned int passed_pawn_extensions_done;
unsigned int one_reply_extensions_done;
unsigned int mate_extensions_done;
KILLER killers[65];
int move_list[5120];
int sort_value[256];
signed char in_check[65];
signed char extended_reason[65];
signed char phase[65];
int search_value;
int w_safety, b_safety;
int w_kingsq, b_kingsq;
int endgame;
int root_move;
int lock;
int thread_id;
volatile char stop;
volatile char done;
char root_move_text[16];
char remaining_moves_text[16];
struct tree *volatile siblings[1], *parent;
volatile int nprocs;
int alpha;
int beta;
int value;
int wtm;
int depth;
int ply;
int mate_threat;
int used;
};
typedef struct tree TREE;
# 477 "chess.h"
struct at {
unsigned char which_attack[8][64];
BITBOARD file_attack_bitboards[8][12];
unsigned char rank_attack_bitboards[8][12];
unsigned char length8_mobility[8][12];
unsigned char short_mobility[116];
};
typedef struct {
BITBOARD *d_attacks;
unsigned char *d_mobility;
unsigned char *d_which_attack;
unsigned char d_shift;
unsigned char d_mask;
unsigned char ad_shift;
unsigned char ad_mask;
unsigned char *ad_which_attack;
unsigned char *ad_mobility;
BITBOARD *ad_attacks;
} DIAG_INFO;
# 531 "chess.h"
BITBOARD Mask(int);
int PopCnt(BITBOARD);
int FirstOne(BITBOARD);
int LastOne(BITBOARD);
void Analyze();
void Annotate();
void AnnotateHeaderHTML(char*, FILE*);
void AnnotateFooterHTML(FILE*);
void AnnotatePositionHTML(TREE*, int, FILE*);
char *AnnotateValueToNAG(int, int, int);
int Attacked(TREE*, int, int);
BITBOARD AttacksFrom(TREE*, int, int);
BITBOARD AttacksTo(TREE*, int);
void Bench(void);
int Book(TREE*,int,int);
int BookMask(char*);
int BookPonderMove(TREE*,int);
int BookRejectMove(TREE*,int);
void BookUp(TREE*, char*, int, char**);
void BookSort(BB_POSITION*, int, int);
int BookUpCompare(const void *, const void *);
BB_POSITION BookUpNextPosition(int, int);
int CheckInput(void);
void ClearHashTableScores(void);
void ComputeAttacksAndMobility(void);
void CopyFromSMP(TREE*, TREE*);
TREE* CopyToSMP(TREE*);
void DelayTime(int);
void DGTInit(int,char**);
int DGTCheckInput(void);
void DGTRead(void);
void DisplayBitBoard(BITBOARD);
void DisplayChessBoard(FILE*, POSITION);
char* DisplayEvaluation(int,int);
char* DisplayEvaluationWhisper(int,int);
void DisplayFT(int, int, int);
char* DisplayHHMM(unsigned int);
void DisplayPieceBoards(signed char*, signed char*);
void DisplayPV(TREE*, int, int, int, int, PATH*);
char* DisplaySQ(unsigned int);
char* DisplayTime(unsigned int);
char* DisplayTimeWhisper(unsigned int);
void DisplayTreeState(TREE*, int, int, int);
void Display2BitBoards(BITBOARD, BITBOARD);
void DisplayChessMove(char*, int);
int Drawn(TREE*, int);
void Edit(void);
int EGTBProbe(TREE*, int, int, int*);
void EGTBPV(TREE*, int);
int EnPrise(int, int);
int Evaluate(TREE*, int, int, int, int);
int EvaluateDevelopmentB(TREE*, int);
int EvaluateDevelopmentW(TREE*, int);
int EvaluateDraws(TREE*);
int EvaluateKingSafety(TREE*, int);
int EvaluateMate(TREE*);
int EvaluateMaterial(TREE*);
int EvaluatePassedPawns(TREE*);
int EvaluatePassedPawnRaces(TREE*, int);
int EvaluatePawns(TREE*);
void EVTest(char *);
int FindBlockID(TREE*);
char* FormatPV(TREE*,int,PATH);
int FTbSetCacheSize(void*,unsigned long);
int* GenerateCaptures(TREE*, int, int, int*);
int* GenerateCheckEvasions(TREE*, int, int, int*);
int* GenerateNonCaptures(TREE*, int, int, int*);
int HashProbe(TREE*, int, int, int, int*, int*, int*);
void HashStore(TREE*, int, int, int, int, int, int);
void HashStorePV(TREE*, int,int);
int HasOpposition(int, int, int);
void History(TREE*, int, int, int, int);
int IInitializeTb(char*);
void Initialize(int);
void InitializeAttackBoards(void);
void InitializeChessBoard(SEARCH_POSITION*);
int InitializeFindAttacks(int, int, int);
void InitializeHashTables(void);
void InitializeHistoryKillers(void);
void InitializeMasks(void);
void InitializePawnMasks(void);
void InitializePieceMasks(void);
void InitializeRandomHash(void);
void InitializeSMP(void);
void InitializeZeroMasks(void);
int InputMove(TREE*, char*, int, int, int, int);
int InputMoveICS(TREE*, char*, int, int, int, int);
BITBOARD InterposeSquares(int, int, int);
void Interrupt(int);
int Iterate(int, int, int);
int KingPawnSquare(int, int, int, int);
void LearnBook(TREE*, int, int, int, int, int);
void LearnBookUpdate(TREE*, int, int, float);
int LearnFunction(int, int, int, int);
void LearnImport(TREE*, int, char**);
void LearnImportBook(TREE*, int, char**);
void LearnImportCAP(TREE*, int, char**);
void LearnImportPosition(TREE*, int, char**);
void LearnPosition(TREE*, int, int, int);
void LearnPositionLoad(void);
int LegalMove(TREE*, int, int, int);
void MakeMove(TREE*, int, int, int);
void MakeMoveRoot(TREE*, int, int);
void NewGame(int);
int NextEvasion(TREE*, int, int);
int NextMove(TREE*, int, int);
int NextRootMove(TREE*, TREE*, int);
int NextRootMoveParallel(void);
char* Normal(void);
int Option(TREE*);
int OptionMatch(char*, char*);
void OptionPerft(TREE*, int, int, int);
char* OutputMove(TREE*, int, int, int);
char* OutputMoveICS(int);
int OutputGood(TREE*, char*, int, int);
int ParseTime(char*);
void Pass(void);
void Phase(void);
int PinnedOnKing(TREE*, int, int);
int Ponder(int);
void PreEvaluate(TREE*,int);
void Print(int, char*, ...);
int Quiesce(TREE*, int, int, int, int);
unsigned int Random32(void);
BITBOARD Random64(void);
int Read(int, char*);
int ReadChessMove(TREE*, FILE*, int, int);
void ReadClear();
unsigned int ReadClock(TIME_TYPE);
int ReadPGN(FILE*,int);
int ReadNextMove(TREE*, char*, int, int);
int ReadParse(char*, char *args[], char*);
int ReadInput();
int RepetitionCheck(TREE*, int, int);
int RepetitionCheckBook(TREE*, int, int);
int RepetitionDraw(TREE*, int);
void ResignOrDraw(TREE*, int);
void RestoreGame(void);
char* Reverse(void);
void RootMoveList(int);
int Search(TREE*, int, int, int, int, int, int);
void SearchOutput(TREE*, int, int);
int SearchRoot(TREE*, int, int, int, int);
int SearchSMP(TREE*, int, int, int, int, int, int, int);
void SearchTrace(TREE*, int, int, int, int, int, char*, int);
void SetBoard(SEARCH_POSITION*,int,char**,int);
void SetChessBitBoards(SEARCH_POSITION*);
int StrCnt(char*, char);
int Swap(TREE*, int, int, int);
BITBOARD SwapXray(TREE*, BITBOARD, int, int);
void Test(char *);
int Thread(TREE*);
void* ThreadInit(void*);
void ThreadStop(TREE*);
int ThreadWait(int, TREE*);
int Threat(TREE*, int, int, int, int, int, int);
void TimeAdjust(int,PLAYER);
int TimeCheck(TREE*,int);
void TimeSet(int);
void UnMakeMove(TREE*, int, int, int);
int ValidMove(TREE*, int, int, int);
void ValidatePosition(TREE*, int, int, char*);
void Whisper(int, int, int, int, int, unsigned int, int, int, char*);
# 899 "chess.h"
extern BITBOARD AttacksRookFunc(int, POSITION *);
extern BITBOARD AttacksBishopFunc(DIAG_INFO *, POSITION *);
# 947 "chess.h"
extern BITBOARD AttacksRankFunc(int, POSITION *);
extern BITBOARD AttacksFileFunc(int, POSITION *);
extern BITBOARD AttacksDiaga1Func(DIAG_INFO *, POSITION *);
extern BITBOARD AttacksDiagh1Func(DIAG_INFO *, POSITION *);
# 1011 "chess.h"
extern unsigned MobilityRankFunc(int, POSITION *);
extern unsigned MobilityFileFunc(int, POSITION *);
extern unsigned MobilityDiaga1Func(DIAG_INFO *, POSITION *);
extern unsigned MobilityDiagh1Func(DIAG_INFO *, POSITION *);
# 8 "utility.c" 2
# 1 "data.h" 1
extern char version[6];
extern PLAYING_MODE mode;
extern int batch_mode;
extern int swindle_mode;
extern int call_flag;
extern int crafty_rating;
extern int opponent_rating;
extern int number_auto_kibitzers;
extern int number_of_computers;
extern int number_of_GMs;
extern int number_of_IMs;
extern int number_of_blockers;
extern int time_used;
extern int time_used_opponent;
extern int cpu_time_used;
extern int next_time_check;
extern int total_moves;
extern int initialized;
extern int early_exit;
extern int new_game;
extern char auto_kibitz_list[64][20];
extern char GM_list[512][20];
extern char IM_list[512][20];
extern char computer_list[512][20];
extern char blocker_list[512][20];
extern FILE *input_stream;
extern FILE *book_file;
extern FILE *books_file;
extern FILE *normal_bs_file;
extern FILE *computer_bs_file;
extern FILE *history_file;
extern FILE *log_file;
extern FILE *auto_file;
extern FILE *book_lrn_file;
extern FILE *position_file;
extern FILE *position_lrn_file;
extern int log_id;
extern int output_format;
extern int EGTBlimit;
extern int EGTB_draw;
extern int EGTB_search;
extern int EGTB_use;
extern void *EGTB_cache;
extern int EGTB_cache_size;
extern int EGTB_setup;
extern int DGT_active;
extern int to_dgt;
extern int from_dgt;
extern char whisper_text[512];
extern int whisper_depth;
extern int last_mate_score;
extern int last_opponent_move;
extern int average_nps;
extern int incheck_depth;
extern int onerep_depth;
extern int pushpp_depth;
extern int recap_depth;
extern int mate_depth;
extern int null_min;
extern int null_max;
extern int pgn_suggested_percent;
extern char pgn_event[32];
extern char pgn_date[32];
extern char pgn_round[32];
extern char pgn_site[32];
extern char pgn_white[64];
extern char pgn_white_elo[32];
extern char pgn_black[64];
extern char pgn_black_elo[32];
extern char pgn_result[32];
extern char log_filename[64];
extern char history_filename[64];
extern int number_of_solutions;
extern int solutions[10];
extern int solution_type;
extern int draw_score[2];
extern int abs_draw_score;
extern int accept_draws;
extern int over;
extern int ics;
extern int auto232;
extern int auto232_delay;
extern int xboard;
extern int pong;
extern int whisper;
extern int channel;
extern char channel_title[32];
extern char book_path[128];
extern char log_path[128];
extern char tb_path[128];
extern char rc_path[128];
extern char cmd_buffer[512];
extern char *args[32];
extern char buffer[512];
extern int nargs;
extern int kibitz;
extern int move_number;
extern int wtm;
extern int crafty_is_white;
extern int iteration_depth;
extern int last_search_value;
extern int search_failed_high;
extern int search_failed_low;
extern int largest_positional_score;
extern int root_alpha;
extern int root_beta;
extern int last_root_value;
extern int ponder_value;
extern int root_value;
extern int root_wtm;
extern int root_print_ok;
extern int move_actually_played;
extern ROOT_MOVE root_moves[256];
extern int n_root_moves;
extern int nodes_per_second;
extern int cpu_percent;
extern int opening;
extern int middle_game;
extern int end_game;
extern int analyze_mode;
extern int annotate_mode;
extern int test_mode;
extern int input_status;
extern signed char resign;
extern signed char resign_counter;
extern signed char resign_count;
extern signed char draw_counter;
extern signed char draw_count;
extern char audible_alarm;
extern char hint[512];
extern char book_hint[512];
extern int post;
extern int search_depth;
extern unsigned int search_nodes;
extern int search_move;
extern int easy_move;
extern TIME_TYPE time_type;
extern int time_limit;
extern int absolute_time_limit;
extern int search_time_limit;
extern int nodes_between_time_checks;
extern int burp;
extern int time_abort;
extern signed char pondering;
extern signed char thinking;
extern signed char puzzling;
extern signed char booking;
extern signed char abort_search;
extern int ponder;
extern int ponder_move;
extern int force;
extern int ponder_moves[220];
extern int num_ponder_moves;
extern char initial_position[80];
extern unsigned int opponent_start_time, opponent_end_time;
extern unsigned int program_start_time, program_end_time;
extern unsigned int start_time, end_time;
extern unsigned int elapsed_start, elapsed_end;
extern int predicted;
extern signed char transposition_id;
extern int ansi;
extern int trace_level;
extern int max_threads;
extern int min_thread_depth;
extern int max_thread_group;
extern int split_at_root;
extern int thread_depth;
extern int display_options;
extern unsigned int noise_level;
extern int book_move;
extern int moves_out_of_book;
extern int book_accept_mask;
extern int book_reject_mask;
extern int book_random;
extern float book_weight_freq;
extern float book_weight_eval;
extern float book_weight_learn;
extern float book_weight_CAP;
extern int book_search_trigger;
extern int book_selection_width;
extern int show_book;
extern int learning;
extern int book_learn_eval[10];
extern int book_learn_depth[10];
extern int tc_moves;
extern int tc_time;
extern int tc_time_remaining;
extern int tc_time_remaining_opponent;
extern int tc_moves_remaining;
extern int tc_secondary_moves;
extern int tc_secondary_time;
extern int tc_increment;
extern int tc_sudden_death;
extern int tc_operator_time;
extern int tc_safety_margin;
extern int trojan_check;
extern int computer_opponent;
extern int usage_level;
extern int log_hash;
extern int log_pawn_hash;
extern int hash_table_size;
extern int pawn_hash_table_size;
extern int hash_maska;
extern int hash_maskb;
extern unsigned int pawn_hash_mask;
extern HASH_ENTRY *trans_ref_a;
extern HASH_ENTRY *trans_ref_b;
extern PAWN_HASH_ENTRY *pawn_hash_table;
extern HASH_ENTRY *trans_ref_a_orig;
extern HASH_ENTRY *trans_ref_b_orig;
extern PAWN_HASH_ENTRY *pawn_hash_table_orig;
extern int history_w[4096], history_b[4096];
extern const int p_values[15];
extern PATH last_pv;
extern int last_value;
extern const char xlate[15];
extern const char empty[9];
extern signed char white_outpost[64];
extern signed char black_outpost[64];
extern const char square_color[64];
extern const char connected_passed_pawn_value[8];
extern const int hidden_passed_pawn_value[8];
extern const int passed_pawn_value[8];
extern const char blockading_passed_pawn_value[8];
extern const char isolated_pawn_value[9];
extern const char isolated_pawn_of_value[9];
extern const char doubled_pawn_value[7];
extern const char pawn_rams_v[9];
extern char pawn_rams[9];
extern const char supported_passer[8];
extern const char outside_passed[128];
extern const char majority[128];
extern const int temper[64];
extern int temper_b[64], temper_w[64];
extern const char ttemper[64];
extern int king_safety_asymmetry;
extern int king_safety_scale;
extern int king_safety_tropism;
extern int blocked_scale;
extern int pawn_scale;
extern int passed_scale;
extern const char missing[8];
extern const char openf[4];
extern const char hopenf[4];
extern const char king_tropism_n[8];
extern const char king_tropism_b[8];
extern const char king_tropism_r[8];
extern const char king_tropism_at_r[8];
extern const char king_tropism_q[8];
extern const char king_tropism_at_q[8];
extern const int king_tropism[128];
extern int tropism[128];
extern signed char pval_w[64];
extern signed char pval_b[64];
extern signed char nval_w[64];
extern signed char nval_b[64];
extern signed char bval_w[64];
extern signed char bval_b[64];
extern signed char rval_w[64];
extern signed char rval_b[64];
extern signed char qval_w[64];
extern signed char qval_b[64];
extern signed char kval_wn[64];
extern signed char kval_wk[64];
extern signed char kval_wq[64];
extern signed char kval_bn[64];
extern signed char kval_bk[64];
extern signed char kval_bq[64];
extern signed char king_defects_w[64];
extern signed char king_defects_b[64];
extern const char b_n_mate_dark_squares[64];
extern const char b_n_mate_light_squares[64];
extern const char mate[64];
extern const char push_extensions[64];
extern signed char directions[64][64];
extern BITBOARD w_pawn_attacks[64];
extern BITBOARD b_pawn_attacks[64];
extern BITBOARD knight_attacks[64];
extern BITBOARD bishop_attacks[64];
extern struct at at;
extern BITBOARD diag_attack_bitboards[296];
extern BITBOARD anti_diag_attack_bitboards[296];
extern DIAG_INFO diag_info[64];
extern const unsigned char bishop_shift_rl45[64];
extern const unsigned char bishop_shift_rr45[64];
# 324 "data.h"
extern BITBOARD rook_attacks[64];
extern POSITION display;
extern BITBOARD queen_attacks[64];
extern BITBOARD king_attacks[64];
extern BITBOARD king_attacks_1[64];
extern BITBOARD king_attacks_2[64];
extern BITBOARD obstructed[64][64];
extern unsigned int w_pawn_random32[64];
extern unsigned int b_pawn_random32[64];
extern BITBOARD w_pawn_random[64];
extern BITBOARD b_pawn_random[64];
extern BITBOARD w_knight_random[64];
extern BITBOARD b_knight_random[64];
extern BITBOARD w_bishop_random[64];
extern BITBOARD b_bishop_random[64];
extern BITBOARD w_rook_random[64];
extern BITBOARD b_rook_random[64];
extern BITBOARD w_queen_random[64];
extern BITBOARD b_queen_random[64];
extern BITBOARD w_king_random[64];
extern BITBOARD b_king_random[64];
extern BITBOARD enpassant_random[65];
extern BITBOARD castle_random_w[2];
extern BITBOARD castle_random_b[2];
extern BITBOARD wtm_random[2];
extern BITBOARD clear_mask[65];
extern BITBOARD clear_mask_rl90[65];
extern BITBOARD clear_mask_rl45[65];
extern BITBOARD clear_mask_rr45[65];
extern BITBOARD set_mask[65];
extern BITBOARD set_mask_rl90[65];
extern BITBOARD set_mask_rl45[65];
extern BITBOARD set_mask_rr45[65];
extern BITBOARD file_mask[8];
extern BITBOARD rank_mask[8];
extern BITBOARD right_side_mask[8];
extern BITBOARD left_side_mask[8];
extern BITBOARD right_side_empty_mask[8];
extern BITBOARD left_side_empty_mask[8];
extern BITBOARD mask_efgh, mask_fgh, mask_abc, mask_abcd;
extern BITBOARD mask_abs7_w, mask_abs7_b;
extern BITBOARD mask_advance_2_w;
extern BITBOARD mask_advance_2_b;
extern BITBOARD mask_left_edge;
extern BITBOARD mask_right_edge;
extern BITBOARD mask_A7H7;
extern BITBOARD mask_A2H2;
extern BITBOARD mask_A3B3;
extern BITBOARD mask_B3C3;
extern BITBOARD mask_F3G3;
extern BITBOARD mask_G3H3;
extern BITBOARD mask_A6B6;
extern BITBOARD mask_B6C6;
extern BITBOARD mask_F6G6;
extern BITBOARD mask_G6H6;
extern BITBOARD mask_white_OO;
extern BITBOARD mask_white_OOO;
extern BITBOARD mask_black_OO;
extern BITBOARD mask_black_OOO;
extern BITBOARD stonewall_white;
extern BITBOARD stonewall_black;
extern BITBOARD e7_e6;
extern BITBOARD e2_e3;
extern BITBOARD closed_white;
extern BITBOARD closed_black;
extern BITBOARD mask_kr_trapped_w[3];
extern BITBOARD mask_qr_trapped_w[3];
extern BITBOARD mask_kr_trapped_b[3];
extern BITBOARD mask_qr_trapped_b[3];
extern BITBOARD good_bishop_kw;
extern BITBOARD good_bishop_qw;
extern BITBOARD good_bishop_kb;
extern BITBOARD good_bishop_qb;
extern BITBOARD light_squares;
extern BITBOARD dark_squares;
extern BITBOARD not_rook_pawns;
extern BITBOARD plus1dir[65];
extern BITBOARD plus7dir[65];
extern BITBOARD plus8dir[65];
extern BITBOARD plus9dir[65];
extern BITBOARD minus1dir[65];
extern BITBOARD minus7dir[65];
extern BITBOARD minus8dir[65];
extern BITBOARD minus9dir[65];
extern BITBOARD mask_eptest[64];
extern BITBOARD mask_1;
extern BITBOARD mask_2;
extern BITBOARD mask_3;
extern BITBOARD mask_8;
extern BITBOARD mask_16;
extern BITBOARD mask_112;
extern BITBOARD mask_120;
extern BITBOARD mask_clear_entry;
extern unsigned char first_ones_8bit[256];
extern unsigned char last_ones_8bit[256];
extern unsigned char pop_cnt_8bit[256];
extern unsigned char connected_passed[256];
extern unsigned char file_spread[256];
extern signed char is_outside[256][256];
extern signed char is_outside_c[256][256];
extern BITBOARD mask_pawn_protected_b[64];
extern BITBOARD mask_pawn_protected_w[64];
extern BITBOARD mask_pawn_duo[64];
extern BITBOARD mask_pawn_isolated[64];
extern BITBOARD mask_pawn_passed_w[64];
extern BITBOARD mask_pawn_passed_b[64];
extern BITBOARD mask_no_pawn_attacks_w[64];
extern BITBOARD mask_no_pawn_attacks_b[64];
extern BITBOARD white_minor_pieces;
extern BITBOARD black_minor_pieces;
extern BITBOARD white_pawn_race_wtm[64];
extern BITBOARD white_pawn_race_btm[64];
extern BITBOARD black_pawn_race_wtm[64];
extern BITBOARD black_pawn_race_btm[64];
extern BITBOARD mask_wk_4th, mask_wq_4th, mask_bk_4th, mask_bq_4th;
extern BOOK_POSITION book_buffer[2000];
extern BOOK_POSITION books_buffer[2000];
extern unsigned int thread_start_time[1];
# 470 "data.h"
extern TREE local_data[1], *local[1];
extern unsigned int parallel_splits;
extern unsigned int parallel_stops;
extern unsigned int max_split_blocks;
extern volatile unsigned int splitting;
extern int cbEGTBCompBytes;
# 9 "utility.c" 2
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/limits.h" 1 3
# 11 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/limits.h" 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/syslimits.h" 1 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/limits.h" 1 3
# 125 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/limits.h" 3
# 1 "/usr/include/limits.h" 1 3
# 126 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/limits.h" 2 3
# 8 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/syslimits.h" 2 3
# 12 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/limits.h" 2 3
# 11 "utility.c" 2
# 23 "utility.c"
# 1 "/usr/include/sys/times.h" 1 3
# 1 "/usr/include/_ansi.h" 1 3
# 8 "/usr/include/sys/times.h" 2 3
# 1 "/usr/include/machine/types.h" 1 3
# 9 "/usr/include/sys/times.h" 2 3
struct tms {
clock_t tms_utime;
clock_t tms_stime;
clock_t tms_cutime;
clock_t tms_cstime;
};
clock_t __attribute__((__cdecl__)) times (struct tms *);
# 24 "utility.c" 2
# 1 "/usr/include/sys/time.h" 1 3
# 1 "/usr/include/_ansi.h" 1 3
# 9 "/usr/include/sys/time.h" 2 3
# 1 "/usr/include/sys/types.h" 1 3
# 10 "/usr/include/sys/time.h" 2 3
struct timeval {
long tv_sec;
long tv_usec;
};
struct timezone {
int tz_minuteswest;
int tz_dsttime;
};
# 1 "/usr/include/sys/select.h" 1 3
# 17 "/usr/include/sys/select.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 18 "/usr/include/sys/select.h" 2 3
# 1 "/usr/include/sys/types.h" 1 3
# 21 "/usr/include/sys/select.h" 2 3
# 1 "/usr/include/sys/time.h" 1 3
# 24 "/usr/include/sys/select.h" 2 3
# 1 "/usr/include/time.h" 1 3
# 25 "/usr/include/sys/select.h" 2 3
int select (int __n, _types_fd_set *__readfds, _types_fd_set *__writefds, _types_fd_set *__exceptfds, struct timeval *__timeout);
# 28 "/usr/include/sys/time.h" 2 3
# 36 "/usr/include/sys/time.h" 3
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
# 73 "/usr/include/sys/time.h" 3
int __attribute__((__cdecl__)) gettimeofday (struct timeval *__p, struct timezone *__z);
int __attribute__((__cdecl__)) settimeofday (const struct timeval *, const struct timezone *);
int __attribute__((__cdecl__)) utimes (const char *__path, struct timeval *__tvp);
int __attribute__((__cdecl__)) getitimer (int __which, struct itimerval *__value);
int __attribute__((__cdecl__)) setitimer (int __which, const struct itimerval *__value, struct itimerval *__ovalue);
# 25 "utility.c" 2
# 1 "/usr/include/unistd.h" 1 3
# 1 "/usr/include/sys/unistd.h" 1 3
# 1 "/usr/include/_ansi.h" 1 3
# 9 "/usr/include/sys/unistd.h" 2 3
# 1 "/usr/include/sys/types.h" 1 3
# 10 "/usr/include/sys/unistd.h" 2 3
# 1 "/usr/include/sys/_types.h" 1 3
# 11 "/usr/include/sys/unistd.h" 2 3
# 1 "/usr/local/lib/gcc-lib/i686-pc-cygwin/3.0.4/include/stddef.h" 1 3
# 14 "/usr/include/sys/unistd.h" 2 3
extern char **environ;
void __attribute__((__cdecl__)) _exit (int __status ) __attribute__ ((noreturn));
int __attribute__((__cdecl__)) access (const char *__path, int __amode );
unsigned __attribute__((__cdecl__)) alarm (unsigned __secs );
int __attribute__((__cdecl__)) chdir (const char *__path );
int __attribute__((__cdecl__)) chmod (const char *__path, mode_t __mode );
int __attribute__((__cdecl__)) chown (const char *__path, uid_t __owner, gid_t __group );
int __attribute__((__cdecl__)) chroot (const char *__path );
int __attribute__((__cdecl__)) close (int __fildes );
char __attribute__((__cdecl__)) *ctermid (char *__s );
char __attribute__((__cdecl__)) *cuserid (char *__s );
int __attribute__((__cdecl__)) dup (int __fildes );
int __attribute__((__cdecl__)) dup2 (int __fildes, int __fildes2 );
void __attribute__((__cdecl__)) endusershell (void);
int __attribute__((__cdecl__)) execl (const char *__path, const char *, ... );
int __attribute__((__cdecl__)) execle (const char *__path, const char *, ... );
int __attribute__((__cdecl__)) execlp (const char *__file, const char *, ... );
int __attribute__((__cdecl__)) execv (const char *__path, char * const __argv[] );
int __attribute__((__cdecl__)) execve (const char *__path, char * const __argv[], char * const __envp[] );
int __attribute__((__cdecl__)) execvp (const char *__file, char * const __argv[] );
int __attribute__((__cdecl__)) fchdir (int __fildes);
int __attribute__((__cdecl__)) fchmod (int __fildes, mode_t __mode );
int __attribute__((__cdecl__)) fchown (int __fildes, uid_t __owner, gid_t __group );
pid_t __attribute__((__cdecl__)) fork (void );
long __attribute__((__cdecl__)) fpathconf (int __fd, int __name );
int __attribute__((__cdecl__)) fsync (int __fd);
char __attribute__((__cdecl__)) *getcwd (char *__buf, size_t __size );
gid_t __attribute__((__cdecl__)) getegid (void );
uid_t __attribute__((__cdecl__)) geteuid (void );
gid_t __attribute__((__cdecl__)) getgid (void );
int __attribute__((__cdecl__)) getgroups (int __gidsetsize, gid_t __grouplist[] );
char __attribute__((__cdecl__)) *getlogin (void );
int __attribute__((__cdecl__)) getlogin_r (char *name, size_t namesize);
char __attribute__((__cdecl__)) *getpass (__const char *__prompt);
size_t __attribute__((__cdecl__)) getpagesize (void);
pid_t __attribute__((__cdecl__)) getpgid (pid_t);
pid_t __attribute__((__cdecl__)) getpgrp (void );
pid_t __attribute__((__cdecl__)) getpid (void );
pid_t __attribute__((__cdecl__)) getppid (void );
uid_t __attribute__((__cdecl__)) getuid (void );
char * __attribute__((__cdecl__)) getusershell (void);
char __attribute__((__cdecl__)) *getwd (char *__buf );
int __attribute__((__cdecl__)) iruserok (unsigned long raddr, int superuser, const char *ruser, const char *luser);
int __attribute__((__cdecl__)) isatty (int __fildes );
int __attribute__((__cdecl__)) lchown (const char *__path, uid_t __owner, gid_t __group );
int __attribute__((__cdecl__)) link (const char *__path1, const char *__path2 );
int __attribute__((__cdecl__)) nice (int __nice_value );
off_t __attribute__((__cdecl__)) lseek (int __fildes, off_t __offset, int __whence );
long __attribute__((__cdecl__)) pathconf (const char *__path, int __name );
int __attribute__((__cdecl__)) pause (void );
int __attribute__((__cdecl__)) pthread_atfork (void (*)(void), void (*)(void), void (*)(void));
int __attribute__((__cdecl__)) pipe (int __fildes[2] );
_ssize_t __attribute__((__cdecl__)) read (int __fd, void *__buf, size_t __nbyte );
int __attribute__((__cdecl__)) revoke (char *path);
int __attribute__((__cdecl__)) rmdir (const char *__path );
int __attribute__((__cdecl__)) ruserok (const char *rhost, int superuser, const char *ruser, const char *luser);
void * __attribute__((__cdecl__)) sbrk (size_t __incr);
int __attribute__((__cdecl__)) setegid (gid_t __gid );
int __attribute__((__cdecl__)) seteuid (uid_t __uid );
int __attribute__((__cdecl__)) setgid (gid_t __gid );
int __attribute__((__cdecl__)) setpgid (pid_t __pid, pid_t __pgid );
int __attribute__((__cdecl__)) setpgrp (void );
pid_t __attribute__((__cdecl__)) setsid (void );
int __attribute__((__cdecl__)) setuid (uid_t __uid );
void __attribute__((__cdecl__)) setusershell (void);
unsigned __attribute__((__cdecl__)) sleep (unsigned int __seconds );
void __attribute__((__cdecl__)) swab (const void *, void *, ssize_t);
long __attribute__((__cdecl__)) sysconf (int __name );
pid_t __attribute__((__cdecl__)) tcgetpgrp (int __fildes );
int __attribute__((__cdecl__)) tcsetpgrp (int __fildes, pid_t __pgrp_id );
char __attribute__((__cdecl__)) *ttyname (int __fildes );
int __attribute__((__cdecl__)) unlink (const char *__path );
int __attribute__((__cdecl__)) vhangup (void );
_ssize_t __attribute__((__cdecl__)) write (int __fd, const void *__buf, size_t __nbyte );
pid_t __attribute__((__cdecl__)) vfork (void );
int __attribute__((__cdecl__)) _close (int __fildes );
pid_t __attribute__((__cdecl__)) _fork (void );
pid_t __attribute__((__cdecl__)) _getpid (void );
int __attribute__((__cdecl__)) _link (const char *__path1, const char *__path2 );
off_t __attribute__((__cdecl__)) _lseek (int __fildes, off_t __offset, int __whence );
_ssize_t __attribute__((__cdecl__)) _read (int __fd, void *__buf, size_t __nbyte );
void * __attribute__((__cdecl__)) _sbrk (size_t __incr);
int __attribute__((__cdecl__)) _unlink (const char *__path );
_ssize_t __attribute__((__cdecl__)) _write (int __fd, const void *__buf, size_t __nbyte );
int __attribute__((__cdecl__)) _execve (const char *__path, char * const __argv[], char * const __envp[] );
int __attribute__((__cdecl__)) getdtablesize (void);
int __attribute__((__cdecl__)) setdtablesize (int);
useconds_t __attribute__((__cdecl__)) ualarm (useconds_t __useconds, useconds_t __interval);
unsigned __attribute__((__cdecl__)) usleep (unsigned int __useconds);
int __attribute__((__cdecl__)) ftruncate (int __fd, off_t __length);
int __attribute__((__cdecl__)) truncate (const char *, off_t __length);
int __attribute__((__cdecl__)) gethostname (char *__name, size_t __len);
char * __attribute__((__cdecl__)) mktemp (char *);
int __attribute__((__cdecl__)) sync (void);
int __attribute__((__cdecl__)) readlink (const char *__path, char *__buf, int __buflen);
int __attribute__((__cdecl__)) symlink (const char *__name1, const char *__name2);
# 159 "/usr/include/sys/unistd.h" 3
# 1 "/usr/include/sys/features.h" 1 3
# 160 "/usr/include/sys/unistd.h" 2 3
# 7 "/usr/include/unistd.h" 2 3
# 1 "/usr/include/getopt.h" 1 3
# 41 "/usr/include/getopt.h" 3
extern int opterr;
extern int optind;
extern int optopt;
extern int optreset;
extern char *optarg;
int getopt (int, char * const *, const char *);
# 9 "/usr/include/unistd.h" 2 3
# 29 "utility.c" 2
# 1 "/usr/include/sys/types.h" 1 3
# 30 "utility.c" 2
# 47 "utility.c"
# 1 "/usr/include/sys/ioctl.h" 1 3
# 16 "/usr/include/sys/ioctl.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 17 "/usr/include/sys/ioctl.h" 2 3
# 26 "/usr/include/sys/ioctl.h" 3
int ioctl (int __fd, int __cmd, ...);
# 48 "utility.c" 2
# 164 "utility.c"
int CheckInput(void) {
_types_fd_set readfds;
struct timeval tv;
int data;
if (!xboard && !ics && !isatty(fileno((_impure_ptr->_stdin)))) return(0);
if (batch_mode) return(0);
if (strchr(cmd_buffer,'\n')) return(1);
(__extension__ (void)({ size_t __i; char *__tmp = (char *)&readfds; for (__i = 0; __i < sizeof (*(&readfds)); ++__i) *__tmp++ = 0; }));
((&readfds)->fds_bits[(fileno((_impure_ptr->_stdin)))/(sizeof (fd_mask) * 8)] |= (1L << ((fileno((_impure_ptr->_stdin))) % (sizeof (fd_mask) * 8))));
tv.tv_sec=0;
tv.tv_usec=0;
select(16, &readfds, 0, 0, &tv);
data=((&readfds)->fds_bits[(fileno((_impure_ptr->_stdin)))/(sizeof (fd_mask) * 8)] & (1L << ((fileno((_impure_ptr->_stdin))) % (sizeof (fd_mask) * 8))));
return(data);
}
void ClearHashTableScores(void) {
int i;
if (trans_ref_a && trans_ref_b) {
for (i=0;i<hash_table_size;i++) {
int age=(trans_ref_a+i)->word1>>61;
if (age) {
(trans_ref_a+i)->word2^=(trans_ref_a+i)->word1;
(trans_ref_a+i)->word1=((trans_ref_a+i)->word1 &
mask_clear_entry) | (BITBOARD) 65536;
(trans_ref_a+i)->word2^=(trans_ref_a+i)->word1;
}
}
for (i=0;i<2*hash_table_size;i++) {
(trans_ref_b+i)->word2^=(trans_ref_b+i)->word1;
(trans_ref_b+i)->word1=((trans_ref_b+i)->word1 &
mask_clear_entry) | (BITBOARD) 65536;
(trans_ref_b+i)->word2^=(trans_ref_b+i)->word1;
}
for (i=0;i<pawn_hash_table_size;i++) {
(pawn_hash_table+i)->key=0;
(pawn_hash_table+i)->p_score=0;
(pawn_hash_table+i)->protected=0;
(pawn_hash_table+i)->black_defects_k=0;
(pawn_hash_table+i)->black_defects_q=0;
(pawn_hash_table+i)->white_defects_k=0;
(pawn_hash_table+i)->white_defects_q=0;
(pawn_hash_table+i)->passed_w=0;
(pawn_hash_table+i)->passed_w=0;
(pawn_hash_table+i)->outside=0;
(pawn_hash_table+i)->candidates_w=0;
(pawn_hash_table+i)->candidates_b=0;
}
}
local[0]->pawn_score.key=0;
}
void DelayTime(int ms) {
int oldt, newt;
oldt=ReadClock(elapsed);
do {
newt=ReadClock(elapsed);
} while (newt-ms/10 < oldt);
}
void DisplayBitBoard(BITBOARD board) {
int i,j,x;
for(i=7;i>=0;i--) {
printf(" %2d ",i*8);
x=board&255;
board>>=8;
for(j=128;j>0;j=j>>1)
if(x & j)
printf("X ");
else
printf("- ");
printf("\n");
}
}
# 258 "utility.c"
void DisplayChessBoard(FILE *display_file, POSITION pos) {
int display_board[64];
static const char display_string[] =
{"*Q\0*R\0*B\0 \0*K\0*N\0*P\0 \0P \0N \0K \0 \0B \0R \0Q \0"};
int i,j;
# 271 "utility.c"
for(i=0;i<64;i++) display_board[i]=(pos.board[i]+7)*3;
# 280 "utility.c"
fprintf(display_file,"\n +---+---+---+---+---+---+---+---+\n");
for(i=7;i>=0;i--) {
fprintf(display_file," %2d ",i+1);
for(j=0;j<8;j++)
fprintf(display_file,"| %s",&display_string[display_board[i*8+j]]);
fprintf(display_file,"|\n");
fprintf(display_file," +---+---+---+---+---+---+---+---+\n");
}
fprintf(display_file," a b c d e f g h\n\n");
}
char* DisplayEvaluation(int value, int wtm) {
static char out[10];
int tvalue;
tvalue=(wtm) ? value : -value;
if (abs(value) < 32768 -300)
sprintf(out,"%7.2f",((float) tvalue)/100.0);
else if (abs(value) > 32768) {
if (tvalue < 0) sprintf(out," -infnty");
else sprintf(out," +infnty");
}
else if (value==32768 -2 && wtm) sprintf(out," Mate");
else if (value==32768 -2 && !wtm) sprintf(out," -Mate");
else if (value==-(32768 -1) && wtm) sprintf(out," -Mate");
else if (value==-(32768 -1) && !wtm) sprintf(out," Mate");
else if (value>0 && wtm) sprintf(out," Mat%.2d",(32768 -value)/2);
else if (value>0 && !wtm) sprintf(out," -Mat%.2d",(32768 -value)/2);
else if (wtm) sprintf(out," -Mat%.2d",(32768 -abs(value))/2);
else sprintf(out," Mat%.2d",(32768 -abs(value))/2);
return(out);
}
char* DisplayEvaluationWhisper(int value, int wtm) {
static char out[10];
int tvalue;
tvalue=(wtm) ? value : -value;
if (abs(value) < 32768 -300)
sprintf(out,"%+.2f",((float) tvalue)/100.0);
else if (abs(value) > 32768) {
if (tvalue < 0) sprintf(out,"-infnty");
else sprintf(out,"+infnty");
}
else if (value==32768 -2 && wtm) sprintf(out,"Mate");
else if (value==32768 -2 && !wtm) sprintf(out,"-Mate");
else if (value==-(32768 -1) && wtm) sprintf(out,"-Mate");
else if (value==-(32768 -1) && !wtm) sprintf(out,"Mate");
else if (value>0 && wtm) sprintf(out,"Mat%.2d",(32768 -value)/2);
else if (value>0 && !wtm) sprintf(out,"-Mat%.2d",(32768 -value)/2);
else if (wtm) sprintf(out,"-Mat%.2d",(32768 -abs(value))/2);
else sprintf(out,"Mat%.2d",(32768 -abs(value))/2);
return(out);
}
void DisplayPieceBoards(signed char *white, signed char *black) {
int i,j;
printf(" white ");
printf(" black\n");
for (i=7;i>=0;i--) {
for (j=i*8;j<i*8+8;j++) printf("%4d ",white[j]);
printf(" ");
for (j=i*8;j<i*8+8;j++) printf("%4d ",black[j]);
printf("\n");
}
}
# 357 "utility.c"
void DisplayPV(TREE *tree, int level, int wtm, int time, int value, PATH *pv) {
char buffer[512], *buffp, *bufftemp;
int i, t_move_number, type, j, dummy;
int nskip=0, twtm=wtm;
root_print_ok=root_print_ok || tree->nodes_searched>noise_level ||
abs(value)>32768 -300;
# 374 "utility.c"
if (level==5) type=4; else type=2;
t_move_number=move_number;
if (display_options&64) sprintf(buffer," %d.",move_number);
else buffer[0]=0;
if ((display_options&64) && !wtm) sprintf(buffer+strlen(buffer)," ...");
for (i=1;i<=(int) pv->pathl;i++) {
if ((display_options&64) && i>1 && wtm)
sprintf(buffer+strlen(buffer)," %d.",t_move_number);
sprintf(buffer+strlen(buffer)," %s",OutputMove(tree,pv->path[i],i,wtm));
MakeMove(tree,i,pv->path[i],wtm);
wtm=((wtm)^1);
if (wtm) t_move_number++;
}
# 397 "utility.c"
if(pv->pathh == 1) {
for (i=pv->pathl+1;i<65;i++) {
HashProbe(tree,i,0,wtm,&dummy,&dummy,&dummy);
if (tree->hash_move[i] && LegalMove(tree,i,wtm,tree->hash_move[i])) {
pv->path[i]=tree->hash_move[i];
for (j=1;j<i;j++)
if (pv->path[i] == pv->path[j]) break;
if (j < i) break;
pv->pathl++;
if ((display_options&64) && wtm)
sprintf(buffer+strlen(buffer)," %d.",t_move_number);
sprintf(buffer+strlen(buffer)," %s",OutputMove(tree,pv->path[i],i,wtm));
MakeMove(tree,i,pv->path[i],wtm);
}
else break;
wtm=((wtm)^1);
if (wtm) t_move_number++;
}
sprintf(buffer+strlen(buffer)," <HT>");
}
else if(pv->pathh == 2)
sprintf(buffer+strlen(buffer)," <EGTB>");
strcpy(whisper_text,buffer);
if (root_print_ok) {
if (nskip <= 1)
Print(type," ");
else
Print(type," (%1d) ",nskip);
if (level==6)
Print(type,"%2i %s%s ",iteration_depth,
DisplayTime(time),DisplayEvaluation(value,twtm));
else
Print(type,"%2i-> %s%s ",iteration_depth,
DisplayTime(time),DisplayEvaluation(value,twtm));
buffp=buffer+1;
do {
if ((int) strlen(buffp) > 34)
bufftemp=strchr(buffp+34,' ');
else
bufftemp=0;
if (bufftemp) *bufftemp=0;
Print(type,"%s\n",buffp);
buffp=bufftemp+1;
if (bufftemp) Print(type," ");
} while(bufftemp);
Whisper(level,twtm,iteration_depth,end_time-start_time,value,
tree->nodes_searched,0,tree->egtb_probes_successful,
whisper_text);
}
for (i=pv->pathl;i>0;i--) {
wtm=((wtm)^1);
UnMakeMove(tree,i,pv->path[i],wtm);
}
}
char* DisplaySQ(unsigned int sq) {
static char out[3];
out[0]=(((sq)&63) & 7)+'a';
out[1]=(((sq)&63) / 8)+'1';
out[2]=0;
return(out);
}
char* DisplayHHMM(unsigned int time) {
static char out[10];
time=time/6000;
sprintf(out,"%3u:%02u", time/60, time%60);
return(out);
}
char* DisplayTime(unsigned int time) {
static char out[10];
if (time < 6000) sprintf(out,"%6.2f",(float) time/100.0);
else {
time=time/100;
sprintf(out,"%3u:%02u", time/60, time%60);
}
return(out);
}
char* DisplayTimeWhisper(unsigned int time) {
static char out[10];
if (time < 6000) sprintf(out,"%.2f",(float) time/100.0);
else {
time=time/100;
sprintf(out,"%u:%02u", time/60, time%60);
}
return(out);
}
void DisplayTreeState(TREE *tree, int sply, int spos, int maxply) {
int left, i, *mvp, parallel=0;
char buf[1024];
buf[0]=0;
if (sply == 1) {
left=0;
for (i=0;i<n_root_moves;i++)
if (!(root_moves[i].status&128)) left++;
sprintf(buf,"%d:%d/%d ",1,left,n_root_moves);
}
else {
for (i=0;i<spos-6;i++) sprintf(buf+strlen(buf)," ");
sprintf(buf+strlen(buf),"[p%2d] ",tree->thread_id);
}
for (i=(((sply) > (2)) ? (sply) : (2));i<=maxply;i++) {
left=0;
for (mvp=tree->last[i-1];mvp<tree->last[i];mvp++)
if (*mvp) left++;
sprintf(buf+strlen(buf),"%d:%d/%d ",i,left,tree->last[i]-tree->last[i-1]);
if (!(i%8)) sprintf(buf+strlen(buf),"\n");
if (tree->nprocs>1 && tree->ply==i) {
parallel=strlen(buf);
break;
}
if (sply > 1) break;
}
printf("%s\n",buf);
if (sply == 1 && tree->nprocs) {
for (i=0;i<max_threads;i++) if (tree->siblings[i])
DisplayTreeState(tree->siblings[i], tree->ply+1,parallel, maxply);
}
}
void Display64bitWord(BITBOARD word) {
printf("%08x%08x\n",(int)(word>>32),(int)word);
}
void Display2BitBoards(BITBOARD board1, BITBOARD board2) {
int i,j,x,y;
for(i=7;i>=0;i--) {
printf(" %2d ",i*8);
x=board1&255;
board1>>=8;
for(j=128;j>0;j=j>>1)
if(x & j) printf("X ");
else printf("- ");
printf(" %2d ",i*8);
y=board2&255;
board2>>=8;
for(j=128;j>0;j=j>>1)
if(y & j) printf("X ");
else printf("- ");
printf("\n");
}
}
# 556 "utility.c"
void EGTBPV(TREE *tree, int wtm) {
int moves[1024], current[256];
BITBOARD hk[1024], phk[1024];
char buffer[16384], *next;
BITBOARD pos[1024];
int value;
register int ply, i, j, nmoves, *last, t_move_number;
register int best=0, bestmv=0, optimal_mv=0;
register int bang=0, legal;
if (!strcmp(args[1],"!")) bang=1;
# 574 "utility.c"
if (!EGTB_setup) return;
if(!EGTBProbe(tree, 1, wtm, &value)) return;
t_move_number=move_number;
if (display_options&64) sprintf(buffer,"%d.",move_number);
else buffer[0]=0;
if ((display_options&64) && !wtm) sprintf(buffer+strlen(buffer)," ...");
# 592 "utility.c"
for (ply=1;ply<1024;ply++) {
pos[ply]=(tree->pos.hash_key);
last=GenerateCaptures(tree, 1, wtm, current);
last=GenerateNonCaptures(tree, 1, wtm, last);
nmoves=last-current;
best=-32768 -1;
legal=0;
for (i=0;i<nmoves;i++) {
MakeMove(tree,1,current[i],wtm);
if (!Attacked(tree, (wtm)?(tree->pos.white_king):(tree->pos.black_king),((wtm)^1))) {
legal++;
if((tree->pos.total_pieces)==2 || EGTBProbe(tree, 2, ((wtm)^1), &value)) {
if ((tree->pos.total_pieces) > 2) value=-value;
else value=(draw_score[wtm]);
if (value > best) {
best=value;
bestmv=current[i];
optimal_mv=1;
}
else if (value == best) optimal_mv=0;
}
}
UnMakeMove(tree,1,current[i],wtm);
}
if (best > -32768 -1) {
moves[ply]=bestmv;
if ((display_options&64) && ply>1 && wtm)
sprintf(buffer+strlen(buffer)," %d.",t_move_number);
sprintf(buffer+strlen(buffer)," %s",OutputMove(tree,bestmv,1,wtm));
if (!strchr(buffer,'#') && bang &&
legal>1 && optimal_mv) sprintf(buffer+strlen(buffer),"!");
hk[ply]=(tree->pos.hash_key);
phk[ply]=(tree->pos.pawn_hash_key);
MakeMove(tree,1,bestmv,wtm);
tree->position[1]=tree->position[2];
wtm=((wtm)^1);
for (j=2-(ply&1);j<ply;j+=2)
if (pos[ply] == pos[j]) break;
if (j < ply) break;
if (wtm) t_move_number++;
if (strchr(buffer,'#')) break;
}
else {
ply--;
break;
}
}
nmoves=ply;
for (;ply>0;ply--) {
wtm=((wtm)^1);
tree->save_hash_key[1]=hk[ply];
tree->save_pawn_hash_key[1]=phk[ply];
UnMakeMove(tree,1,moves[ply],wtm);
tree->position[2]=tree->position[1];
}
next=buffer;
while (nmoves) {
if (strlen(next) > 72) {
int i;
for (i=0;i<16;i++)
if (*(next+64+i) == ' ') break;
*(next+64+i)=0;
printf("%s\n",next);
next+=64+i+1;
}
else {
printf("%s\n",next);
break;
}
}
}
void DisplayChessMove(char *title, int move) {
Print(4095,"%s piece=%d, from=%d, to=%d, captured=%d, promote=%d\n",
title,(((move)>>12)&7),((move)&63), (((move)>>6)&63),(((move)>>15)&7),
(((move)>>18)&7));
}
# 679 "utility.c"
char *FormatPV(TREE *tree, int wtm, PATH pv) {
static char buffer[512];
int i, t_move_number;
t_move_number=move_number;
if (display_options&64) sprintf(buffer," %d.",move_number);
else buffer[0]=0;
if ((display_options&64) && !wtm) sprintf(buffer+strlen(buffer)," ...");
for (i=1;i<=(int) pv.pathl;i++) {
if ((display_options&64) && i>1 && wtm)
sprintf(buffer+strlen(buffer)," %d.",t_move_number);
sprintf(buffer+strlen(buffer)," %s",OutputMove(tree,pv.path[i],i,wtm));
MakeMove(tree,i,pv.path[i],wtm);
wtm=((wtm)^1);
if (wtm) t_move_number++;
}
for (i=pv.pathl;i>0;i--) {
wtm=((wtm)^1);
UnMakeMove(tree,i,pv.path[i],wtm);
}
return (buffer);
}
unsigned int ReadClock(TIME_TYPE type) {
struct tms t;
struct timeval timeval;
struct timezone timezone;
BITBOARD cputime=0;
switch (type) {
case cpu:
(void) times(&t);
cputime=t.tms_utime+t.tms_stime+t.tms_cutime+t.tms_cstime;
cputime=cputime*100/1000;
return((unsigned int) cputime);
case elapsed:
gettimeofday(&timeval, &timezone);
return(timeval.tv_sec*100+(timeval.tv_usec/10000));
default:
gettimeofday(&timeval, &timezone);
return(timeval.tv_sec*100+(timeval.tv_usec/10000));
# 755 "utility.c"
}
}
# 786 "utility.c"
int HasOpposition(int on_move, int white_king, int black_king) {
register int file_distance, rank_distance;
file_distance=abs(((white_king)&7) - ((black_king)&7));
rank_distance=abs(((white_king)>>3) - ((black_king)>>3));
if (rank_distance < 2) return(1);
if (on_move) {
if (rank_distance&1) {
rank_distance--;
if (file_distance&1) file_distance--;
}
else if (file_distance&1) {
file_distance--;
if (rank_distance&1) rank_distance--;
}
}
if (!(file_distance&1) && !(rank_distance&1)) return(1);
if (!(file_distance&1) && !(rank_distance&1)) return(1);
return(0);
}
# 815 "utility.c"
BITBOARD InterposeSquares(int check_direction, int king_square,
int checking_square) {
register BITBOARD target;
# 828 "utility.c"
switch (check_direction) {
case +1:
target=plus1dir[king_square-1] ^ plus1dir[checking_square];
break;
case +7:
target=plus7dir[king_square-7] ^ plus7dir[checking_square];
break;
case +8:
target=plus8dir[king_square-8] ^ plus8dir[checking_square];
break;
case +9:
target=plus9dir[king_square-9] ^ plus9dir[checking_square];
break;
case -1:
target=minus1dir[king_square+1] ^ minus1dir[checking_square];
break;
case -7:
target=minus7dir[king_square+7] ^ minus7dir[checking_square];
break;
case -8:
target=minus8dir[king_square+8] ^ minus8dir[checking_square];
break;
case -9:
target=minus9dir[king_square+9] ^ minus9dir[checking_square];
break;
default:
target=0;
break;
}
return(target);
}
int KingPawnSquare(int pawn, int king, int queen, int ptm) {
register int pdist, kdist;
pdist=abs((pawn>>3)-(queen>>3));
kdist=(abs((king>>3)-(queen>>3)) > abs((king&7)-(queen&7))) ?
abs((king>>3)-(queen>>3)) : abs((king&7)-(queen&7));
if (!ptm) pdist++;
if (pdist < kdist) return(0);
else return(1);
}
# 879 "utility.c"
void NewGame(int save) {
char filename[64];
static int save_book_selection_width=5;
static int save_whisper=0, save_kibitz=0, save_channel=0;
static int save_resign=0, save_resign_count=0, save_draw_count=0;
static int save_learning=0;
static int save_accept_draws=0;
TREE * const tree=local[0];
new_game=0;
if (save) {
save_book_selection_width=book_selection_width;
save_whisper=whisper;
save_kibitz=kibitz;
save_channel=channel;
save_resign=resign;
save_resign_count=resign_count;
save_draw_count=draw_count;
save_learning=learning;
save_accept_draws=accept_draws;
}
else {
if (learning&book_learning && moves_out_of_book) {
int val=(crafty_is_white)?last_search_value:-last_search_value;
LearnBook(tree,crafty_is_white,val,0,0,1);
}
if (ics) printf("*whisper Hello from Crafty v%s !\n",version);
if (xboard) {
printf("tellics set 1 Crafty v%s (%d cpus)\n",
version,(((1) > (max_threads)) ? (1) : (max_threads)));
}
over=0;
moves_out_of_book=0;
ponder_move=0;
last_search_value=0;
last_pv.pathd=0;
last_pv.pathl=0;
strcpy(initial_position,"");
InitializeChessBoard(&tree->position[0]);
InitializeHashTables();
force=0;
trojan_check=0;
computer_opponent=0;
books_file=normal_bs_file;
draw_score[0]=0;
draw_score[1]=0;
wtm=1;
move_number=1;
tc_time_remaining=tc_time;
tc_time_remaining_opponent=tc_time;
tc_moves_remaining=tc_moves;
if (move_actually_played) {
if (log_file) fclose(log_file);
if (history_file) fclose(history_file);
if (log_file) {
if (log_id < 299) log_id++;
sprintf(filename,"%s/log.%03d",log_path,log_id);
log_file=fopen(filename,"w+");
}
sprintf(filename,"%s/game.%03d",log_path,log_id);
history_file=fopen(filename,"w+");
}
move_actually_played=0;
book_selection_width=save_book_selection_width;
whisper=save_whisper;
kibitz=save_kibitz;
channel=save_channel;
resign=save_resign;
resign_count=save_resign_count;
resign_counter=0;
draw_count=save_draw_count;
accept_draws=save_accept_draws;
draw_counter=0;
usage_level=0;
learning=save_learning;
largest_positional_score=100;
predicted=0;
whisper_depth=0;
tree->nodes_searched=0;
tree->fail_high=0;
tree->fail_high_first=0;
cpu_percent=0;
whisper_text[0]=0;
}
}
char* Normal(void) {
if (ansi) {
return("\033[0m");
}
return("");
}
int ParseTime(char* string) {
int time=0;
int minutes=0;
while (*string) {
switch (*string) {
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
case '6':
case '7':
case '8':
case '9':
minutes=minutes*10+(*string)-'0';
break;
case ':':
time=time*60+minutes;
minutes=0;
break;
default: Print(4095,"illegal character in time, please re-enter\n");
break;
}
string++;
}
return(time*60+minutes);
}
void Pass(void) {
char buffer[128];
const int halfmoves_done=2*(move_number-1)+(1-wtm);
int prev_pass=0;
if (halfmoves_done>0) {
fseek(history_file,(halfmoves_done-1)*10,0);
if (fscanf(history_file,"%s",buffer)==0 || strcmp(buffer,"pass")==0) {
prev_pass=1;
}
}
if (prev_pass) {
if (wtm) move_number--;
} else {
fseek(history_file,halfmoves_done*10,0);
fprintf(history_file,"%9s\n","pass");
if (!wtm) move_number++;
}
wtm=((wtm)^1);
}
# 1053 "utility.c"
int PinnedOnKing(TREE *tree, int wtm, int square) {
register int ray;
if (wtm) {
# 1064 "utility.c"
ray=directions[square][(tree->pos.white_king)];
if (!ray) return(0);
# 1076 "utility.c"
switch (abs(ray)) {
case 1:
if (AttacksRankFunc(square,&tree->pos) & ((set_mask[tree->pos.white_king])))
return((AttacksRankFunc(square,&tree->pos) & (tree->pos.rooks_queens) & (tree->pos.b_occupied)) != 0);
else return(0);
case 7:
if (AttacksDiaga1Func(&diag_info[square],&tree->pos) & ((set_mask[tree->pos.white_king])))
return((AttacksDiaga1Func(&diag_info[square],&tree->pos) & (tree->pos.bishops_queens) & (tree->pos.b_occupied)) != 0);
else return(0);
case 8:
if (AttacksFileFunc(square,&tree->pos) & ((set_mask[tree->pos.white_king])))
return((AttacksFileFunc(square,&tree->pos) & (tree->pos.rooks_queens) & (tree->pos.b_occupied)) != 0);
else return(0);
case 9:
if (AttacksDiagh1Func(&diag_info[square],&tree->pos) & ((set_mask[tree->pos.white_king])))
return((AttacksDiagh1Func(&diag_info[square],&tree->pos) & (tree->pos.bishops_queens) & (tree->pos.b_occupied)) != 0);
else return(0);
}
}
else {
# 1104 "utility.c"
ray=directions[(tree->pos.black_king)][square];
if (!ray) return(0);
# 1116 "utility.c"
switch (abs(ray)) {
case 1:
if (AttacksRankFunc(square,&tree->pos) & ((set_mask[tree->pos.black_king])))
return((AttacksRankFunc(square,&tree->pos) & (tree->pos.rooks_queens) & (tree->pos.w_occupied)) != 0);
else return(0);
case 7:
if (AttacksDiaga1Func(&diag_info[square],&tree->pos) & ((set_mask[tree->pos.black_king])))
return((AttacksDiaga1Func(&diag_info[square],&tree->pos) & (tree->pos.bishops_queens) & (tree->pos.w_occupied)) != 0);
else return(0);
case 8:
if (AttacksFileFunc(square,&tree->pos) & ((set_mask[tree->pos.black_king])))
return((AttacksFileFunc(square,&tree->pos) & (tree->pos.rooks_queens) & (tree->pos.w_occupied)) != 0);
else return(0);
case 9:
if (AttacksDiagh1Func(&diag_info[square],&tree->pos) & ((set_mask[tree->pos.black_king])))
return((AttacksDiagh1Func(&diag_info[square],&tree->pos) & (tree->pos.bishops_queens) & (tree->pos.w_occupied)) != 0);
else return(0);
}
}
return(0);
}
void Print(int vb, char *fmt, ...) {
va_list ap;
__builtin_stdarg_start((ap),fmt);
if (vb&display_options) vprintf(fmt, ap);
fflush((_impure_ptr->_stdout));
if (time_limit>99 || tc_time_remaining>6000 || vb==4095) {
if (log_file) vfprintf(log_file, fmt, ap);
if (log_file) fflush(log_file);
}
__builtin_va_end(ap);
}
# 1159 "utility.c"
unsigned int Random32(void) {
static const unsigned long x[55] = {
1410651636UL, 3012776752UL, 3497475623UL, 2892145026UL, 1571949714UL,
3253082284UL, 3489895018UL, 387949491UL, 2597396737UL, 1981903553UL,
3160251843UL, 129444464UL, 1851443344UL, 4156445905UL, 224604922UL,
1455067070UL, 3953493484UL, 1460937157UL, 2528362617UL, 317430674UL,
3229354360UL, 117491133UL, 832845075UL, 1961600170UL, 1321557429UL,
747750121UL, 545747446UL, 810476036UL, 503334515UL, 4088144633UL,
2824216555UL, 3738252341UL, 3493754131UL, 3672533954UL, 29494241UL,
1180928407UL, 4213624418UL, 33062851UL, 3221315737UL, 1145213552UL,
2957984897UL, 4078668503UL, 2262661702UL, 65478801UL, 2527208841UL,
1960622036UL, 315685891UL, 1196037864UL, 804614524UL, 1421733266UL,
2017105031UL, 3882325900UL, 810735053UL, 384606609UL, 2393861397UL };
static int init = 1;
static unsigned long y[55];
static int j, k;
unsigned long ul;
if (init)
{
int i;
init = 0;
for (i = 0; i < 55; i++) y[i] = x[i];
j = 24 - 1;
k = 55 - 1;
}
ul = (y[k] += y[j]);
if (--j < 0) j = 55 - 1;
if (--k < 0) k = 55 - 1;
return((unsigned int)ul);
}
BITBOARD Random64(void) {
BITBOARD result;
unsigned int r1, r2;
r1=Random32();
r2=Random32();
result=r1 | (BITBOARD) r2<<32;
return (result);
}
# 1217 "utility.c"
int Read(int wait, char *buffer) {
char *eol, *ret, readdata;
*buffer=0;
# 1229 "utility.c"
if (strchr(cmd_buffer,'\n'));
else if (!wait) {
if (CheckInput()) {
readdata=ReadInput();
if (!strchr(cmd_buffer,'\n')) return(0);
if (!readdata) return(-1);
}
else return(0);
}
else while (!strchr(cmd_buffer,'\n')) {
# 1270 "utility.c"
readdata=ReadInput();
if (!readdata) return(-1);
}
eol=strchr(cmd_buffer,'\n');
*eol=0;
ret=strchr(cmd_buffer,'\r');
if (ret) *ret=' ';
strcpy(buffer,cmd_buffer);
memmove(cmd_buffer,eol+1,strlen(eol+1)+1);
return(1);
}
# 1295 "utility.c"
void ReadClear() {
cmd_buffer[0]=0;
}
# 1309 "utility.c"
int ReadParse(char *buffer, char *args[], char *delims) {
char *next, tbuffer[512];
int nargs;
strcpy(tbuffer,buffer);
for (nargs=0;nargs<16;nargs++) *(args[nargs])=0;
next=strtok(tbuffer,delims);
if (!next) return(0);
strcpy(args[0],next);
for (nargs=1;nargs<32;nargs++) {
next=strtok(0,delims);
if (!next) break;
strcpy(args[nargs],next);
}
return(nargs);
}
# 1335 "utility.c"
int ReadInput(void) {
char buffer[512], *end;
int bytes;
# 1347 "utility.c"
do
bytes=read(fileno(input_stream),buffer,512);
while (bytes<0 && (*__errno())==4);
if (bytes == 0) {
if (input_stream != (_impure_ptr->_stdin)) fclose(input_stream);
input_stream=(_impure_ptr->_stdin);
return(0);
}
else if (bytes < 0) {
Print(4095,"ERROR! input I/O stream is unreadable, exiting.\n");
exit(1);
}
end=cmd_buffer+strlen(cmd_buffer);
memcpy(end,buffer,bytes);
*(end+bytes)=0;
return(1);
}
# 1376 "utility.c"
int ReadChessMove(TREE *tree, FILE *input, int wtm, int one_move) {
static char text[128];
char *tmove;
int move=0, status;
while (move == 0) {
status=fscanf(input,"%s",text);
if (status <= 0) return(-1);
if (strcmp(text,"0-0") && strcmp(text,"0-0-0"))
tmove=text+strspn(text,"0123456789.");
else
tmove=text;
if (((tmove[0]>='a' && tmove[0]<='z') ||
(tmove[0]>='A' && tmove[0]<='Z')) ||
!strcmp(tmove,"0-0") || !strcmp(tmove,"0-0-0")) {
if (!strcmp(tmove,"exit")) return(-1);
move=InputMove(tree,tmove,0,wtm,1,0);
}
if (one_move) break;
}
return(move);
}
# 1410 "utility.c"
int ReadNextMove(TREE *tree, char *text, int ply, int wtm) {
char *tmove;
int move=0;
if (strcmp(text,"0-0") && strcmp(text,"0-0-0"))
tmove=text+strspn(text,"0123456789./-");
else
tmove=text;
if (((tmove[0]>='a' && tmove[0]<='z') ||
(tmove[0]>='A' && tmove[0]<='Z')) ||
!strcmp(tmove,"0-0") || !strcmp(tmove,"0-0-0")) {
if (!strcmp(tmove,"exit")) return(-1);
move=InputMove(tree,tmove,ply,wtm,1,0);
}
return(move);
}
# 1440 "utility.c"
int ReadPGN(FILE *input, int option) {
static int data=0, lines_read=0;
static char input_buffer[512];
char temp[512], *eof, analysis_move[64];
int braces=0, parens=0, brackets=0, analysis=0, last_good_line;
# 1455 "utility.c"
pgn_suggested_percent=0;
if (!input) {
lines_read=0;
data=0;
return(0);
}
if (option==-1) data=0;
if (option==-2) return(lines_read);
# 1471 "utility.c"
while (1) {
if (!data) {
eof=fgets(input_buffer,512,input);
if (!eof) return(-1);
if (strchr(input_buffer,'\n')) *strchr(input_buffer,'\n')=0;
if (strchr(input_buffer,'\r')) *strchr(input_buffer,'\r')=' ';
lines_read++;
buffer[0]=0;
sscanf(input_buffer,"%s",buffer);
if (buffer[0] == '[') do {
char *bracket1, *bracket2, value[128];
strcpy(buffer,input_buffer);
bracket1=strchr(input_buffer,'\"');
if (bracket1 == 0) return(1);
bracket2=strchr(bracket1+1,'\"');
if (bracket2 == 0) return(1);
*bracket1=0;
*bracket2=0;
strcpy(value,bracket1+1);
if (strstr(input_buffer,"Event")) strcpy(pgn_event,value);
else if (strstr(input_buffer,"Site")) strcpy(pgn_site,value);
else if (strstr(input_buffer,"Round")) strcpy(pgn_round,value);
else if (strstr(input_buffer,"Date")) strcpy(pgn_date,value);
else if (strstr(input_buffer,"WhiteElo")) strcpy(pgn_white_elo,value);
else if (strstr(input_buffer,"White")) strcpy(pgn_white,value);
else if (strstr(input_buffer,"BlackElo")) strcpy(pgn_black_elo,value);
else if (strstr(input_buffer,"Black")) strcpy(pgn_black,value);
else if (strstr(input_buffer,"Result")) strcpy(pgn_result,value);
else if (strstr(input_buffer,"FEN")) {
sprintf(buffer,"setboard %s",value);
(void) Option(local[0]);
continue;
}
return(1);
} while(0);
data=1;
}
# 1518 "utility.c"
else {
buffer[0]=0;
sscanf(input_buffer,"%s",buffer);
if (strlen(buffer) == 0) {
data=0;
continue;
}
else {
char *skip;
strcpy(temp,input_buffer);
skip=strstr(input_buffer,buffer)+strlen(buffer);
if (skip) strcpy(input_buffer,skip);
}
# 1541 "utility.c"
last_good_line=lines_read;
analysis_move[0]=0;
if (strchr(buffer,'{') || strchr(buffer,'(')) while (1) {
char *skip, *ch;
analysis=1;
while ((ch=strpbrk(buffer,"(){}[]"))) {
if (*ch == '(') {
*strchr(buffer,'(')=' ';
if (!braces) parens++;
}
if (*ch == ')') {
*strchr(buffer,')')=' ';
if (!braces) parens--;
}
if (*ch == '{') {
*strchr(buffer,'{')=' ';
braces++;
}
if (*ch == '}') {
*strchr(buffer,'}')=' ';
braces--;
}
if (*ch == '[') {
*strchr(buffer,'[')=' ';
if (!braces) brackets++;
}
if (*ch == ']') {
*strchr(buffer,']')=' ';
if (!braces) brackets--;
}
}
if (analysis && analysis_move[0]==0) {
if (strspn(buffer," ") != strlen(buffer)) {
char *tmove=analysis_move;
sscanf(buffer,"%64s",analysis_move);
strcpy(buffer,analysis_move);
if (strcmp(buffer,"0-0") && strcmp(buffer,"0-0-0"))
tmove=buffer+strspn(buffer,"0123456789.");
else
tmove=buffer;
if ((tmove[0]>='a' && tmove[0]<='z') ||
(tmove[0]>='A' && tmove[0]<='Z') ||
!strcmp(tmove,"0-0") || !strcmp(tmove,"0-0-0"))
strcpy(analysis_move,buffer);
else
analysis_move[0]=0;
}
}
if (parens==0 && braces==0 && brackets==0) break;
buffer[0]=0;
sscanf(input_buffer,"%s",buffer);
if (strlen(buffer) == 0) {
eof=fgets(input_buffer,512,input);
if (!eof) {
parens=0;
braces=0;
brackets=0;
return(-1);
}
if (strchr(input_buffer,'\n')) *strchr(input_buffer,'\n')=0;
if (strchr(input_buffer,'\r')) *strchr(input_buffer,'\r')=' ';
lines_read++;
if (lines_read-last_good_line >= 100) {
parens=0;
braces=0;
brackets=0;
Print(4095,"ERROR. comment spans over 100 lines, starting at line %d\n",
last_good_line);
break;
}
}
strcpy(temp,input_buffer);
skip=strstr(input_buffer,buffer)+strlen(buffer);
strcpy(input_buffer,skip);
}
else {
int skip;
if ((skip=strspn(buffer,"0123456789."))) {
char temp[512];
strcpy(temp,buffer+skip);
strcpy(buffer,temp);
}
if (((_ctype_+1)[(unsigned)(buffer[0])]&(01|02)) || strchr(buffer,'-')) {
char *first, *last, *percent;
first=input_buffer+strspn(input_buffer," ");
if (first==0 || *first != '{') return(0);
last=strchr(input_buffer,'}');
if (last == 0) return(0);
percent=strstr(first,"play");
if (percent == 0) return(0);
pgn_suggested_percent=atoi(percent+4+strspn(percent+4," "));
return(0);
}
}
if (analysis_move[0] && option==1) {
strcpy(buffer,analysis_move);
return(2);
}
}
}
return(-1);
}
# 1654 "utility.c"
void RestoreGame(void) {
int i, move;
char cmd[16];
wtm=1;
InitializeChessBoard(&local[0]->position[0]);
for (i=0;i<500;i++) {
fseek(history_file,i*10,0);
strcpy(cmd,"");
fscanf(history_file,"%s",cmd);
if (strcmp(cmd,"pass")) {
move=InputMove(local[0],cmd,0,wtm,1,0);
if (move) MakeMoveRoot(local[0],move,wtm);
else break;
}
wtm=((wtm)^1);
}
Phase();
}
char* Reverse(void) {
if (ansi) {
return("\033[7m");
}
return("");
}
# 1751 "utility.c"
const unsigned char bishop_shift_rl45[64] = {
59, 57, 54, 50, 45, 39, 32, 0,
57, 54, 50, 45, 39, 32, 0, 8,
54, 50, 45, 39, 32, 0, 8, 15,
50, 45, 39, 32, 0, 8, 15, 21,
45, 39, 32, 0, 8, 15, 21, 60,
39, 32, 0, 8, 15, 21, 60, 26,
32, 0, 8, 15, 21, 60, 26, 29,
0, 8, 15, 21, 60, 26, 29, 31 };
const unsigned char bishop_shift_rr45[64] = {
0, 8, 15, 21, 60, 26, 29, 31,
32, 0, 8, 15, 21, 60, 26, 29,
39, 32, 0, 8, 15, 21, 60, 26,
45, 39, 32, 0, 8, 15, 21, 60,
50, 45, 39, 32, 0, 8, 15, 21,
54, 50, 45, 39, 32, 0, 8, 15,
57, 54, 50, 45, 39, 32, 0, 8,
59, 57, 54, 50, 45, 39, 32, 0 };
const unsigned char init_l45[64] = {
4, 5, 7, 10, 14, 19, 25, 56,
6, 8, 11, 15, 20, 26, 57, 49,
9, 12, 16, 21, 27, 58, 50, 43,
13, 17, 22, 28, 59, 51, 44, 38,
18, 23, 29, 60, 52, 45, 39, 0,
24, 30, 61, 53, 46, 40, 1, 35,
31, 62, 54, 47, 41, 2, 36, 33,
63, 55, 48, 42, 3, 37, 34, 32 };
const unsigned char init_r45[64] = {
56, 49, 43, 38, 0, 35, 33, 32,
25, 57, 50, 44, 39, 1, 36, 34,
19, 26, 58, 51, 45, 40, 2, 37,
14, 20, 27, 59, 52, 46, 41, 3,
10, 15, 21, 28, 60, 53, 47, 42,
7, 11, 16, 22, 29, 61, 54, 48,
5, 8, 12, 17, 23, 30, 62, 55,
4, 6, 9, 13, 18, 24, 31, 63 };
const unsigned char init_l90[64] = {
0, 8, 16, 24, 32, 40, 48, 56,
1, 9, 17, 25, 33, 41, 49, 57,
2, 10, 18, 26, 34, 42, 50, 58,
3, 11, 19, 27, 35, 43, 51, 59,
4, 12, 20, 28, 36, 44, 52, 60,
5, 13, 21, 29, 37, 45, 53, 61,
6, 14, 22, 30, 38, 46, 54, 62,
7, 15, 23, 31, 39, 47, 55, 63 };
const unsigned char n_attacks[9][8] =
{
{ 0 },
{ 1 },
{ 1, 1 },
{ 2, 1, 2 },
{ 3, 2, 2, 3 },
{ 4, 3, 4, 3, 4 },
{ 5, 4, 6, 6, 4, 5 },
{ 6, 5, 8, 9, 8, 5, 6 },
{ 7, 6, 10, 12, 12, 10, 6, 7}
};
const unsigned char n_length_attacks[9] =
{ 0, 1, 2, 5, 10, 18, 30, 47, 70 };
static struct gfile_info {
BITBOARD *bitboard;
unsigned char length;
unsigned char *map;
unsigned char *mobility;
unsigned char inc;
} gfiles[((7 + 1 + 7) + (7 + 1 + 7) + 1 + 1)];
static unsigned char diag_map [(7 + 1 + 7)] [8];
static unsigned char anti_diag_map [(7 + 1 + 7)] [8];
static unsigned char file_map [8];
static unsigned char rank_map [8];
# 1857 "utility.c"
static void InitializeMaps(BITBOARD *temp_rank_attack_bitboards) {
int file, rank;
int diag;
int gfile;
BITBOARD *b;
unsigned char *m;
unsigned char *mobility_for_length[9];
static const unsigned char diag_base [(7 + 1 + 7)] =
{ (((7)<<3) | (0)), (((6)<<3) | (0)), (((5)<<3) | (0)), (((4)<<3) | (0)), (((3)<<3) | (0)), (((2)<<3) | (0)), (((1)<<3) | (0)), (((0)<<3) | (0)),
(((0)<<3) | (1)), (((0)<<3) | (2)), (((0)<<3) | (3)), (((0)<<3) | (4)), (((0)<<3) | (5)), (((0)<<3) | (6)), (((0)<<3) | (7)) };
static const unsigned char anti_base[(7 + 1 + 7)] =
{ (((0)<<3) | (0)), (((0)<<3) | (1)), (((0)<<3) | (2)), (((0)<<3) | (3)), (((0)<<3) | (4)), (((0)<<3) | (5)), (((0)<<3) | (6)), (((0)<<3) | (7)),
(((1)<<3) | (7)), (((2)<<3) | (7)), (((3)<<3) | (7)), (((4)<<3) | (7)), (((5)<<3) | (7)), (((6)<<3) | (7)), (((7)<<3) | (7)) };
{
int i;
unsigned char *m = at.short_mobility;
for (i = 1; i < 8; i++) {
mobility_for_length[i] = m;
m += n_length_attacks[i];
}
mobility_for_length[8] = &at.length8_mobility[0][0];
}
gfile = 0;
b = diag_attack_bitboards;
for (diag = 0; diag < (7 + 1 + 7); diag++, gfile++) {
int sq = diag_base[diag];
const int len = (8 - ((((sq)>>3)&7) > ((sq)&7) ? (((sq)>>3)&7) - ((sq)&7) : ((sq)&7) - (((sq)>>3)&7)));
const int excess = 8 - len;
int i;
gfiles[gfile].length = len;
gfiles[gfile].map = diag_map[diag];
gfiles[gfile].bitboard = b;
gfiles[gfile].mobility = (diag < 7 ? mobility_for_length[len] : 0);
gfiles[gfile].inc = 0;
m = mobility_for_length[len];
for (i = 0; i < len; i++, sq += 9) {
diag_map[diag][i] = sq;
diag_info[sq].d_shift = bishop_shift_rr45[sq] + 1 - excess;
diag_info[sq].d_mask = (~((~0) << ((((len-2) > (0)) ? (len-2) : (0))))) << excess;
diag_info[sq].d_which_attack = &at.which_attack[i][0];
diag_info[sq].d_attacks = b;
b += n_attacks[len][i];
diag_info[sq].d_mobility = m;
m += (len == 8 ? 12 : n_attacks[len][i]);
}
}
b = anti_diag_attack_bitboards;
for (diag = 0; diag < (7 + 1 + 7); diag++, gfile++) {
int sq = anti_base[diag];
int len = (8 - ((((sq)>>3)&7) > ((~sq)&7) ? (((sq)>>3)&7) - ((~sq)&7) : ((~sq)&7) - (((sq)>>3)&7)));
int excess = 8 - len;
int i;
gfiles[gfile].length = len;
gfiles[gfile].map = anti_diag_map[diag];
gfiles[gfile].bitboard = b;
gfiles[gfile].mobility = 0;
gfiles[gfile].inc = 0;
m = mobility_for_length[len];
for (i = 0; i < len; i++, sq += 7) {
anti_diag_map[diag][i] = sq;
diag_info[sq].ad_shift = bishop_shift_rl45[sq] + 1 - excess;
diag_info[sq].ad_mask = (~((~0) << ((((len-2) > (0)) ? (len-2) : (0))))) << excess;
diag_info[sq].ad_which_attack = &at.which_attack[i][0];
diag_info[sq].ad_attacks = b;
b += n_attacks[len][i];
diag_info[sq].ad_mobility = m;
m += (len == 8 ? 12 : n_attacks[len][i]);
}
}
gfiles[gfile].length = 8;
gfiles[gfile].map = file_map;
gfiles[gfile].bitboard = &at.file_attack_bitboards[0][0];
gfiles[gfile].mobility = &at.length8_mobility[0][0];
gfiles[gfile].inc = 12;
for (rank = 0; rank < 8; rank++) file_map[rank] = (rank << 3) | 7;
gfile++;
gfiles[gfile].length = 8;
gfiles[gfile].map = rank_map;
gfiles[gfile].bitboard = temp_rank_attack_bitboards;
gfiles[gfile].mobility = 0;
gfiles[gfile].inc = 12;
for (file = 0; file < 8; file++) rank_map[file] = file | (7 << 3);
}
static void InitializeBrev (unsigned char brev[]) {
unsigned value;
for (value = 0; value < 64; value++) {
unsigned br = 0;
int i;
for (i = 0; i < 6; i++) br |= (((value >> i) & 1) << (5 - i));
brev[value] = br;
}
}
void ComputeAttacksAndMobility () {
BITBOARD temp_rank_attack_bitboards[8][12];
int attacks_seen[12];
int attacker;
unsigned g;
unsigned char brev[64];
InitializeMaps(&temp_rank_attack_bitboards[0][0]);
InitializeBrev(brev);
for (attacker = 0; attacker < 8; attacker++) {
unsigned attacks_found = 0;
unsigned gf;
memset ((char *)attacks_seen, 0, sizeof attacks_seen);
for (g = 0; g < 64; g++) {
int a, p, found;
unsigned lower, upper, attack;
const unsigned gfile_value = g << 1;
lower = 0;
for (p = attacker-1; p >= 0; p--) {
lower++;
if (gfile_value & (1 << p)) break;
}
upper = 0;
for (p = attacker+1; p < 8; p++) {
upper++;
if (gfile_value & (1 << p)) break;
}
attack = ((lower) | ((upper) << 3));
found = 0;
for (a=0; a<(int)attacks_found; a++)
if ((int)attack == attacks_seen[a]) {
found = 1;
break;
}
if (!found) {
int gf;
attacks_seen[attacks_found] = attack;
for (gf = 0; gf < ((7 + 1 + 7) + (7 + 1 + 7) + 1 + 1); gf++) {
const unsigned max_attacks = n_attacks[gfiles[gf].length][attacker];
if (attacks_found < max_attacks) {
BITBOARD b = 0;
int i, p;
for (p = attacker-1, i = 0; i < (int) lower; i++, p--)
b=(set_mask[gfiles[gf].map[p]])|(b);
for (p=attacker+1,i=0;(i<(int) upper) && (p<(int) gfiles[gf].length);
i++, p++)
b=(set_mask[gfiles[gf].map[p]])|(b);
if (gfiles[gf].mobility)
gfiles[gf].mobility[attacks_found] =
lower + ((((int) upper) < ((int) gfiles[gf].length - attacker - 1)) ? ((int) upper) : ((int) gfiles[gf].length - attacker - 1));
gfiles[gf].bitboard[attacks_found] = b;
}
}
attacks_found++;
}
at.which_attack[attacker][brev[g]] = a;
}
for (gf = 0; gf < ((7 + 1 + 7) + (7 + 1 + 7) + 1 + 1); gf++) {
const unsigned len = gfiles[gf].length;
const unsigned this_inc =
(gfiles[gf].inc ? gfiles[gf].inc : n_attacks[len][attacker]);
if ((unsigned) attacker < len) {
if (gfiles[gf].mobility) gfiles[gf].mobility += this_inc;
gfiles[gf].bitboard += this_inc;
}
}
}
{
int i, a;
for (i = 0; i < 8; i++)
for (a = 0; a < 12; a++)
at.rank_attack_bitboards[i][a]=
temp_rank_attack_bitboards[i][a] & 0xff;
}
}
# 2055 "utility.c"
void Whisper(int level,int wtm, int depth,int time,int value,
unsigned int nodes, int cpu, int tb_hits, char *pv) {
if (!puzzling) {
char prefix[128];
if (strlen(channel_title) && channel)
sprintf(prefix,"tell %d (%s) ",channel, channel_title);
else if (channel) sprintf(prefix,"tell %d",channel);
else sprintf(prefix,"whisper");
switch (level) {
case 1:
if (kibitz && (value > 0)) {
if (ics) printf("*");
printf("kibitz mate in %d moves.\n\n",value);
}
else if (whisper && (value > 0)) {
if (ics) printf("*");
printf("%s mate in %d moves.\n\n",prefix,value);
}
if (kibitz && (value < 0)) {
if (ics) printf("*");
printf("%s mated in %d moves.\n\n",prefix,-value);
}
break;
case 2:
if (kibitz >= 2) {
if (ics) printf("*");
printf("kibitz ply=%d; eval=%s; nps=%dk; time=%s; cpu=%d%%; egtb=%d\n",
depth,DisplayEvaluationWhisper(value,wtm),
(int) ((time)?100*(BITBOARD)nodes/(BITBOARD)time:nodes)/1000,
DisplayTimeWhisper(time),cpu,tb_hits);
}
else if (whisper >= 2) {
if (ics) printf("*");
printf("%s ply=%d; eval=%s; nps=%dk; time=%s; cpu=%d%%; egtb=%d\n",
prefix,depth,DisplayEvaluationWhisper(value,wtm),
(int) ((time)?100*(BITBOARD)nodes/(BITBOARD)time:nodes)/1000,
DisplayTimeWhisper(time),cpu,tb_hits);
}
case 3:
if ((kibitz >= 3) && (nodes>5000 || level==2)) {
if (ics) printf("*");
printf("kibitz %s\n",pv);
}
else if ((whisper >= 3) && (nodes>5000 || level==2)) {
if (ics) printf("*");
printf("%s %s\n",prefix,pv);
}
break;
case 4:
if (kibitz >= 4) {
if (ics) printf("*");
printf("kibitz %s\n",pv);
}
else if (whisper >= 4) {
if (ics) printf("*");
printf("%s %s\n",prefix,pv);
}
break;
case 5:
if (kibitz>=5 && nodes>5000) {
if (ics) printf("*");
printf("kibitz d%d-> %s %s %s\n",depth, DisplayTimeWhisper(time),
DisplayEvaluationWhisper(value,wtm),pv);
}
else if (whisper>=5 && nodes>5000) {
if (ics) printf("*");
printf("%s d%d-> %s %s %s\n",prefix,depth, DisplayTimeWhisper(time),
DisplayEvaluationWhisper(value,wtm),pv);
}
break;
case 6:
if (kibitz>=6 && nodes>5000) {
if (ics) printf("*");
if (cpu == 0)
printf("kibitz d%d+ %s %s %s\n",depth, DisplayTimeWhisper(time),
DisplayEvaluationWhisper(value,wtm),pv);
else
printf("kibitz d%d+ %s >(%s) %s <re-searching>\n",depth,
DisplayTimeWhisper(time),DisplayEvaluationWhisper(value,wtm),pv);
}
else if (whisper>=6 && nodes>5000) {
if (ics) printf("*");
if (cpu == 0)
printf("%s d%d+ %s %s %s\n",prefix,depth, DisplayTimeWhisper(time),
DisplayEvaluationWhisper(value,wtm),pv);
else
printf("%s d%d+ %s >(%s) %s <re-searching>\n",prefix,depth,
DisplayTimeWhisper(time),DisplayEvaluationWhisper(value,wtm),pv);
}
break;
}
value=(wtm)?value:-value;
if (post && level>1) {
if (strstr(pv,"book"))
printf(" %2d %5d %7d %6u %s\n",depth,value,time,nodes,pv+10);
else
printf(" %2d %5d %7d %6u %s\n",depth,value,time,nodes,pv);
}
fflush((_impure_ptr->_stdout));
}
}
# 2280 "utility.c"
int LegalMove(TREE *tree, int ply, int wtm, int move) {
int moves[220], *mv, *mvp;
if (move == 0) return(0);
tree->position[65]=tree->position[ply];
mvp=GenerateCaptures(tree,65, wtm, moves);
mvp=GenerateNonCaptures(tree,65, wtm, mvp);
for (mv=&moves[0];mv<mvp;mv++) {
MakeMove(tree,65, *mv, wtm);
if (!Attacked(tree, (wtm)?(tree->pos.white_king):(tree->pos.black_king),((wtm)^1)) && move==*mv) {
UnMakeMove(tree,65, *mv, wtm);
return(1);
}
UnMakeMove(tree,65, *mv, wtm);
}
return(0);
}
# 2308 "utility.c"
int StrCnt(char *string, char testchar) {
int count=0, i;
for (i=0;i<strlen(string);i++) if (string[i] == testchar) count++;
return(count);
}