change logging api to accept variadic properties

This commit is contained in:
JOLIMAITRE Matthieu 2024-05-02 16:14:15 +02:00
parent 336efff5c1
commit aab2e60dab
7 changed files with 61 additions and 23 deletions

View file

@ -18,10 +18,14 @@ export class ReducingGuesser implements Guessing {
this.candidates = new Set(this.words.values());
}
public async guess(try_: (guess: string, known: string) => Awaitable<GuessResult>) {
if (this.candidates.size === 1) return await try_(first(this.candidates)!, "");
public declare_properties() {
return ["candidates"];
}
public async guess(try_: (guess: string, candidates: number) => Awaitable<GuessResult>) {
if (this.candidates.size === 1) return await try_(first(this.candidates)!, this.candidates.size);
const guess = get_word_with_smallest_cuts(this.candidates, this.words);
const result = await try_(guess, "");
const result = await try_(guess, this.candidates.size);
if (result.kind === "success") return result;
this.learn(guess, result.informations);
return null;