change simulation to account for generated dicts

This commit is contained in:
JOLIMAITRE Matthieu 2024-04-30 17:14:43 +02:00
parent be91004c3a
commit 3ac586e7e1

View file

@ -5,15 +5,16 @@ import { Command } from "https://deno.land/x/cliffy@v1.0.0-rc.4/command/mod.ts";
import { Dict, Guesser, Runner, Simulator } from "./lib/lib.ts"; import { Dict, Guesser, Runner, Simulator } from "./lib/lib.ts";
import { TableLogging } from "./lib/runner.ts"; import { TableLogging } from "./lib/runner.ts";
import { francais } from "../data/data.ts";
async function main() { async function main() {
const args = await new Command().name("simulation") const args = await new Command().name("simulation")
.description( .description(
"Program to simulate TUSMO game with guesser controller.", "Program to simulate TUSMO game with guesser controller.",
) )
.option( .option(
"-d, --dictionnary <path:string>", "-f, --file <path:string>",
"Sets dictionnary to use words from.", "Sets dictionnary to use words from (defaults to internal french dict).",
{ default: "./data/liste_francais.txt" },
).option( ).option(
"-n, --length <length:number>", "-n, --length <length:number>",
"Length of the word to use from the dictionnary.", "Length of the word to use from the dictionnary.",
@ -21,10 +22,11 @@ async function main() {
).option( ).option(
"-w, --wait <wait:number>", "-w, --wait <wait:number>",
"Time to wait between guesses, in ms.", "Time to wait between guesses, in ms.",
{ default: 500 }, { default: 0 },
).parse(Deno.args); ).parse(Deno.args);
const dict = await Dict.from_file(args.options.dictionnary, args.options.length); let dict = Dict.from_lines(francais, args.options.length);
if (args.options.file !== undefined) dict = await Dict.from_text_file(args.options.file, args.options.length);
const guesser = new Guesser(dict); const guesser = new Guesser(dict);
const game = Simulator.from_dict_rand(dict); const game = Simulator.from_dict_rand(dict);