bpaul-chess

UCI chess engine to replace Omelette Chess Engine
Log | Files | Refs | README | LICENSE

pos.h (1329B)


      1 #ifndef POS_H
      2 #define POS_H
      3 
      4 enum { WHITE, BLACK };
      5 
      6 enum { PAWN, KNIGHT, BISHOP, ROOK, QUEEN, KING };
      7 
      8 /* Please format this better! */
      9 enum {  wP,     wN, wB, wR, wQ, wK,
     10 	bP = 8, bN, bB, bR, bQ, bK,
     11     nP /* No piece */
     12 };
     13 
     14 /* Square names enum */
     15 enum {
     16 	A1, B1, C1, D1, E1, F1, G1, H1,
     17     A2, B2, C2, D2, E2, F2, G2, H2,
     18     A3, B3, C3, D3, E3, F3, G3, H3,
     19     A4, B4, C4, D4, E4, F4, G4, H4,
     20     A5, B5, C5, D5, E5, F5, G5, H5,
     21     A6, B6, C6, D6, E6, F6, G6, H6,
     22     A7, B7, C7, D7, E7, F7, G7, H7,
     23     A8, B8, C8, D8, E8, F8, G8, H8,
     24     NO_SQ
     25 };
     26 
     27 typedef struct pos pos;
     28 typedef struct magic magic;
     29 
     30 struct pos {
     31 	bb sides[2];
     32 	bb pieces[6];
     33 	char mailbox[64]; /* Array of piece positions used for square lookup */
     34 	char castle;	/* Castling permissions flags */
     35 	char enpas;	/* En passant square */
     36 	unsigned char fifty;	/* Tracker for 50 move rule */
     37 	unsigned short game_length;	/* Track game length (hence the name) */
     38 	char turn;
     39 };
     40 
     41 struct magic {
     42 	bb mask;
     43 	bb *attacks;
     44 #ifdef MAGIC
     45 	/* I am going to do this later it is too much work */
     46 	unsigned long long magic;
     47 	char shift;
     48 #endif
     49 };
     50 
     51 void reset_board(pos *);
     52 void parse_fen(pos *, char *);
     53 #ifndef NDEBUG
     54 void print_board(pos *);
     55 #endif
     56 bb knight_att(char);
     57 bb king_att(char);
     58 bb bishop_att(char, bb);
     59 bb rook_att(char, bb);
     60 bb queen_att(char, bb);
     61 #endif