Elo play level selection (#17)

* feat(play): switch engine UI and logic from skill level to Elo rating (100–3200)
This commit is contained in:
titanium_machine
2025-05-08 23:47:09 +02:00
committed by GitHub
parent 9245125e13
commit 1ac075f1f0
5 changed files with 40 additions and 35 deletions

View File

@@ -92,6 +92,20 @@ export class UciEngine {
this.multiPv = multiPv;
}
private async setLimitStrength(on: boolean) {
await this.broadcastCommands(
[`setoption name UCI_LimitStrength value ${on}`, "isready"],
"readyok"
);
}
private async setElo(elo: number) {
await this.broadcastCommands(
[`setoption name UCI_Elo value ${elo}`, "isready"],
"readyok"
);
}
private async setSkillLevel(skillLevel: number, initCase = false) {
if (!initCase) {
if (skillLevel === this.skillLevel) return;
@@ -352,11 +366,12 @@ export class UciEngine {
public async getEngineNextMove(
fen: string,
skillLevel: number,
elo: number,
depth = 16
): Promise<string | undefined> {
this.throwErrorIfNotReady();
await this.setSkillLevel(skillLevel);
await this.setLimitStrength(true);
await this.setElo(elo);
console.log(`Evaluating position: ${fen}`);