Chess Engine
C++ chess engine with movegen, bitboards, and Arduino-friendly docs
|
#include <iostream>
#include "move_generator.h"
#include "make_move.h"
#include "../util/attack.h"
#include "../util/setup.h"
Go to the source code of this file.
Functions | |
static void | AddQuietMove (const S_BOARD *board, int move, S_MOVELIST *moveList) |
static void | AddCaptureMove (const S_BOARD *board, int move, S_MOVELIST *moveList) |
static void | AddEnPassantMove (const S_BOARD *board, int move, S_MOVELIST *moveList) |
static void | AddWhitePawnCapMove (const S_BOARD *board, int fromSq, int toSq, int captured, S_MOVELIST *moveList) |
static void | AddWhitePawnMove (const S_BOARD *board, int fromSq, int toSq, S_MOVELIST *moveList) |
static void | AddBlackPawnCapMove (const S_BOARD *board, int fromSq, int toSq, int captured, S_MOVELIST *moveList) |
static void | AddBlackPawnMove (const S_BOARD *board, int fromSq, int toSq, S_MOVELIST *moveList) |
void | InitMvvLva () |
Initialize the MVV-LVA capture scoring table. | |
int | moveExists (S_BOARD *board, const int move) |
Check if a given move exists in the current position. | |
void | generateAllMoves (const S_BOARD *board, S_MOVELIST *moveList) |
Generate all pseudo-legal moves for the side to move. | |
void | generateAllCaptures (const S_BOARD *board, S_MOVELIST *moveList) |
Generate all pseudo-legal capture moves (including en passant). |
Variables | |
const int | LoopSlidePce [8] = { wB, wR, wQ, 0, bB, bR, bQ, 0 } |
Sliding piece loop order for move generation. | |
const int | LoopNonSlidePce [6] = { wN, wK, 0, bN, bK, 0 } |
Non-sliding piece loop order for move generation. | |
const int | LoopSlideIndex [2] = { 0, 4 } |
Indices into LoopSlidePce for white and black. | |
const int | LoopNonSlideIndex [2] = { 0, 3 } |
Indices into LoopNonSlidePce for white and black. | |
const int | pieceDirection [13][8] |
Direction offsets for each piece type. | |
const int | numberDirections [13] = { 0, 0, 8, 4, 4, 8, 8, 0, 8, 4, 4, 8, 8 } |
Number of valid directions for each piece type. | |
const int | VictimScore [13] = { 0,100,200,300,400,500,600,100,200,300,400,500,600 } |
Victim scoring table for MVV-LVA. | |
static int | MvvLvaScores [13][13] |
|
static |
Definition at line 109 of file move_generator.cpp.
References AddCaptureMove(), ASSERT, bB, bN, bQ, bR, EMPTY, isBoardStateValid(), MOVE, pieceValueidEmpty(), RANK_2, rankIndex120, and SqOnBoard().
Referenced by generateAllCaptures(), and generateAllMoves().
|
static |
Definition at line 125 of file move_generator.cpp.
References AddQuietMove(), ASSERT, bB, bN, bQ, bR, EMPTY, isBoardStateValid(), MOVE, RANK_2, rankIndex120, and SqOnBoard().
Referenced by generateAllMoves().
|
static |
Definition at line 53 of file move_generator.cpp.
References ASSERT, CAPTURED, S_MOVELIST::count, FROMSQ, isBoardStateValid(), S_MOVE::move, S_MOVELIST::moves, MvvLvaScores, S_BOARD::pieces, pieceValueid(), SqOnBoard(), and TOSQ.
Referenced by AddBlackPawnCapMove(), AddWhitePawnCapMove(), generateAllCaptures(), and generateAllMoves().
|
static |
Definition at line 65 of file move_generator.cpp.
References ASSERT, BLACK, S_MOVELIST::count, FROMSQ, isBoardStateValid(), S_MOVE::move, S_MOVELIST::moves, RANK_3, RANK_6, rankIndex120, S_BOARD::side, SqOnBoard(), TOSQ, and WHITE.
Referenced by generateAllCaptures(), and generateAllMoves().
|
static |
Definition at line 34 of file move_generator.cpp.
References ASSERT, S_MOVELIST::count, FROMSQ, isBoardStateValid(), MAXDEPTH, S_MOVE::move, S_MOVELIST::moves, S_BOARD::pieces, S_BOARD::ply, S_BOARD::searchHistory, S_BOARD::searchKillers, SqOnBoard(), and TOSQ.
Referenced by AddBlackPawnMove(), AddWhitePawnMove(), and generateAllMoves().
|
static |
Definition at line 78 of file move_generator.cpp.
References AddCaptureMove(), ASSERT, EMPTY, isBoardStateValid(), MOVE, pieceValueidEmpty(), RANK_7, rankIndex120, SqOnBoard(), wB, wN, wQ, and wR.
Referenced by generateAllCaptures(), and generateAllMoves().
|
static |
Definition at line 94 of file move_generator.cpp.
References AddQuietMove(), ASSERT, EMPTY, isBoardStateValid(), MOVE, RANK_7, rankIndex120, SqOnBoard(), wB, wN, wQ, and wR.
Referenced by generateAllMoves().
void generateAllCaptures | ( | const S_BOARD * | pos, |
S_MOVELIST * | list ) |
Generate all pseudo-legal capture moves (including en passant).
pos | Pointer to the current board position. |
list | Pointer to the move list to be filled. |
Definition at line 299 of file move_generator.cpp.
References AddBlackPawnCapMove(), AddCaptureMove(), AddEnPassantMove(), AddWhitePawnCapMove(), ASSERT, BLACK, bP, S_MOVELIST::count, EMPTY, S_BOARD::enPas, isBoardStateValid(), LoopNonSlideIndex, LoopNonSlidePce, LoopSlideIndex, LoopSlidePce, MFLAGEP, MOVE, MoveListOk(), NO_SQ, numberDirections, S_BOARD::pceNum, pieceColor, pieceDirection, S_BOARD::pieces, pieceValueid(), S_BOARD::pList, S_BOARD::side, SQOFFBOARD, SqOnBoard(), WHITE, and wP.
void generateAllMoves | ( | const S_BOARD * | pos, |
S_MOVELIST * | list ) |
Generate all pseudo-legal moves for the side to move.
pos | Pointer to the current board position. |
list | Pointer to the move list to be filled. |
Definition at line 165 of file move_generator.cpp.
References AddBlackPawnCapMove(), AddBlackPawnMove(), AddCaptureMove(), AddEnPassantMove(), AddQuietMove(), AddWhitePawnCapMove(), AddWhitePawnMove(), ASSERT, B1, B8, BKCA, BLACK, bP, BQCA, C1, C8, S_BOARD::castlePerm, S_MOVELIST::count, D1, D8, E1, E8, EMPTY, S_BOARD::enPas, F1, F8, G1, G8, isBoardStateValid(), isSquareAttacked(), LoopNonSlideIndex, LoopNonSlidePce, LoopSlideIndex, LoopSlidePce, MFLAGCA, MFLAGEP, MFLAGPS, MOVE, MoveListOk(), NO_SQ, numberDirections, S_BOARD::pceNum, pieceColor, pieceDirection, S_BOARD::pieces, pieceValueid(), S_BOARD::pList, RANK_2, RANK_7, rankIndex120, S_BOARD::side, SQOFFBOARD, SqOnBoard(), WHITE, WKCA, wP, and WQCA.
Referenced by LegalMovesFrom(), moveExists(), parseMoveString(), Perft(), and PerftTest().
void InitMvvLva | ( | void | ) |
Initialize the MVV-LVA capture scoring table.
Definition at line 141 of file move_generator.cpp.
References bK, MvvLvaScores, VictimScore, and wP.
Referenced by initializeEngine().
int moveExists | ( | S_BOARD * | pos, |
int | move ) |
Check if a given move exists in the current position.
pos | Pointer to the current board position. |
move | Encoded move integer. |
Definition at line 149 of file move_generator.cpp.
References S_MOVELIST::count, FALSE, generateAllMoves(), makeMove(), S_MOVE::move, S_MOVELIST::moves, takeMove(), and TRUE.
const int LoopNonSlideIndex[2] = { 0, 3 } |
Indices into LoopNonSlidePce for white and black.
Definition at line 10 of file move_generator.cpp.
Referenced by generateAllCaptures(), and generateAllMoves().
Non-sliding piece loop order for move generation.
Definition at line 8 of file move_generator.cpp.
Referenced by generateAllCaptures(), and generateAllMoves().
const int LoopSlideIndex[2] = { 0, 4 } |
Indices into LoopSlidePce for white and black.
Definition at line 9 of file move_generator.cpp.
Referenced by generateAllCaptures(), and generateAllMoves().
Sliding piece loop order for move generation.
Definition at line 7 of file move_generator.cpp.
Referenced by generateAllCaptures(), and generateAllMoves().
|
static |
Definition at line 31 of file move_generator.cpp.
Referenced by AddCaptureMove(), and InitMvvLva().
const int numberDirections[13] = { 0, 0, 8, 4, 4, 8, 8, 0, 8, 4, 4, 8, 8 } |
Number of valid directions for each piece type.
Definition at line 28 of file move_generator.cpp.
Referenced by generateAllCaptures(), and generateAllMoves().
const int pieceDirection[13][8] |
Direction offsets for each piece type.
Definition at line 12 of file move_generator.cpp.
Referenced by generateAllCaptures(), and generateAllMoves().
const int VictimScore[13] = { 0,100,200,300,400,500,600,100,200,300,400,500,600 } |
Victim scoring table for MVV-LVA.
Definition at line 30 of file move_generator.cpp.
Referenced by InitMvvLva().