fixes and cleanup

This commit is contained in:
JOLIMAITRE Matthieu 2024-05-03 06:12:12 +02:00
parent 374c42802e
commit bc211621e5
6 changed files with 199 additions and 83 deletions

View file

@ -15,6 +15,7 @@ import {
} from "./lib/lib.ts";
import { francais } from "../data/data.ts";
import { last } from "./lib/utils.ts";
async function main() {
const args = await new Command().name("simulation")
@ -27,6 +28,9 @@ async function main() {
).option(
"-n, --length <length:number>",
"Length of the word to use from the dictionnary.",
).option(
"-m, --max <max:number>",
"Maximum number of iterations.",
).option(
"-w, --wait <wait:number>",
"Time to wait between guesses, in ms.",
@ -56,8 +60,10 @@ async function main() {
console.log("Target is", game.word);
console.log();
const runner = new Runner(game, guesser, new TableLogging(), args.options.wait);
await runner.play_all();
const runner = new Runner(game, guesser, new TableLogging(), args.options.wait, args.options.max);
const result = last(await runner.play_all());
if (result === undefined) Deno.exit(1);
if (result.result.kind === "failure") Deno.exit(1);
}
function validate_target(target: string, length: number) {