Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lichess-org/lila
Browse files Browse the repository at this point in the history
* 'master' of github.com:lichess-org/lila:
  use movetime for external engine
  • Loading branch information
ornicar committed Nov 17, 2023
2 parents 7b89c20 + 9d847b5 commit 40ee275
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions ui/ceval/src/engines/externalEngine.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Work, ExternalEngineInfo, CevalEngine, CevalState } from '../types';
import { randomToken } from 'common/random';
import { readNdJson } from 'common/ndjson';
import throttle from 'common/throttle';

interface ExternalEngineOutput {
time: number;
Expand Down Expand Up @@ -35,10 +36,13 @@ export class ExternalEngine implements CevalEngine {
start(work: Work) {
this.stop();
this.state = CevalState.Loading;
this.process(work);
}

process = throttle(700, work => {
this.req = new AbortController();
this.analyse(work, this.req.signal);
}
});

private async analyse(work: Work, signal: AbortSignal): Promise<void> {
try {
Expand All @@ -57,15 +61,14 @@ export class ExternalEngine implements CevalEngine {
sessionId: this.sessionId,
threads: work.threads,
hash: work.hashSize || 16,
infinite: true, // TODO WTF
movetime: work.searchMs === Number.POSITIVE_INFINITY ? 24 * 3600 * 1000 : work.searchMs,
multiPv: work.multiPv,
variant: work.variant,
initialFen: work.initialFen,
moves: work.moves,
},
}),
});

await readNdJson<ExternalEngineOutput>(res, line => {
this.state = CevalState.Computing;
work.emit({
Expand Down

0 comments on commit 40ee275

Please sign in to comment.