
I have a little bit done so far that is similar to what I have done already but hopefully the code is a little cleaner. And maybe a bit faster. As always I use C++ as a better C. I do not use classes. It is not that I don't like classes. It is because I can't keep them in my memory long enough to be able to program with them. I have to operate within my limitations.
Some definitions
Code: Select all
// !!
// A Chess Engine
// By Michael Sherwin
#include <stdint.h>
#include <bit>
#define defines
#ifdef defines
typedef int8_t s08;
typedef int32_t s32;
typedef uint64_t u64;
constexpr s32 maxThreads = 4;
constexpr u64 one = 1ull;
constexpr s32 valp = 100;
constexpr s32 valn = 290;
constexpr s32 valb = 320;
constexpr s32 valr = 500;
constexpr s32 valq = 960;
constexpr s32 na = 0;
constexpr u64 file_b2_b7 = 0x0002020202020200;
constexpr u64 file_a2_a7 = 0x0001010101010100;
constexpr u64 diag_c2_h7 = 0x0080402010080400;
constexpr u64 occ_w_s = 0x0000000000000060;
constexpr u64 occ_w_l = 0x000000000000000e;
constexpr u64 occ_b_s = 0x6000000000000000;
constexpr u64 occ_b_l = 0x0e00000000000000;
constexpr u64 atk_w_s = 0x0000000000000070;
constexpr u64 atk_w_l = 0x000000000000001c;
constexpr u64 atk_b_s = 0x7000000000000000;
constexpr u64 atk_b_l = 0x1c00000000000000;
enum { EXIT, GETCMD, SEARCH, MOVE, RESIGN };
enum { BLACK, WHITE };
enum {
WP2, WP3, WP4, WP5, WP6, WP7, WN, WB, WRC, WR, WQ, WKC, WK,
ES,
BP7, BP6, BP5, BP4, BP3, BP2, BN, BB, BRC, BR, BQ, BKC, BK,
WPQ, WPN, WPR, WPB, WCS, WCL,
BPQ, BPN, BPR, BPB, BCS, BCL
};
enum { RANK1, RANK2, RANK3, RANK4, RANK5, RANK6, RANK7, RANK8 };
enum { FILEa, FILEb, FILEc, FILEd, FILEe, FILEf, FILEg, FILEh };
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
};
struct sMove {
s08 fs;
s08 ts;
s08 ft;
s08 tt;
s32 sc;
};
union uMove {
sMove s;
u64 u;
};
struct Thread {
u64 occupied[2];
u64 pawns[2];
u64 knights[2];
u64 bishops[2];
u64 rooks[2];
u64 queens[2];
u64 kings[2];
u64 epsq;
u64* occType[27];
s32 board[64];
s32 stm;
s32 otm;
s32 sly;
s32 gly;
s32 mat[2];
s32 pos[2];
};
#define occupied t->occupied
#define pawns t->pawns
#define knights t->knights
#define bishops t->bishops
#define rooks t->rooks
#define queens t->queens
#define kings t->kings
#define epsq t->epsq
#define occType t->occType
#define board t->board
#define stm t->stm
#define otm t->otm
#define sly t->sly
#define gly t->gly
#define mat t->mat
#define pos t->pos
#endif