remove old mains
This commit is contained in:
parent
e5b23bfd16
commit
dc32188c91
2 changed files with 0 additions and 285 deletions
40
src/main.ts
40
src/main.ts
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env -S deno run --allow-read
|
||||
|
||||
import { GuessResult } from "./lib/game/game.ts";
|
||||
import { Dict, Gueser, Simulator } from "./lib/lib.ts";
|
||||
import { wait } from "./lib/utils.ts";
|
||||
|
||||
async function main() {
|
||||
const length = 6;
|
||||
const dict = await Dict.from_file("./data/liste_francais.txt", length);
|
||||
console.log(dict);
|
||||
const guesser = new Gueser(dict);
|
||||
const game = Simulator.from_dict_rand(dict);
|
||||
console.log("Target is", game.word);
|
||||
let index = 0;
|
||||
while (true) {
|
||||
console.log();
|
||||
index += 1;
|
||||
const found = await guesser.next_guess((guess, known) => {
|
||||
console.log("knows: ", known);
|
||||
console.log("Guessing:", guess);
|
||||
const result = game.try_guess(guess);
|
||||
console.log(format_result(result));
|
||||
return result;
|
||||
});
|
||||
if (found !== undefined) {
|
||||
console.log("Found", found, "in", index);
|
||||
break;
|
||||
}
|
||||
await wait(500);
|
||||
}
|
||||
}
|
||||
|
||||
function format_result(result: GuessResult) {
|
||||
if (result.kind === "success") return `success`;
|
||||
let line = "failure: ";
|
||||
for (const info of result.informations) line += info.kind === "abscent" ? "-" : info.kind === "somewhere" ? "+" : "#";
|
||||
return line;
|
||||
}
|
||||
|
||||
if (import.meta.main) await main();
|
Loading…
Add table
Add a link
Reference in a new issue