I'm using MSVS 2022 Community Edition, C++ as a better C.
***Protozoa.cpp*** // Just the files off the top of my head that I know will be needed.
Code: Select all
// Protozoa
// A Chess Engine
// By Michael Sherwin
// Protozoa.cpp
#include <stdint.h>
#include <bit>
#include "Defines.cpp"
#include "Globals.cpp"
#include "Utilities.cpp"
#include "Initialize.cpp"
#include "Evaluate.cpp"
#include "Move.cpp"
#include "GenerateMoves.cpp"
#include "GetCommand.cpp"
#include "Search.cpp"
#include "Main.cpp"
Code: Select all
// Protozoa
// A Chess Engine
// By Michael Sherwin
// Defines.cpp
typedef int8_t s08;
typedef uint8_t u08;
typedef int32_t s32;
typedef uint64_t u64;
constexpr auto ILLEGAL = 10000;
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 owcs = 0x0000000000000060; // Occupied as concerning White Castling Short
constexpr u64 owcl = 0x000000000000000e;
constexpr u64 obcs = 0x6000000000000000;
constexpr u64 obcl = 0x0e00000000000000;
constexpr u64 awcs = 0x0000000000000070; // Attacked as concerning White Castling Short
constexpr u64 awcl = 0x000000000000001c;
constexpr u64 abcs = 0x7000000000000000;
constexpr u64 abcl = 0x1c00000000000000;
enum { EXIT, GETCMD, SEARCH, MOVE , ANALYZE };
enum { BLACK, WHITE };
enum { FILEa, FILEb, FILEc, FILEd, FILEe, FILEf, FILEg, FILEh };
enum { RANK1, RANK2, RANK3, RANK4, RANK5, RANK6, RANK7, RANK8 };
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
};
// These are piece types and pseudo piece types
// WP2 - white pawn on rank 2
// WRC - white rook that can castle
// WKC - white king that can castle
// WPQ - white pawn that promotes to queen
// WCS - white castles short
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
};
struct sMove {
u08 fs; // from square
u08 ts; // to squart
u08 ft; // from type
u08 tt; // to type
s32 sc; // score
};
// So I don't have to type "->" all the time
#define mfs m->fs
#define mts m->ts
#define mft m->ft
#define mtt m->tt
#define msc m->sc
union uMove {
sMove s;
u64 u;
};
struct Thread {
u64 sides[2]; // bitboards for white and black pieces
u64 pawns[2]; // specific piece type bitboards
u64 knights[2];
u64 bishops[2];
u64 rooks[2];
u64 queens[2];
u64 kings[2];
u64* types[27]; // another way of accessing the piece types by pointer
u64 epbit[100];
s32 mat[2]; // material score
s32 pos[2]; // positional
u08 board[64]; // the chess board
u08 wptbl[64]; // WP piece Table
u08 bptbl[64];
u08 wntbl[64];
u08 bntbl[64];
u08 wbtbl[64];
u08 bbtbl[64];
u08 wrtbl[64];
u08 brtbl[64];
u08 wqtbl[64];
u08 bqtbl[64];
u08 wktbl[64];
u08 bktbl[64];
u08 estbl[64]; // empty square table all zero
u08* tbls[27]; // to access the tables by pointer
u08 stm; // side to move
u08 otm; // other side to move (maybe)
u08 ply;
};
#define sides t->sides
#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 types t->types
#define epbit t->epbit
#define mat t->mat
#define pos t->pos
#define board t->board
#define wptbl t->wptbl
#define bptbl t->bptbl
#define wntbl t->wntbl
#define bntbl t->bntbl
#define wbtbl t->wbtbl
#define bbtbl t->bbtbl
#define wrtbl t->wrtbl
#define brtbl t->brtbl
#define wqtbl t->wqtbl
#define bqtbl t->bqtbl
#define wktbl t->wktbl
#define bktbl t->bktbl
#define estbl t->estbl
#define tbls t->tbls
#define stm t->stm
#define otm t->otm
#define ply t->ply
Code: Select all
// Protozoa
// A Chess Engine
// By Michael Sherwin
// Main.cpp
s32 main() {
Initialize();
while (mode != EXIT) {
if (mode == GETCMD) GetCommand();
if (mode == SEARCH) StartSearch();
if (mode == MOVE) GameMove();
if (mode == ANALYZE) Analyze();
}
}