-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathstrategyRefreqyFlexBadGuesser.mjs
More file actions
23 lines (20 loc) · 1.08 KB
/
strategyRefreqyFlexBadGuesser.mjs
File metadata and controls
23 lines (20 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { Logger } from "./log.mjs";
import { StrategyOptionRate } from "./strategy.mjs";
import { StrategyRefreqyFlexDoubleRules } from "./strategyRefreqyFlexDoubleRules.mjs";
const DEFAULT_HIGH_SCORE_PERCENTILE = 0.95;
export class StrategyRefreqyFlexBadGuesser extends StrategyRefreqyFlexDoubleRules {
getSupportedOptions() {
return [
new StrategyOptionRate(
'highScorePercentile', DEFAULT_HIGH_SCORE_PERCENTILE,
'Percentile rank of word to pick, as a ratio from 0-1 (e.g. 0.0 is the lowest-scoring word, 1.0 is the highest-scoring'),
...super.getSupportedOptions()
];
}
bestWordWithScore(words) {
const scores = this.scoreAndSortWords(words);
const scoreIndex = Math.floor((words.length - 1) * (1.00 - this.options.highScorePercentile));
Logger.log('strategy', 'debug', `StrategyRefreqyFlexBadGuesser choosing item ${scoreIndex + 1 /* correct for 0-based array indexing */} of ${scores.length} based on percentile ${this.options.highScorePercentile}.`)
return scores[scoreIndex];
}
}