⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 common.h

📁 一款运行在linux上的象棋游戏。用GTK/GNOME环境下用GLADE开发。
💻 H
📖 第 1 页 / 共 2 页
字号:
extern int ThrtCnt[MAXPLYDEPTH];extern char id[32];extern char solution[64];extern float SearchTime;extern int SearchDepth;extern int MoveLimit[2];extern float TimeLimit[2];extern int TCMove;extern int TCinc;extern float TCTime;extern int hunged[2];extern int phase;extern int Hashmv[MAXPLYDEPTH];extern short RootPieces;extern short RootPawns;extern short RootMaterial;extern short RootAlpha;extern short RootBeta;extern short pickphase[MAXPLYDEPTH];extern short InChk[MAXPLYDEPTH];extern short KingThrt[2][MAXPLYDEPTH];extern short KingSafety[2];extern short pscore[64];extern short bookmode;extern short bookfirstlast;extern int range[8];extern int ptype[2];extern char algbr[64][3];extern char algbrfile[9];extern char algbrrank[9];extern char notation[8];extern char lnotation[8];extern int r90[64];extern int r45[64];extern int r315[64];extern int Mask45[64];extern int Mask315[64];extern int rank6[2];extern int rank7[2];extern int rank8[2];extern char *progname;extern FILE *ofp;extern int myrating, opprating, suddendeath;#define MAXNAMESZ 50extern char name[MAXNAMESZ];extern int computerplays;extern int wasbookmove;extern int nmovesfrombook;extern float maxtime;extern int n; 		/* Last mobility returned by CTL */extern int ExchCnt[2];extern int newpos, existpos;		/* For book statistics */extern int bookloaded;enum Piece { empty, pawn, knight, bishop, rook, queen, king, bpawn };enum Square { 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 };enum File { A_FILE, B_FILE, C_FILE, D_FILE, E_FILE, F_FILE, G_FILE, H_FILE };/**************************************************************************** * *  The various function prototypes.  They are group into the *.c files *  in which they are defined. * ****************************************************************************//* * Explanation of the #ifdef NO_INLINE conditionals: * * Define NO_INLINE only if you really must, implementations will be * provided by the corresponding *.c files. The better solution is to * not define it, in which case inlines.h will be included which * provides static inline version of these functions. *//*  The initialization routines  */void Initialize (void);void InitLzArray (void);void InitBitPosArray (void);void InitMoveArray (void);void InitRay (void);void InitFromToRay (void);void InitRankFileBit (void);void InitBitCount (void);void InitPassedPawnMask (void);void InitIsolaniMask (void);void InitSquarePawnMask (void);void InitRandomMasks (void);void InitRotAtak (void);void InitDistance (void);void InitVars (void);void InitHashCode (void);void InitHashTable (void);void CalcHashSize (int);void NewPosition (void);void InitFICS (void);void InitInput (void);/* Cleanup routines */void CleanupInput(void);/*  The book routines */int BookQuery (int);int BookBuilderOpen(void);int BookBuilder (short result, uint8_t side);int BookBuilderClose(void);/* * Return values (errorcodes) for the book routines, * maybe one should have a global enum of errorcodes */enum {  BOOK_SUCCESS,  BOOK_EFORMAT,  /* Wrong format (e.g. produced by older version) */  BOOK_EMIDGAME, /* Move is past the opening book's move limit */   BOOK_EIO,      /* I/O error, e.g. caused by wrong permissions */  BOOK_EFULL,    /* Book hash is full, new position was not added. */  BOOK_ENOBOOK,  /* No book present */  BOOK_ENOMOVES, /* No moves found (in BookQuery() only) */  BOOK_ENOMEM    /* Memory allocation failed */}; /*  The move generation routines  */void GenMoves (short);void GenCaptures (short);void GenNonCaptures (short);void GenCheckEscapes (short);void FilterIllegalMoves (short);/*  The move routines  */void MakeMove (int, int *);void UnmakeMove (int, int *);void MakeNullMove (int);void UnmakeNullMove (int);void SANMove (int, int);leaf *ValidateMove (char *);leaf *IsInMoveList (int, int, int, char);int IsLegalMove (int);char *AlgbrMove (int);/*  The attack routines  */short SqAtakd (short sq, short side);void GenAtaks (void);BitBoard AttackTo (int, int);BitBoard AttackXTo (int, int);BitBoard AttackFrom (int, int, int);BitBoard AttackXFrom (int, int);int PinnedOnKing (int, int);void FindPins (BitBoard *);int MateScan (int);/*  The swap routines  */int SwapOff (int);void AddXrayPiece (int, int, int, BitBoard *, BitBoard *);/*  The EPD routines  */short ReadEPDFile (const char *, short);int ParseEPD (char *);void LoadEPD (char *);void SaveEPD (char *);/* Error codes for ParseEPD */enum {   EPD_SUCCESS,   EPD_ERROR};void UpdateFriends (void);void UpdateCBoard (void);void UpdateMvboard (void);void EndSearch (int);short ValidateBoard (void);/*  PGN routines  */void PGNSaveToFile (const char *, const char *);void PGNReadFromFile (const char *);void BookPGNReadFromFile (const char *);int IsTrustedPlayer(const char *name);/*  The hash routines  */void CalcHashKey (void);void ShowHashKey (HashType);/*  The evaluation routines  */int ScoreP (short);int ScoreN (short);int ScoreB (short);int ScoreR (short);int ScoreQ (short);int ScoreK (short);int ScoreDev (short);int Evaluate (int, int);short EvaluateDraw (void);/*  Hung routines  */int EvalHung (int);/*  The search routines  */void Iterate (void);int Search (uint8_t ply, short depth, int alpha, int beta, short nodetype);int SearchRoot (short depth, int alpha, int beta);int Quiesce (uint8_t ply, int alpha, int beta);void pick (leaf *, short);short Repeat (void);void ShowLine (int, int, char);/* * Set up a timer by first calling StartTiming(), saving * the return value and feeding it to GetElapsed() for * timings in seconds. */typedef struct timeval Timer;extern double ElapsedTime;extern Timer StartTime;Timer StartTiming (void);double GetElapsed (Timer start);/*  The transposition table routies */void TTPut (uint8_t side, uint8_t depth, uint8_t ply, 	    int alpha, int beta, int score, int move);/* Returns flag if it finds an entry, 0 otherwise */uint8_t TTGet (uint8_t side, uint8_t depth, uint8_t ply,	     int *score, int *move);short TTGetPV (uint8_t side, uint8_t ply, int score, int *move);void TTClear (void);void PTClear (void);/*  Sorting routines  */void SortCaptures (int);void SortMoves (int);void SortRoot (void);int PhasePick (leaf **, int);int PhasePick1 (leaf **, int);/*  Some output routines */void ShowMoveList (int);void ShowSmallBoard (void);void ShowBoard (void);void ShowBitBoard (BitBoard *);void ShowCBoard (void);void ShowMvboard (void);void ShowGame (void);void ShowTime (void);/*  Random numbers routines */uint32_t Rand32 (void);HashType Rand64 (void);/*  Solver routines  */void Solve (char *);/*  Test routines  */void TestMoveGenSpeed (void);void TestNonCaptureGenSpeed (void);void TestCaptureGenSpeed (void);void TestMoveList (void);void TestNonCaptureList (void);void TestCaptureList (void);void TestEvalSpeed (void);void TestEval (void);/* Player database */void DBSortPlayer (const char *style);void DBListPlayer (const char *style); 	void DBReadPlayer (void);	void DBWritePlayer (void);int DBSearchPlayer (const char *player);void DBUpdatePlayer (const char *player, const char *resultstr);void DBTest (void);/* Input thread and thread function */#include <pthread.h>extern pthread_t input_thread;void *input_func(void *);/* * Status variable used by the input thread to signal * pending input. Thought about using flags for this * but this can be refined and is conceptually different * from flags. */enum {  INPUT_NONE,  INPUT_AVAILABLE};extern volatile int input_status;/* * Function to wake up the input thread, should be called after * input has been parsed. */void input_wakeup(void);/* Wait for input. */void wait_for_input(void);/* * Input routine, initialized to one of the specific * input routines. The given argument is the prompt. */void (*getline) (char *);#define MAXSTR 128extern char inputstr[MAXSTR];/* Input parser */void parse_input(void);/* Pondering */void ponder(void);/*  The command subroutines */void ShowCmd (char *);void BookCmd (char *);void TestCmd (char *);/* Commands from the input engine */void cmd_accepted(void);void cmd_activate(void); void cmd_analyze(void);void cmd_bk(void);void cmd_black(void);void cmd_book(void);void cmd_computer(void);void cmd_depth(void);void cmd_draw(void);void cmd_easy(void);void cmd_edit(void); void cmd_epd(void);void cmd_exit(void);void cmd_force(void);void cmd_go(void);void cmd_hard(void);void cmd_hash(void);void cmd_hashsize(void);void cmd_help (void);void cmd_hint(void);void cmd_level(void);void cmd_list(void);void cmd_load(void);void cmd_manual(void);void cmd_movenow(void);void cmd_name(void);void cmd_new(void);void cmd_nopost(void);void cmd_null(void);void cmd_otim(void);void cmd_pgnload(void);void cmd_pgnsave(void);void cmd_ping(void);void cmd_post(void);void cmd_protover(void);void cmd_quit(void);void cmd_random(void);void cmd_rating(void);void cmd_rejected(void);void cmd_remove(void);void cmd_result(void);void cmd_save(void);void cmd_setboard(void);void cmd_show (void);void cmd_solve(void);void cmd_st(void); void cmd_switch(void);void cmd_test (void);void cmd_time(void);void cmd_undo(void);void cmd_usage(void);void cmd_variant(void);void cmd_version(void);void cmd_white(void);void cmd_xboard(void);/* * Define NO_INLINE only if you really must, implementations will be * provided by the corresponding *.c files. The better solution is to * not define it, in which case inlines.h will be included which * provides static inline version of these functions. *//*  Some utility routines  */#ifdef NO_INLINEunsigned char leadz (BitBoard);unsigned char nbits (BitBoard);#else# include "inlines.h"#endif/* More elaborate debugging output to logfile *//* All the following functions are no-ops if DEBUG is not defined *//* * dbg_open() can be called with NULL as argument, using a default * filename, defined in debug.c, for the debug log. Otherwise the * argument is the filename. If dbg_open() fails or is not called at * all, debugging output goes to stderr by default. */int dbg_open(const char *name);/* Same format rules as printf() */int dbg_printf(const char *fmt, ...);/* Closes the debugging log, if it is not stderr */int dbg_close(void);# ifdef DEBUG#  include <assert.h>#  define ASSERT(x) assert(x)# else#  define ASSERT(x)# endif#endif /* !COMMON_H */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -