io-chess
UCI chess engine
Loading...
Searching...
No Matches
Types.h
Go to the documentation of this file.
1#pragma once
2
10
11#include "chess.hpp"
12
13// Type aliases for cleaner code
14using Board = chess::Board;
15using Move = chess::Move;
16using Movelist = chess::Movelist;
17using Color = chess::Color;
18using Square = chess::Square;
19using Piece = chess::Piece;
20using PieceType = chess::PieceType;
21using Bitboard = chess::Bitboard;
22using File = chess::File;
23using Rank = chess::Rank;
24
33namespace SearchConstants {
34constexpr int INFINITE = 32000;
35constexpr int MATE_SCORE = 31500;
36constexpr int MATE_IN_MAX = MATE_SCORE - 300;
37constexpr int TB_WIN_SCORE = 31000;
38constexpr int TB_WIN_IN_MAX = TB_WIN_SCORE - 800;
39constexpr int DRAW_SCORE = 0;
40constexpr int CONTEMPT_FACTOR = 5;
41
42// TT Flags
43constexpr uint8_t TT_EXACT = 0;
44constexpr uint8_t TT_ALPHA = 1;
45constexpr uint8_t TT_BETA = 2;
46
47// Search defaults
48constexpr int DEFAULT_DEPTH = 100;
49constexpr int MAX_PLY = 128;
50constexpr int LMR_MIN_DEPTH = 3;
51constexpr int NULL_MOVE_MIN_DEPTH = 4;
52
53// Extension limits
54constexpr int MAX_EXTENSIONS = 8;
55
56// Sentinel for invalid static eval
57constexpr int16_t INVALID_EVAL = 32001;
58} // namespace SearchConstants
59
64namespace MoveOrderConstants {
65constexpr int16_t HASH_MOVE_SCORE = 30000;
66constexpr int16_t CAPTURE_BASE = 10000;
67constexpr int16_t KILLER_SCORE_1 = 9000;
68constexpr int16_t KILLER_SCORE_2 = 8000;
69constexpr int16_t HISTORY_MAX = 8000;
70} // namespace MoveOrderConstants
71
76namespace MoveGen {
77
84inline void generateLegalMoves(Movelist &moves, const Board &board) {
85 chess::movegen::legalmoves(moves, board);
86}
87
94inline void generateCaptures(Movelist &moves, const Board &board) {
95 chess::movegen::legalmoves<chess::movegen::MoveGenType::CAPTURE>(moves, board);
96}
97} // namespace MoveGen
chess::Move Move
Alias for chess::Move.
Definition Types.h:15
chess::PieceType PieceType
Alias for chess::PieceType.
Definition Types.h:20
chess::Color Color
Alias for chess::Color.
Definition Types.h:17
chess::Piece Piece
Alias for chess::Piece.
Definition Types.h:19
chess::Bitboard Bitboard
Alias for chess::Bitboard.
Definition Types.h:21
chess::Rank Rank
Alias for chess::Rank.
Definition Types.h:23
chess::Square Square
Alias for chess::Square.
Definition Types.h:18
chess::Movelist Movelist
Alias for chess::Movelist.
Definition Types.h:16
chess::File File
Alias for chess::File.
Definition Types.h:22
chess::Board Board
Alias for chess::Board.
Definition Types.h:14
Utility wrappers for legal and capture move generation.
void generateCaptures(Movelist &moves, const Board &board)
Generates only legal capture and promotion moves for the given board state.
Definition Types.h:94
void generateLegalMoves(Movelist &moves, const Board &board)
Generates all pseudo-legal and legal moves for the given board state.
Definition Types.h:84
Scores used to sort moves during the move picking phase.
constexpr int16_t HISTORY_MAX
Maximum possible history heuristic score.
Definition Types.h:69
constexpr int16_t HASH_MOVE_SCORE
Highest priority for moves retrieved from the Transposition Table.
Definition Types.h:65
constexpr int16_t KILLER_SCORE_2
Score for the secondary killer move.
Definition Types.h:68
constexpr int16_t KILLER_SCORE_1
Score for the primary killer move.
Definition Types.h:67
constexpr int16_t CAPTURE_BASE
Base score for captures, adjusted by MVV-LVA.
Definition Types.h:66
Global constants related to search and evaluation boundaries.
constexpr int TB_WIN_SCORE
Base score for a tablebase win.
Definition Types.h:37
constexpr int INFINITE
Absolute maximum score.
Definition Types.h:34
constexpr int MATE_IN_MAX
Threshold to detect mating sequences.
Definition Types.h:36
constexpr int DRAW_SCORE
Score for a draw position.
Definition Types.h:39
constexpr int TB_WIN_IN_MAX
Threshold to detect tablebase wins.
Definition Types.h:38
constexpr int16_t INVALID_EVAL
Special value indicating an uncomputed or invalid static evaluation.
Definition Types.h:57
constexpr int CONTEMPT_FACTOR
Make draws slightly negative to encourage winning.
Definition Types.h:40
constexpr uint8_t TT_BETA
Transposition table entry is a lower bound (failed high).
Definition Types.h:45
constexpr int MAX_PLY
Maximum supported plies from root.
Definition Types.h:49
constexpr uint8_t TT_EXACT
Transposition table entry is an exact score.
Definition Types.h:43
constexpr int LMR_MIN_DEPTH
Minimum depth to consider Late Move Reductions (LMR).
Definition Types.h:50
constexpr uint8_t TT_ALPHA
Transposition table entry is an upper bound (failed low).
Definition Types.h:44
constexpr int NULL_MOVE_MIN_DEPTH
Minimum depth to consider Null Move Pruning.
Definition Types.h:51
constexpr int MATE_SCORE
Base score for checkmate.
Definition Types.h:35
constexpr int MAX_EXTENSIONS
Maximum number of search extensions per path.
Definition Types.h:54
constexpr int DEFAULT_DEPTH
Default maximum depth for search.
Definition Types.h:48