Merge pull request #13 from rektdie/fail_soft

This commit was merged in pull request #13.
This commit is contained in:
rektdie authored and GitHub committed 2025-03-09 09:35:27 +01:00
commit 9d3de4ecdc
4 files changed
+21 -86

No files matched your search

-65
View File
@@ -1,65 +0,0 @@
![Eleanor](https://i.ibb.co/T1ZV9wN/91dea356-a725-45fd-b7a2-cd92afddcba4-1.jpg)
# Eleanor is a chess engine
## Features
- Bitboard board representation
- Magic Bitboards
- Legal move generation
- Precalculated attack tables
- Storing moves in a 16 bit word
- Copy/make moving
- Simple evaluation (material and piece-square tables, MVV-LVA)
- Principal Variation Search
- Move ordering
- Time management
- UCI
## Installation
> Prerequisites:
> - A C++ compiler
> - Access to `make` command
1. Clone the repo to your PC
2. Run the command `make` in the root directory
> You can specify the compiler with the flag `CXX`
> and the executable name with `EXE`.
> By default they are `g++` and `Eleanor` respectively.
3. Run the executable
## How to use
There are some commands that you can use the engine with.
- **`position`**: Set the current position of the board with [FEN](https://www.chess.com/terms/fen-chess).
`position [FEN]` or `position startpos` can be used.
- **`ucinewgame`** resets the position and game state
- **`quit`** terminates the program
- **`go`** is the command that asks what is the best move in the current position (search),
but we have to give it some parameters:
`wtime` `btime` `winc` `binc`
The first letter tells the color of player
wtime sets the remaining time of the white player
and winc sets the increments for the white player.
**It's important that these parameters are given in milliseconds!**
- **`stop`** stops the current search
- **`bench`** tests the search speed of the engine on a set of positions
Also, the engine can be connected to any GUI software that has UCI support.
## Sources I used
[Chess Programming Wiki](https://www.chessprogramming.org/Main_Page "Chess Programming Wiki")
[Maksim Korzh's chess engine in C series](https://www.youtube.com/watch?v=QUNP-UjujBM&list=PLmN0neTso3Jxh8ZIylk74JpwfiWNI76Cs "Maksim Korzh's chess engine in C series")
[Stockfish discord helping community](https://discord.com/invite/GWDRS3kU6R "Stockfish discord community")
[Logo is generated by AI](https://deepai.org/ "Logo is generated by AI")
<hr>
**The project is still in progress and developed constantly. Contributions are highly appreciated.**
###### Last edited: 2025-01-23
+1
View File
@@ -334,6 +334,7 @@ void Board::Promote(int square, int pieceType, int color, bool isCapture) {
}
void Board::MakeMove(Move move) {
nodes++;
// Null Move
if (!move) {
+18 -19
View File
@@ -94,16 +94,16 @@ static SearchResults Quiescence(Board board, int alpha, int beta) {
}
}
nodes++;
int staticScore = Evaluate(board);
if (staticScore >= beta) {
return beta;
int bestScore = staticScore;
if (bestScore>= beta) {
return bestScore;
}
if (staticScore > alpha) {
alpha = staticScore;
if (alpha < bestScore) {
alpha = bestScore;
}
GenerateMoves(board, board.sideToMove);
@@ -119,9 +119,11 @@ static SearchResults Quiescence(Board board, int alpha, int beta) {
int score = -Quiescence(copy, -beta, -alpha).score;
if (score >= beta) {
return beta;
return score;
}
bestScore = std::max(score, bestScore);
if (score > alpha) {
alpha = score;
results.bestMove = board.moveList[i];
@@ -129,7 +131,7 @@ static SearchResults Quiescence(Board board, int alpha, int beta) {
}
}
results.score = alpha;
results.score = bestScore;
if (searchStopped) return 0;
return results;
}
@@ -153,10 +155,10 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
}
}
const int staticEval = Evaluate(board);
if (depth <= 0) return Quiescence(board, alpha, beta);
const int staticEval = Evaluate(board);
if (board.InCheck(board.sideToMove)) {
depth++;
} else {
@@ -184,14 +186,11 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
}
}
}
}
int score = -inf;
int nodeType = AllNode;
nodes++;
GenerateMoves(board, board.sideToMove);
SortMoves(board);
@@ -203,7 +202,7 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
}
}
SearchResults results;
SearchResults results(-inf);
// For all moves
for (int i = 0; i < board.currentMoveIndex; i++) {
@@ -235,10 +234,12 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
killerMoves[1][ply] = killerMoves[0][ply];
killerMoves[0][ply] = board.moveList[i];
WriteEntry(board.hashKey, depth, beta, CutNode, Move());
return beta;
WriteEntry(board.hashKey, depth, score, CutNode, Move());
return score;
}
results.score = std::max(score, results.score);
if (score > alpha) {
nodeType = PV;
alpha = score;
@@ -246,8 +247,6 @@ SearchResults PVS(Board board, int depth, int alpha, int beta) {
}
}
results.score = alpha;
WriteEntry(board.hashKey, depth, results.score, nodeType, results.bestMove);
if (searchStopped) return 0;
return results;
@@ -330,4 +329,4 @@ void SearchPosition(Board &board, SearchParams params) {
void StopSearch() {
searchStopped = true;
}
}
+2 -2
View File
@@ -87,9 +87,9 @@ SearchResults ReadEntry(U64 &hashKey, int depth, int alpha, int beta) {
if (current->nodeType == PV){
return {current->score, current->bestMove};
} else if (current->nodeType == AllNode && current->score <= alpha) {
return alpha;
return current->score;
} else if (current->nodeType == CutNode && current->score >= beta) {
return beta;
return current->score;
}
}
}