Skip to content

Commit

Permalink
Hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
nguyenphuminh authored Oct 4, 2024
1 parent f9ab353 commit 01890fa
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -508,24 +508,23 @@ export class Engine {
}

findMove() {
let bestMove = "";

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

let alpha = -INFINITY, beta = INFINITY, score = 0;
let alpha = -INFINITY, beta = INFINITY, score = 0, bestMove = "";

for (let depth = 1; depth <= this.searchDepth; depth++) {
// Stop searching if forced to stop or timeout
if (this.stopped || Date.now() - this.startTime > this.timeout) {
break;
}

// Reset collect PV flag
this.collectPV = true;

// Find moves
score = this.negamax(depth, alpha, beta, 0);

// Handle timeouts
if (this.stopped || Date.now() - this.startTime > this.timeout) {
break;
}

// Fell out of window
if (score <= alpha || score >= beta) {
alpha = -INFINITY;
Expand Down
2 changes: 1 addition & 1 deletion src/uci.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class UCI {
}

if (command.startsWith("go")) {
this.handleGo(command);
setImmediate(() => this.handleGo(command));
}
}
})
Expand Down

0 comments on commit 01890fa

Please sign in to comment.