-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtestSmoke.mjs
More file actions
executable file
·27 lines (23 loc) · 993 Bytes
/
testSmoke.mjs
File metadata and controls
executable file
·27 lines (23 loc) · 993 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/env node --experimental-modules
import { Logger } from "./log.mjs";
import { strategyByName, STRATEGIES } from "./strategyByName.mjs";
import { takeGuess } from "./util.mjs";
const solution = "freak";
const words = [ "break", "bleak", "bread", "freed", "greed", "greek", solution ];
Object.keys(STRATEGIES).forEach(strategyName => {
Logger.log('test', 'info', `===== BEGIN TESTING STRATEGY ${strategyName} with solution ${solution}`);
const strategy = new strategyByName(strategyName, words);
while(1) {
const guess = strategy.guess();
if (!guess) {
throw new Error('Ran out of guesses');
}
const response = takeGuess(solution, guess);
Logger.log('test', 'info', `Guessed ${guess}, response ${response}`);
strategy.update(guess, response.split(""));
if (response === 'GGGGG') {
break;
}
}
Logger.log('test', 'info', `===== END TESTING STRATEGY: ${strategyName}`);
});