From 98b5f4a19be517f7f4a5065f4b948bf6c3d5a04f Mon Sep 17 00:00:00 2001 From: "Martin M. S. Pedersen" Date: Thu, 9 Apr 2020 14:41:51 +0200 Subject: [PATCH] clean-up source --- Makefile | 202 ----------- chess.h | 650 ---------------------------------- crafty.hlp | 996 ----------------------------------------------------- data.h | 366 -------------------- epd.h | 144 -------- epddefs.h | 636 ---------------------------------- epdglue.h | 29 -- evaluate.h | 387 --------------------- lock.h | 86 ----- speak | 85 ----- tbconfig.h | 111 ------ tbcore.h | 170 --------- tbprobe.h | 289 ---------------- vcinline.h | 20 -- 14 files changed, 4171 deletions(-) delete mode 100644 Makefile delete mode 100644 chess.h delete mode 100644 crafty.hlp delete mode 100644 data.h delete mode 100644 epd.h delete mode 100644 epddefs.h delete mode 100644 epdglue.h delete mode 100644 evaluate.h delete mode 100644 lock.h delete mode 100644 speak delete mode 100644 tbconfig.h delete mode 100644 tbcore.h delete mode 100644 tbprobe.h delete mode 100644 vcinline.h diff --git a/Makefile b/Makefile deleted file mode 100644 index 3f5e7f8..0000000 --- a/Makefile +++ /dev/null @@ -1,202 +0,0 @@ -# To build crafty: -# -# You want to set up for maximum optimization, but typically you will -# need to experiment to see which options provide the fastest code. The -# following option descriptions explain each option. To use one or more -# of these options, to the "opt =" line that follows the explanations and -# add the options you want, being careful to stay inside the single quote -# marks. -# -# -DAFFINITY Include code to set processor/thread affinity on Unix -# systems. Note this will not work on Apple OS X as it does -# not support any sort of processor affinity mechanism. -# WARNING: know what you are doing before using this. If -# you test multiple copies of Crafty (each copy using just -# one thread) you can have bogus results because if compiled -# with -DAFFINITY, even a single-cpu execution will lock led -# itself onto processor zero (since it only has thread #0) -# which is probably NOT what you want. This is intended to -# be used when you run Crafty using a complete dedicated -# machine with nothing else running at the same time. -# -DBOOKDIR Path to the directory containing the book binary files. -# The default for all such path values is "." if you don't -# specify a path with this macro definition. -# -DCPUS=n Defines the maximum number of CPUS Crafty will be able -# to use in a SMP system. Note that this is the max you -# will be able to use. You need to use the smpmt=n command -# to make crafty use more than the default 1 process. -# -DDEBUG This is used for testing changes. Enabling this option -# greatly slows Crafty down, but every time a move is made, -# the corresponding position is checked to make sure all of -# the bitboards are set correctly. -# -DEPD If you want full EPD support built in. -# -DLOGDIR Path to the directory where Crafty puts the log.nnn and -# game.nnn files. -# -DNODES This enables the sn=x command. Crafty will search until -# exactly X nodes have been searched, then the search -# terminates as if time ran out. -# -DPOSITIONS Causes Crafty to emit FEN strings, one per book line, as -# it creates a book. I use this to create positions to use -# for cluster testing. -# -DRCDIR Path to the directory where we look for the .craftyrc or -# crafty.rc (windows) file. -# -DSKILL Enables the "skill" command which allows you to arbitrarily -# lower Crafty's playing skill so it does not seem so -# invincible to non-GM-level players. -# -DSYZYGY This enables syzygy endgame tables (both WDL and DTC) -# -DTBDIR Path to the directory where the endgame tablebase files -# are found. default = "./TB" -# -DTEST Displays evaluation table after each move (in the logfile) -# -DTRACE This enables the "trace" command so that the search tree -# can be dumped while running. -# -DUNIX This identifies the target O/S as being Unix-based, if this -# option is omitted, windows is assumed. -# -# Note: If you compile on a machine with the hardware popcnt -# instruction, you should use the -mpopcnt compiler option -# to make the built-in intrinsic use the hardware rather than -# the "folding" approach. That is the default in this -# Makefile so if you do NOT have hardware popcnt, remove all -# of the -mpopcnt strings in the Makefile lines below. -# -default: - $(MAKE) -j unix-clang -help: - @echo "You must specify the system which you want to compile for:" - @echo "" - @echo "make unix-clang Unix w/clang compiler (MacOS usually)" - @echo "make unix-gcc Unix w/gcc compiler" - @echo "make unix-icc Unix w/icc compiler" - @echo "make profile profile-guided-optimizations" - @echo " (edit Makefile to make the profile" - @echo " option use the right compiler)" - @echo "" - - -quick: - $(MAKE) target=UNIX \ - CC=clang \ - opt='-DSYZYGY -DTEST -DTRACE -DCPUS=4' \ - CFLAGS='-mpopcnt -Wall -Wno-array-bounds -pipe -O3' \ - LDFLAGS='$(LDFLAGS) -lstdc++' \ - crafty-make - -unix-gcc: - $(MAKE) -j target=UNIX \ - CC=gcc \ - opt='-DSYZYGY -DTEST -DCPUS=4' \ - CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-use \ - -mpopcnt -fprofile-correction -pthread' \ - LDFLAGS='$(LDFLAGS) -fprofile-use -pthread -lstdc++' \ - crafty-make - -unix-gcc-profile: - $(MAKE) -j target=UNIX \ - CC=gcc \ - opt='-DSYZYGY -DTEST -DCPUS=4' \ - CFLAGS='-Wall -Wno-array-bounds -pipe -O3 -fprofile-arcs \ - -mpopcnt -pthread' \ - LDFLAGS='$(LDFLAGS) -fprofile-arcs -pthread -lstdc++ ' \ - crafty-make - -unix-clang: - @/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/llvm-profdata merge -output=crafty.profdata *.profraw - $(MAKE) -j target=UNIX \ - CC=clang \ - opt='-DSYZYGY -DTEST -DCPUS=4' \ - CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \ - -mpopcnt -fprofile-instr-use=crafty.profdata' \ - LDFLAGS='$(LDFLAGS) -fprofile-use -lstdc++' \ - crafty-make - -unix-clang-profile: - $(MAKE) -j target=UNIX \ - CC=clang \ - opt='-DSYZYGY -DTEST -DCPUS=4' \ - CFLAGS='-Wall -Wno-array-bounds -pipe -O3 \ - -mpopcnt -fprofile-instr-generate' \ - LDFLAGS='$(LDFLAGS) -fprofile-instr-generate -lstdc++ ' \ - crafty-make - -unix-icc: - $(MAKE) -j target=UNIX \ - CC=icc \ - opt='-DSYZYGY -DTEST -DCPUS=4' \ - CFLAGS='-Wall -w -O2 -prof_use -prof_dir ./prof -fno-alias \ - -mpopcnt -pthread' \ - LDFLAGS='$(LDFLAGS) -pthread -lstdc++' \ - crafty-make - -unix-icc-profile: - $(MAKE) -j target=UNIX \ - CC=icc \ - opt='-DSYZYGY -DTEST -DCPUS=4' \ - CFLAGS='-Wall -w -O2 -prof_gen -prof_dir ./prof -fno-alias \ - -mpopcnt -pthread' \ - LDFLAGS='$(LDFLAGS) -pthread -lstdc++ ' \ - crafty-make - -profile: - @rm -rf *.o - @rm -rf log.* - @rm -rf game.* - @rm -rf prof - @rm -rf *.gcda - @mkdir prof - @touch *.c *.h - $(MAKE) -j unix-clang-profile - @echo "#!/bin/csh" > runprof - @echo "./crafty <>runprof - @echo "bench" >>runprof - @echo "mt=0" >>runprof - @echo "quit" >>runprof - @echo "EOF" >>runprof - @chmod +x runprof - @./runprof - @rm runprof - @touch *.c *.h - $(MAKE) -j unix-clang - - -# -# one of the two following definitions for "objects" should be used. The -# default is to compile everything separately. However, if you use the -# definition that refers to crafty.o, that will compile using the file crafty.c -# which #includes every source file into one large glob. This gives the -# compiler max opportunity to inline functions as appropriate. You should try -# compiling both ways to see which way produces the fastest code. -# - -#objects = main.o iterate.o time.o search.o quiesce.o evaluate.o thread.o \ - repeat.o hash.o next.o history.o movgen.o make.o unmake.o attacks.o \ - see.o tbprobe.o boolean.o utility.o book.o drawn.o epd.o \ - epdglue.o init.o input.o autotune.o interrupt.o option.o output.o \ - ponder.o resign.o root.o learn.o setboard.o test.o validate.o \ - annotate.o analyze.o evtest.o bench.o edit.o data.o - -objects = crafty.o - -# Do not change anything below this line! - -opts = $(opt) -D$(target) - -crafty-make: - @$(MAKE) opt='$(opt)' CFLAGS='$(CFLAGS)' crafty - -crafty.o: *.c *.h - -crafty: $(objects) - $(CC) $(LDFLAGS) -g -o crafty $(objects) -lm $(LIBS) - -evaluate.o: evaluate.h - -clean: - -rm -f *.o crafty - -$(objects): chess.h data.h - -.c.o: - $(CC) $(CFLAGS) $(opts) -c $*.c - -.s.o: - $(AS) $(AFLAGS) -o $*.o $*.s diff --git a/chess.h b/chess.h deleted file mode 100644 index 3b87fa0..0000000 --- a/chess.h +++ /dev/null @@ -1,650 +0,0 @@ -/* - ******************************************************************************* - * * - * configuration information: the following variables need to be set to * - * indicate the machine configuration/capabilities. * - * * - * UNIX: define this if the program is being run on a unix-based system, * - * which causes the executable to use unix-specific runtime utilities. * - * * - * CPUS=N: this sets up data structures to the appropriate size to support * - * up to N simultaneous search engines. note that you can set this to a * - * value larger than the max processors you currently have, because the mt=n * - * command (added to the command line or your crafty.rc/.craftyrc file) will * - * control how many threads are actually spawned. * - * * - ******************************************************************************* - */ -/* *INDENT-OFF* */ - -#if defined(AFFINITY) -# define _GNU_SOURCE -# include -#endif -#if defined(UNIX) -# define _GNU_SOURCE -# if (CPUS > 1) -# include -# endif -# include -# include -# include -#endif -#include -#include -#include -#include -#include -#include -#include -#pragma once -# if !defined (UNIX) -# define RESTRICT __restrict -# else -# define RESTRICT -# endif -# if !defined(CPUS) -# define CPUS 1 -# endif -# if !defined(UNIX) -# include -# include -# endif -# define CDECL -# define STDCALL -/* Provide reasonable defaults for UNIX systems. */ -# if !defined(UNIX) -# undef STDCALL -# define STDCALL __stdcall -# ifdef VC_INLINE32 -# undef CDECL -# define CDECL __cdecl -# endif -# endif -# if !defined(BOOKDIR) -# define BOOKDIR "." -# endif -# if !defined(LOGDIR) -# define LOGDIR "." -# endif -# if !defined(TBDIR) -# define TBDIR "./syzygy" -# endif -# if !defined(RCDIR) -# define RCDIR "." -# endif -# include "lock.h" -# define MAXPLY 129 -# define MAX_TC_NODES 3000000 -# define MAX_BLOCKS 64 * CPUS -# define BOOK_CLUSTER_SIZE 8000 -# define MERGE_BLOCK 1000 -# define SORT_BLOCK 4000000 -# define LEARN_INTERVAL 10 -# define LEARN_COUNTER_BAD -80 -# define LEARN_COUNTER_GOOD +100 -# define MATE 32768 -# define TBWIN 31000 -# define PAWN_VALUE 100 -# define KNIGHT_VALUE 305 -# define BISHOP_VALUE 305 -# define ROOK_VALUE 490 -# define QUEEN_VALUE 1000 -# define KING_VALUE 40000 -# define FOREVER 1 -# if !defined(CLOCKS_PER_SEC) -# define CLOCKS_PER_SEC 1000000 -# endif -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 { empty = 0, occupied = 0, pawn = 1, knight = 2, bishop = 3, - rook = 4, queen = 5, king = 6 -} PIECE; -typedef enum { black = 0, white = 1 } COLOR; -typedef enum { mg = 0, eg = 1 } PHASE; -typedef enum { empty_v = 0, pawn_v = 1, knight_v = 3, - bishop_v = 3, rook_v = 5, queen_v = 9, king_v = 99 -} PIECE_V; -typedef enum { serial = 0, parallel = 1} SEARCH_MODE; -typedef enum { think = 1, puzzle = 2, book = 3, annotate = 4 } SEARCH_TYPE; -typedef enum { normal_mode, tournament_mode } PLAYING_MODE; -typedef struct { - int8_t castle[2]; - uint8_t enpassant_target; - uint8_t reversible; -} SEARCH_POSITION; -typedef struct { - uint32_t move1; - uint32_t move2; -} KILLER; -typedef struct { - uint64_t pieces[7]; -} BB_PIECES; -typedef struct { - BB_PIECES color[2]; - uint64_t hash_key; - uint64_t pawn_hash_key; - int material_evaluation; - int kingsq[2]; - int8_t board[64]; - char pieces[2][7]; - char total_all_pieces; -} POSITION; -typedef struct { - uint64_t word1; - uint64_t word2; -} HASH_ENTRY; -typedef struct { - uint64_t key; - int32_t score_mg, score_eg; - unsigned char defects_k[2]; - unsigned char defects_m[2]; - unsigned char defects_q[2]; - unsigned char passed[2]; -} PAWN_HASH_ENTRY; -typedef struct { - uint64_t entry[3]; -} PXOR; -typedef struct { - int path[MAXPLY]; - int pathh; - int pathl; - int pathd; - int pathv; -} PATH; -typedef struct { - uint64_t path_sig; - int hash_pathl; - int hash_path_age; - int hash_path_moves[MAXPLY]; -} HPATH_ENTRY; -typedef struct { - int phase; - int order; - int remaining; - unsigned *last; - unsigned done[10]; - unsigned *exclude; -} NEXT_MOVE; -/* - root_move.status: - - xxx1 = failed low this iteration - xx1x = failed high this iteration - x1xx = don't search in parallel or reduce - 1xxx = move has been searched - */ -typedef struct { - int move; - unsigned status; - int bm_age; - PATH path; -} ROOT_MOVE; -# if !defined(UNIX) -# pragma pack(4) -# endif -typedef struct { - uint64_t position; - unsigned status_played; - float learn; -} BOOK_POSITION; -# if !defined(UNIX) -# pragma pack() -# endif -typedef struct { - unsigned char position[8]; - unsigned char status; - unsigned char percent_play; -} BB_POSITION; -struct personality_term { - char *description; - int type; - int size; - void *value; -}; -struct autotune { - unsigned int min; - unsigned int max; - unsigned int increment; - char description[64]; - char command[16]; - unsigned int *parameter; -}; -typedef struct tree { -/* commonly used variables */ - SEARCH_POSITION status[MAXPLY + 3]; - NEXT_MOVE next_status[MAXPLY]; - KILLER killers[MAXPLY]; - KILLER counter_move[4096]; - KILLER move_pair[4096]; - POSITION position; - uint64_t save_hash_key[MAXPLY + 3]; - uint64_t save_pawn_hash_key[MAXPLY + 3]; - uint64_t rep_list[256]; - int curmv[MAXPLY]; - int phase[MAXPLY]; - int hash_move[MAXPLY]; - unsigned *last[MAXPLY]; - unsigned move_list[5120]; - PATH pv[MAXPLY]; -/* variables used by Evaluate() */ - PAWN_HASH_ENTRY pawn_score; - int tropism[2]; - int dangerous[2]; - uint64_t all_pawns; - int score_mg, score_eg; -/* statistical counters */ - uint64_t nodes_searched; - uint64_t fail_highs; - uint64_t fail_high_first_move; - uint64_t evaluations; - uint64_t egtb_probes; - uint64_t egtb_hits; - uint64_t extensions_done; - uint64_t qchecks_done; - uint64_t moves_fpruned; - uint64_t moves_mpruned; - uint64_t LMR_done[16]; - uint64_t null_done[16]; -/* thread stuff */ - lock_t lock; - int thread_id; - volatile int joinable; - volatile int joined; - volatile int stop; - volatile int nprocs; - int alpha; - int beta; - volatile int value; - int wtm; - int depth; - int ply; - int in_check; - int *searched; - int cutmove; - struct tree *volatile siblings[CPUS], *parent; -/* rarely accessed */ - char root_move_text[16]; - char remaining_moves_text[16]; -} TREE; -typedef struct thread { - TREE *tree; - uint64_t blocks; - uint64_t max_blocks; - unsigned int idle; - volatile unsigned int terminate; - char filler[40]; -} THREAD; -/* - DO NOT modify these. these are constants, used in multiple modules. - modification may corrupt the search in any number of ways, all bad. - */ -# define WORTHLESS 0 -# define UPPER 1 -# define LOWER 2 -# define EXACT 3 -# define HASH_MISS 0 -# define HASH_HIT 1 -# define AVOID_NULL_MOVE 2 -# define NO_NULL 0 -# define DO_NULL 1 -# define NONE 0 -# define NULL_MOVE 1 -# define DO_NOT_REDUCE 1 -# define HASH 2 -# define GENERATE_CAPTURES 3 -# define CAPTURES 4 -# define KILLER1 5 -# define KILLER2 6 -# define KILLER3 7 -# define KILLER4 8 -# define COUNTER_MOVE1 9 -# define COUNTER_MOVE2 10 -# define MOVE_PAIR1 11 -# define MOVE_PAIR2 12 -# define GENERATE_QUIET 13 -# define HISTORY 14 -# define REMAINING 15 -# define EVALUATION 16 -# define ILLEGAL 0 -# define LEGAL 1 -# define IN_WINDOW 2 -# define FAIL_HIGH 3 -#define PopCnt(v) __builtin_popcountll(v) -#define LSB(v) __builtin_ctzll(v) -#define MSB(v) (63 - __builtin_clzll(v)) -void AlignedMalloc(void **, uint64_t, size_t); -void AlignedRemalloc(void **, uint64_t, size_t); -void Analyze(void); -void Annotate(void); -void AnnotateHeaderHTML(char *, FILE *); -void AnnotateFooterHTML(FILE *); -void AnnotatePositionHTML(TREE *RESTRICT, int, FILE *); -char *AnnotateVtoNAG(int, int, int, int); -void AnnotateHeaderTeX(FILE *); -void AnnotateFooterTeX(FILE *); -void AnnotatePositionTeX(TREE *, int, FILE *); -uint64_t atoiKMB(char *); -int Attacks(TREE *RESTRICT, int, int); -uint64_t Attacked(TREE *RESTRICT, int, uint64_t); -uint64_t AttacksFrom(TREE *RESTRICT, int, int); -uint64_t AttacksTo(TREE *RESTRICT, int); -void AutoTune(int, char **); -int Bench(int, int); -int Book(TREE *RESTRICT, int); -void BookClusterIn(FILE *, int, BOOK_POSITION *); -void BookClusterOut(FILE *, int, BOOK_POSITION *); -int BookIn32(unsigned char *); -float BookIn32f(unsigned char *); -uint64_t BookIn64(unsigned char *); -int BookMask(char *); -unsigned char *BookOut32(int); -unsigned char *BookOut32f(float); -unsigned char *BookOut64(uint64_t); -int BookPonderMove(TREE *RESTRICT, int); -void Bookup(TREE *RESTRICT, 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); -int ComputeDifficulty(int, int); -void CopyFromParent(TREE *RESTRICT); -void CopyToParent(TREE *RESTRICT, TREE *RESTRICT, int); -void CraftyExit(int); -void DisplayArray(int *, int); -void DisplayArrayX2(int *, int *, int); -void DisplayBitBoard(uint64_t); -void Display2BitBoards(uint64_t, uint64_t); -void DisplayChessBoard(FILE *, POSITION); -char *DisplayEvaluation(int, int); -char *DisplayEvaluationKibitz(int, int); -void DisplayFT(int, int, int); -char *DisplayHHMM(unsigned); -char *DisplayHHMMSS(unsigned); -char *DisplayKMB(uint64_t, int); -void DisplayFail(TREE *RESTRICT, int, int, int, int, int, int, int); -char *DisplayPath(TREE *RESTRICT, int, PATH *); -void DisplayPV(TREE *RESTRICT, int, int, int, PATH *, int); -char *DisplayTime(unsigned); -char *Display2Times(unsigned); -char *DisplayTimeKibitz(unsigned); -void DisplayChessMove(char *, int); -int Drawn(TREE *RESTRICT, int); -int DTZtoWDL(int, int); -void Edit(void); -int Evaluate(TREE *RESTRICT, int, int, int, int); -void EvaluateBishops(TREE *RESTRICT, int); -void EvaluateCastling(TREE *RESTRICT, int, int); -int EvaluateDraws(TREE *RESTRICT, int, int, int); -int EvaluateHasOpposition(int, int, int); -void EvaluateKing(TREE *RESTRICT, int, int); -int EvaluateKingsFile(TREE * RESTRICT, int, int, int); -void EvaluateKnights(TREE *RESTRICT, int); -void EvaluateMate(TREE *RESTRICT, int); -void EvaluateMaterial(TREE *RESTRICT, int); -void EvaluatePassedPawns(TREE *RESTRICT, int, int); -void EvaluatePassedPawnRaces(TREE *RESTRICT, int); -void EvaluatePawns(TREE *RESTRICT, int); -void EvaluateQueens(TREE *RESTRICT, int); -void EvaluateRooks(TREE *RESTRICT, int); -int EvaluateWinningChances(TREE *RESTRICT, int, int); -void EVTest(char *); -int Exclude(TREE *RESTRICT, int, int); -int FindBlockID(TREE *RESTRICT); -char *FormatPV(TREE *RESTRICT, int, PATH); -int FTbSetCacheSize(void *, unsigned long); -int GameOver(int); -unsigned *GenerateCaptures(TREE *RESTRICT, int, int, unsigned *); -unsigned *GenerateCheckEvasions(TREE *RESTRICT, int, int, unsigned *); -unsigned *GenerateChecks(TREE *RESTRICT, int, unsigned *); -unsigned *GenerateNoncaptures(TREE *RESTRICT, int, int, unsigned *); -TREE *GetBlock(TREE *, int); -void Initialize(void); -void InitializeAttackBoards(void); -void InitializeChessBoard(TREE *); -int InitializeGetLogID(); -void InitializeHashTables(int); -void InitializeKillers(void); -void InitializeKingSafety(void); -void InitializeMagic(void); -uint64_t InitializeMagicBishop(int, uint64_t); -uint64_t InitializeMagicRook(int, uint64_t); -uint64_t InitializeMagicOccupied(int *, int, uint64_t); -void InitializeMasks(void); -void InitializePawnMasks(void); -void InitializeLMP(void); -void InitializeLMR(void); -void InitializeSMP(void); -int IInitializeTb(char *); -int InputMove(TREE *RESTRICT, int, int, int, int, char *); -int InputMoveICS(TREE *RESTRICT, int, int, int, int, char *); -uint64_t InterposeSquares(int, int, int); -void Interrupt(int); -int InvalidPosition(TREE *RESTRICT); -int Iterate(int, int, int); -int Join(int64_t); -void Kibitz(int, int, int, int, int, uint64_t, int, int, char *); -void History(TREE *RESTRICT, int, int, int, int, int*); -int KingPawnSquare(int, int, int, int); -int LearnAdjust(int); -void LearnBook(void); -int LearnFunction(int, int, int, int); -void LearnValue(int, int); -void MakeMove(TREE *RESTRICT, int, int, int); -void MakeMoveRoot(TREE *RESTRICT, int, int); -int Mated(TREE *RESTRICT, int, int); -int RootMoveEGTB(int); -int NextMove(TREE *RESTRICT, int, int, int, int); -int NextRootMove(TREE *RESTRICT, TREE *RESTRICT, int); -int NextRootMoveParallel(void); -void NextSort(TREE *RESTRICT, int); -int Option(TREE *RESTRICT); -int OptionMatch(char *, char *); -void OptionPerft(TREE *RESTRICT, int, int, int); -void Output(TREE *RESTRICT); -char *OutputMove(TREE *RESTRICT, int, int, int); -int ParseTime(char *); -void Pass(void); -int PinnedOnKing(TREE *RESTRICT, int, int); -int Ponder(int); -void Print(int, char *, ...); -int ProbeDTZ(TREE * RESTRICT tree, int ply, int wtm); -int HashProbe(TREE *RESTRICT, int, int, int, int, int, int*); -void HashStore(TREE *RESTRICT, int, int, int, int, int, int); -void HashStorePV(TREE *RESTRICT, int, int); -int Quiesce(TREE *RESTRICT, int, int, int, int, int); -int QuiesceEvasions(TREE *RESTRICT, int, int, int, int); -unsigned Random32(void); -uint64_t Random64(void); -int Read(int, char *); -int ReadChessMove(TREE *RESTRICT, FILE *, int, int); -void ReadClear(void); -unsigned ReadClock(void); -int ReadPGN(FILE *, int); -int ReadNextMove(TREE *RESTRICT, char *, int, int); -int ReadParse(char *, char *args[], char *); -int ReadInput(void); -int Repeat(TREE *RESTRICT, int); -int Repeat3x(TREE *RESTRICT); -void ResignOrDraw(TREE *RESTRICT, int); -void RestoreGame(void); -void RootMoveList(int); -int Search(TREE *RESTRICT, int, int, int, int, int, int, int); -int SearchMove(TREE *RESTRICT, int, int, int, int, int, int, int, int, int); -int SearchMoveList(TREE *RESTRICT, int, int, int, int, int, int *, int, int, int); -int SearchNull(TREE * RESTRICT, int, int, int, int); -void Trace(TREE *RESTRICT, int, int, int, int, int, const char *, int, int, int); -void SetBoard(TREE *, int, char **, int); -void SetChessBitBoards(TREE *); -void SharedFree(void *address); -void SortRootMoves(TREE *RESTRICT, int); -int Split(TREE *RESTRICT); -int StrCnt(char *, char); -int SEE(TREE *RESTRICT, int, int); -int SEEO(TREE *RESTRICT, int, int); -void Test(char *, FILE *, int, int); -void TestEPD(char *, FILE *, int, int); -void ThreadAffinity(int); -void *STDCALL ThreadInit(void *); -# if !defined(UNIX) -void ThreadMalloc(int64_t); -# endif -int ThreadSplit(TREE *RESTRICT, int, int, int, int, int); -void ThreadStop(TREE *RESTRICT); -void ThreadTrace(TREE * RESTRICT, int, int); -int ThreadWait(int, TREE *RESTRICT); -int Threat(TREE *, int, int, int, int); -void TimeAdjust(int, int); -int TimeCheck(TREE *RESTRICT, int); -void TimeSet(int); -void UnmakeMove(TREE *RESTRICT, int, int, int); -int ValidMove(TREE *RESTRICT, int, int, int); -int VerifyMove(TREE *RESTRICT, int, int, int); -void ValidatePosition(TREE *RESTRICT, int, int, char *); -void WaitForAllThreadsInitialized(void); -# if !defined(UNIX) -extern void *WinMallocInterleaved(size_t, int); -extern void WinFreeInterleaved(void *, size_t); -# define MallocInterleaved(cBytes, cThreads) \ - WinMallocInterleaved(cBytes, cThreads) -# define FreeInterleaved(pMemory, cBytes) \ - WinFreeInterleaved(pMemory, cBytes) -# else -# if defined(NUMA) -# define MallocInterleaved(cBytes, cThreads) numa_alloc_interleaved(cBytes) -# define FreeInterleaved(pMemory, cBytes) numa_free(pMemory, 1) -# else -# define MallocInterleaved(cBytes, cThreads) malloc(cBytes) -# define FreeInterleaved(pMemory, cBytes) free(pMemory) -# endif -# endif -# define Abs(a) (((a) > 0) ? (a) : -(a)) -# define Max(a,b) (((a) > (b)) ? (a) : (b)) -# define Min(a,b) (((a) < (b)) ? (a) : (b)) -# define Sign(a) ((a) < 0 ? -1 : +1) -# define FileDistance(a,b) abs(File(a) - File(b)) -# define RankDistance(a,b) abs(Rank(a) - Rank(b)) -# define Distance(a,b) Max(FileDistance(a,b), RankDistance(a,b)) -# define DrawScore(side) (draw_score[side]) -# define PopCnt8Bit(a) (pop_cnt_8bit[a]) -# define MSB8Bit(a) (msb_8bit[a]) -# define LSB8Bit(a) (lsb_8bit[a]) -# define HistoryIndex(side, m) ((side << 9) + (Piece(m) << 6) + To(m)) -/* - side = side to move - mptr = pointer into move list - m = bit vector of to squares to unpack - t = pre-computed from + moving piece - */ -# define Extract(side, mptr, m, t) \ - for ( ; m ; Clear(to, m)) { \ - to = MostAdvanced(side, m); \ - *mptr++ = t | (to << 6) | (Abs(PcOnSq(to)) << 15); \ - } -# define Check(side) Attacks(tree, Flip(side), KingSQ(side)) -# define Attack(from,to) (!(intervening[from][to] & OccupiedSquares)) -# define BishopAttacks(square, occ) *(magic_bishop_indices[square]+((((occ)&magic_bishop_mask[square])*magic_bishop[square])>>magic_bishop_shift[square])) -# define BishopMobility(square, occ) *(magic_bishop_mobility_indices[square]+((((occ)&magic_bishop_mask[square])*magic_bishop[square])>>magic_bishop_shift[square])) -# define KingAttacks(square) king_attacks[square] -# define KnightAttacks(square) knight_attacks[square] -# define PawnAttacks(side, square) pawn_attacks[side][square] -# define Reversible(p) (tree->status[p].reversible) -# define ReversibleMove(m) (!CaptureOrPromote(m) && Piece(m) != pawn) -# define RookAttacks(square, occ) *(magic_rook_indices[square]+((((occ)&magic_rook_mask[square])*magic_rook[square])>>magic_rook_shift[square])) -# define RookMobility(square, occ) *(magic_rook_mobility_indices[square]+((((occ)&magic_rook_mask[square])*magic_rook[square])>>magic_rook_shift[square])) -# define QueenAttacks(square, occ) (BishopAttacks(square, occ)|RookAttacks(square, occ)) -# define Rank(x) ((x)>>3) -# define File(x) ((x)&7) -# define Flip(x) ((x)^1) -# define MostAdvanced(side, squares) ((side) ? MSB(squares) : LSB(squares)) -# define LeastAdvanced(side, squares) ((side) ? LSB(squares) : MSB(squares)) -# define MinMax(side, v1, v2) ((side) ? Min((v1), (v2)) : Max((v1), (v2))) -# define InFront(side, k, p) ((side) ? k > p : k < p) -# define Behind(side, k, p) ((side) ? k < p : k > p) -# define Passed(sq, wtm) (!(mask_passed[wtm][sq] & Pawns(Flip(wtm)))) -# define RankAttacks(a) (RookAttacks(a, OccupiedSquares) & rank_mask[Rank(a)]) -# define FileAttacks(a) (RookAttacks(a, OccupiedSquares) & file_mask[File(a)]) -# define Diaga1Attacks(a) (BishopAttacks(a, OccupiedSquares) & (plus9dir[a] | minus9dir[a])) -# define Diagh1Attacks(a) (BishopAttacks(a, OccupiedSquares) & (plus7dir[a] | minus7dir[a])) -# define InterposeSquares(kingsq, checksq) intervening[kingsq][checksq] -/* - the following macros are used to extract the pieces of a move that are - kept compressed into the rightmost 21 bits of a simple integer. - */ -# define From(a) ((a) & 63) -# define To(a) (((a)>>6) & 63) -# define Piece(a) (((a)>>12) & 7) -# define Captured(a) (((a)>>15) & 7) -# define Promote(a) (((a)>>18) & 7) -# define Move(a) (a & 0x1fffff) -# define SortV(a) (a >> 21) -# define CaptureOrPromote(a) (((a)>>15) & 63) -# define PawnPush(c, a) (Piece(a) == pawn && \ - rankflip[c][Rank(To(a))] >= RANK6 \ - && !(mask_passed[c][To(a)] & \ - Pawns(Flip(c)))) -# define CastleMove(c, a) (Piece(a) == king && Abs(File(To(a)) - \ - File(From(a))) > 1) -# define SetMask(a) (set_mask[a]) -# define ClearMask(a) (clear_mask[a]) -# define Pawns(c) (tree->position.color[c].pieces[pawn]) -# define Knights(c) (tree->position.color[c].pieces[knight]) -# define Bishops(c) (tree->position.color[c].pieces[bishop]) -# define Rooks(c) (tree->position.color[c].pieces[rook]) -# define Queens(c) (tree->position.color[c].pieces[queen]) -# define Kings(c) (tree->position.color[c].pieces[king]) -# define KingSQ(c) (tree->position.kingsq[c]) -# define Occupied(c) (tree->position.color[c].pieces[occupied]) -# define Pieces(c, p) (tree->position.color[c].pieces[p]) -# define TotalPieces(c, p) (tree->position.pieces[c][p]) -# define PieceValues(c, p) (piece_values[c][p]) -# define TotalAllPieces (tree->position.total_all_pieces) -# define Material (tree->position.material_evaluation) -# define MaterialSTM(side) ((side) ? Material : -Material) -# define MateScore(s) (Abs(s) > 32000) -# define EGTBScore(s) (Abs(s) > 30000 && Abs(s) < 32000) -# define Castle(ply, c) (tree->status[ply].castle[c]) -# define HashKey (tree->position.hash_key) -# define PawnHashKey (tree->position.pawn_hash_key) -# define EnPassant(ply) (tree->status[ply].enpassant_target) -# define EnPassantTarget(ply) (EnPassant(ply) ? SetMask(EnPassant(ply)) : 0) -# define PcOnSq(sq) (tree->position.board[sq]) -# define OccupiedSquares (Occupied(white) | Occupied(black)) -# define Color(square) (square_color[square] ? dark_squares : ~dark_squares) -# define SideToMove(c) ((c) ? "White" : "Black") -/* - the following macros are used to Set and Clear a specific bit in the - second argument. this is done to make the code more readable, rather - than to make it faster. - */ -# define ClearSet(a,b) b=((a) ^ (b)) -# define Clear(a,b) b=ClearMask(a) & (b) -# define Set(a,b) b=SetMask(a) | (b) -/* - the following macros are used to update the hash signatures. - */ -# define Hash(stm,piece,square) (HashKey^=randoms[stm][piece][square]) -# define HashP(stm,square) (PawnHashKey^=randoms[stm][pawn][square]) -# define HashCastle(stm,direction) (HashKey^=castle_random[stm][direction]) -# define HashEP(sq) (HashKey^=enpassant_random[sq]) -# define SavePV(tree,ply,ph) do { \ - tree->pv[ply-1].path[ply-1]=tree->curmv[ply-1]; \ - tree->pv[ply-1].pathl=ply; \ - tree->pv[ply-1].pathh=ph; \ - tree->pv[ply-1].pathd=iteration;} while(0) -# if defined(INLINEASM) -# include "inline.h" -# endif -/* *INDENT-ON* */ diff --git a/crafty.hlp b/crafty.hlp deleted file mode 100644 index 026770b..0000000 --- a/crafty.hlp +++ /dev/null @@ -1,996 +0,0 @@ -command synopsis - -!command....................... passes command to a shell. -adaptive NPS a b c d........... enables adaptive hash mode. -alarm on|off................... turns audible alarm on/off. -analyze........................ analyze a game in progress. -annotate....................... annotate game -autotune....................... SMP search tuning (help autotune for details) -batch on|off................... on disables async I/O for batch file usage -bench.......................... runs performance benchmark. -black.......................... sets black to move. -book........................... controls book -cache=n........................ sets tablebase cache size. -clock.......................... displays/adjusts chess clock times. -display........................ displays chess board. -display [n].................... sets display options -draw accept|decline............ decline always declines. -draw offer|nooffer............. nooffer never offers a draw. -draw dynamic <0|1>............. enables/disables dynamic draw scores. -echo........................... echos output to display. -edit........................... edit board position. -egtb........................... enables endgame database probes. -egtbd.......................... set min remaining depth to allow probes. -epdhelp........................ info about EPD facility. -end............................ terminates program. -evaluation..................... adjust evaluation terms. -exit........................... restores STDIN to keyboard. -force move..................... forces specific move. -hash n......................... sets transposition table size. - (n bytes, nK bytes or nM bytes). -hashp n........................ sets pawn hash table size. -history........................ display game moves. -import filename................ imports learning data (.lrn files). -info........................... displays program settings. -input filename................. sets STDIN to filename, reverts back on exit. -kibitz n....................... sets kibitz mode n on ICS. -learn n|clear.................. enables/disables learning (100 = default). - clear clears all learned information -level moves time inc........... sets ICS time controls. -linelength n................... sets line length to n. A really large value - will produce 1 line PVs, making parsing easier -list........................... update/display GM/IM/computer lists. -lmp base scale................. LMP pruning move counts -lmr min max bias moves scale... LMR reduction matrix generator -load file title................ load a position from problem file, starting - with line containing title, ending on exit. -log on|off..................... turn logging on/off. -mode normal|tournament......... toggles tournament mode. -move........................... initiates search (same as go). -name........................... sets opponent's name. -new............................ initialize and start new game. -null m n....................... null move R = M + depth / n. -noise n........................ no status until n nodes searched. -operator seconds............... sets operator time per move. -output long|short.............. sets move display format to long or SAN -perf........................... times the move generator/make_move. -perft.......................... tests the move generator/make_move. -personality save|load fn....... saves/loads a personality file. -pgn option value............... set PGN header information. -phash n........................ sets path hash table size. -ponder on|off.................. toggle pondering off/on. -ponder move.................... ponder "move" as predicted move. -rating a b..................... sets Crafty rating to a, opponent to b - (affects draw score/contempt) -read [filename]................ read moves in (from [filename] if given.) -reada [filename]............... read moves in (from [filename]]) and append. - (appends to current game history.) -reset n........................ reset game to move n. -resign......................... ends current game recording Crafty as winner. -resign m n..................... set resign threshold to m pawns. - n = # of moves before resigning. -savegame [filename]............ saves game in PGN format (to filename). -savepos [filename]............. saves position in FEN string (to filename). -score.......................... print evaluation of position. -screen [filename] margin....... screen a file of EPD positions by searching them - and culling positions with score outside the - window {-margin, margin} (use st=n to set time) -sd n........................... sets absolute search depth. -search move.................... search specified move only. -selective min max.............. set null move depths. -setboard FEN................... sets board position to FEN position. -settc.......................... set time controls. -show book...................... toggle book statistics. -skill n........................ set skill level to n -smp............................ sets SMP parameters (help smp for details) -sn n........................... sets absolute search node limit. -speech on|off.................. enables (disables) audio output. -st n........................... sets absolute search time. -swindle on|off................. enables/disables swindle mode. -tags........................... list PGN header tags. -test file [N].................. test a suite of problems. -time........................... time controls. -timebook....................... out of book time adjustment -trace n........................ display search tree below depth n. -usage percentage............... adjusts Crafty's time usage up or down. -whisper n...................... sets ICS whisper mode n. -white.......................... sets white to move. -wild n......................... sets ICS wild position (7 for now). -xboard......................... sets xboard compatibility mode. - -Type "help command" to see more detailed help information, if it is -available. Note that help is not available for all possible commands. - - - -The analyze command puts Crafty into a mode where it will search forever -in the current position. When a move is entered, crafty will make that -move, switch sides, and again compute, printing analysis as it searches. -You can back up a move by entering "back" or you can back up several -moves by entering "back n". Note that n is the number of moves, counting -each player's move as one (ie n plies, not n full moves). - - - -annotate[h|t] filename side moves margin time [n] - -Filename is the input file with game moves, while the output will be -written to filename.can. The input file is PGN-compatible with one -addition, the ability to request that alternative moves also be -analyzed at any point. To do this at the point where you have -alternative moves, simply include them in braces {move1, move2}, -and Crafty will then search them also. - -Side can be b/w/bw to indicate whether to annotate only the white -side (w), the black side (b) or both (bw). Side can also be the -players name, where Crafty will then use the players name and the -PGN tags to discover which you want the annotation done for. - -Moves indicates which moves to annotate. A single value says start -at the indicated move and go through the entire game. A range (20-30) -annotates the given range only. - -Margin is the difference between the search value for the move played -in the game, and the best move crafty found, before a comment is -generated (pawn=1.0). - -Time is the time limit per move in seconds. - -If the optional "n" is appended, this produces N best moves/scores/PV's, -rather than just the very best move. It won't display any move that -is worse than the actual game move played, but you can use -N to force -Crafty to produce N PV's regardless of how bad they get. - -Using 'annotateh' produces an HTML file with bitmapped board displays -where analysis was displayed. - -Using "annotatet" will cause the output to be written in a LaTex (.tex) -format. - - - -The autotune command can be used to configure various SMP search parameters -for your specific hardware and target time limit. Note that before you run -this command, you MUST set the max number of threads you want to use (most -likely the number of physical processor cores on your machine.) Crafty -actually runs a parallel search over a small set of positions repeatedly, and -to properly tune things, it needs to use the max configuration you will ever -want to use. If you forget, autotune will refuse to run. The command is: - -autotune