Skip to content

Commit

Permalink
Time bug fix (#23)
Browse files Browse the repository at this point in the history
Fixed an issue where we use the move of the current depth when not all moves of that depth were searched.
  • Loading branch information
nguyenphuminh authored Oct 3, 2024
1 parent feca224 commit f9ab353
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion catto.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = {
// Current version to show in UCI
version: "v0.12.2",
version: "v0.12.3",
// Late move reduction config
lmrFullDepth: 4, // Number of moves to be searched in full depth
lmrMaxReduction: 3, // Only apply LMR above this depth
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "catto",
"version": "0.12.2",
"version": "0.12.3",
"description": "The Catto chess engine",
"main": "index.js",
"scripts": {
Expand Down
8 changes: 7 additions & 1 deletion src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,8 @@ export class Engine {
}

findMove() {
let bestMove = "";

// Iterative deepening with aspiration windows
this.startTime = Date.now();

Expand Down Expand Up @@ -550,8 +552,12 @@ export class Engine {
console.log(`info depth ${depth} score cp ${Math.round(score)} time ${Date.now() - this.startTime} nodes ${this.nodes} pv${pv}`);
}
}

// This is used to prevent cases where moves at a depth is not completely searched.
// We will just use the best move of previous depth if time is up or forced-stopped.
bestMove = this.pvTable[0][0];
}

console.log(`bestmove ${this.pvTable[0][0]}`);
console.log(`bestmove ${bestMove}`);
}
}

0 comments on commit f9ab353

Please sign in to comment.