Chess Engine
C++ chess engine with movegen, bitboards, and Arduino-friendly docs
|
#include "defs.h"
#include <cstdio>
#include "make_move.h"
#include "../util/attack.h"
#include "../util/setup.h"
Go to the source code of this file.
Macros | |
#define | HASH_PCE(pce, sq) |
#define | HASH_CA (board->posKey ^= (zobristCastleKeys[(board->castlePerm)])) |
#define | HASH_SIDE (board->posKey ^= (zobristSideKey)) |
#define | HASH_EP (board->posKey ^= (zobristPieceKeys[EMPTY][(board->enPas)])) |
Functions | |
static void | ClearPiece (const int sq, S_BOARD *board) |
static void | AddPiece (const int sq, S_BOARD *board, const int piece) |
static void | MovePiece (const int from, const int to, S_BOARD *board) |
int | makeMove (S_BOARD *board, int move) |
Make a move; returns non-zero if legal (king not left in check). | |
void | takeMove (S_BOARD *board) |
Undo the last made move. | |
void | makeNullMove (S_BOARD *board) |
Make a null move (side to move toggles, no pieces moved). | |
void | takeNullMove (S_BOARD *board) |
Undo the last null move. |
Variables | |
const int | CastlePerm [120] |
Castling permission mask by board square (mailbox 120). |
#define HASH_CA (board->posKey ^= (zobristCastleKeys[(board->castlePerm)])) |
Definition at line 10 of file make_move.cpp.
Referenced by makeMove(), and takeMove().
#define HASH_EP (board->posKey ^= (zobristPieceKeys[EMPTY][(board->enPas)])) |
Definition at line 12 of file make_move.cpp.
Referenced by makeMove(), makeNullMove(), takeMove(), and takeNullMove().
#define HASH_PCE | ( | pce, | |
sq ) |
Definition at line 9 of file make_move.cpp.
Referenced by AddPiece(), ClearPiece(), and MovePiece().
#define HASH_SIDE (board->posKey ^= (zobristSideKey)) |
Definition at line 11 of file make_move.cpp.
Referenced by makeMove(), makeNullMove(), takeMove(), and takeNullMove().
|
static |
Definition at line 72 of file make_move.cpp.
References ASSERT, S_BOARD::bigPce, BOTH, HASH_PCE, isBigPiece, isMajorPiece, S_BOARD::majPce, S_BOARD::material, S_BOARD::minPce, S_BOARD::pawns, S_BOARD::pceNum, pieceColor, S_BOARD::pieces, pieceValue, pieceValueid(), S_BOARD::pList, SETBIT, SideValid(), SQ64, and SqOnBoard().
Referenced by makeMove(), and takeMove().
|
static |
Definition at line 30 of file make_move.cpp.
References ASSERT, S_BOARD::bigPce, BOTH, CLRBIT, EMPTY, HASH_PCE, isBigPiece, isBoardStateValid(), isMajorPiece, S_BOARD::majPce, S_BOARD::material, S_BOARD::minPce, S_BOARD::pawns, S_BOARD::pceNum, pieceColor, S_BOARD::pieces, pieceValue, pieceValueid(), S_BOARD::pList, SideValid(), SQ64, and SqOnBoard().
Referenced by makeMove(), and takeMove().
int makeMove | ( | S_BOARD * | board, |
int | move ) |
Make a move; returns non-zero if legal (king not left in check).
Definition at line 142 of file make_move.cpp.
References A1, A8, AddPiece(), ASSERT, C1, C8, CAPTURED, CastlePerm, S_BOARD::castlePerm, S_UNDO::castlePerm, ClearPiece(), D1, D8, EMPTY, S_BOARD::enPas, S_UNDO::enPas, F1, F8, FALSE, S_BOARD::fiftyMove, S_UNDO::fiftyMove, FROMSQ, G1, G8, H1, H8, HASH_CA, HASH_EP, HASH_SIDE, S_BOARD::hisPly, S_BOARD::history, isBoardStateValid(), isKing, isPawn, isSquareAttacked(), S_BOARD::KingSq, MAXDEPTH, MAXGAMEMOVES, MFLAGCA, MFLAGEP, MFLAGPS, S_UNDO::move, MovePiece(), NO_SQ, S_BOARD::pieces, pieceValueid(), S_BOARD::ply, S_BOARD::posKey, S_UNDO::posKey, PROMOTED, RANK_3, RANK_6, rankIndex120, S_BOARD::side, SideValid(), SqOnBoard(), takeMove(), TOSQ, TRUE, and WHITE.
Referenced by LegalMovesFrom(), moveExists(), Perft(), and PerftTest().
void makeNullMove | ( | S_BOARD * | board | ) |
Make a null move (side to move toggles, no pieces moved).
Definition at line 303 of file make_move.cpp.
References ASSERT, S_BOARD::castlePerm, S_UNDO::castlePerm, S_BOARD::enPas, S_UNDO::enPas, S_BOARD::fiftyMove, S_UNDO::fiftyMove, HASH_EP, HASH_SIDE, S_BOARD::hisPly, S_BOARD::history, isBoardStateValid(), isSquareAttacked(), S_BOARD::KingSq, MAXDEPTH, MAXGAMEMOVES, S_UNDO::move, NO_SQ, NOMOVE, S_BOARD::ply, S_BOARD::posKey, S_UNDO::posKey, and S_BOARD::side.
|
static |
Definition at line 99 of file make_move.cpp.
References ASSERT, BOTH, CLRBIT, EMPTY, HASH_PCE, isBigPiece, S_BOARD::pawns, S_BOARD::pceNum, pieceColor, S_BOARD::pieces, pieceValueid(), S_BOARD::pList, SETBIT, SideValid(), SQ64, and SqOnBoard().
Referenced by makeMove(), and takeMove().
void takeMove | ( | S_BOARD * | board | ) |
Undo the last made move.
Definition at line 240 of file make_move.cpp.
References A1, A8, AddPiece(), ASSERT, bP, C1, C8, CAPTURED, S_BOARD::castlePerm, S_UNDO::castlePerm, ClearPiece(), D1, D8, EMPTY, S_BOARD::enPas, S_UNDO::enPas, F1, F8, FALSE, S_BOARD::fiftyMove, S_UNDO::fiftyMove, FROMSQ, G1, G8, H1, H8, HASH_CA, HASH_EP, HASH_SIDE, S_BOARD::hisPly, S_BOARD::history, isBoardStateValid(), isKing, isPawn, S_BOARD::KingSq, MAXDEPTH, MAXGAMEMOVES, MFLAGCA, MFLAGEP, S_UNDO::move, MovePiece(), NO_SQ, pieceColor, S_BOARD::pieces, pieceValueid(), S_BOARD::ply, PROMOTED, S_BOARD::side, SqOnBoard(), TOSQ, WHITE, and wP.
Referenced by LegalMovesFrom(), makeMove(), moveExists(), Perft(), and PerftTest().
void takeNullMove | ( | S_BOARD * | board | ) |
Undo the last null move.
Definition at line 327 of file make_move.cpp.
References ASSERT, S_BOARD::castlePerm, S_UNDO::castlePerm, S_BOARD::enPas, S_UNDO::enPas, S_BOARD::fiftyMove, S_UNDO::fiftyMove, HASH_EP, HASH_SIDE, S_BOARD::hisPly, S_BOARD::history, isBoardStateValid(), MAXDEPTH, MAXGAMEMOVES, NO_SQ, S_BOARD::ply, and S_BOARD::side.
const int CastlePerm[120] |
Castling permission mask by board square (mailbox 120).
Definition at line 14 of file make_move.cpp.
Referenced by makeMove().