diff --git a/src/manual_proxy.ts b/src/manual_proxy.ts index 8d8c4cb..1b7d935 100755 --- a/src/manual_proxy.ts +++ b/src/manual_proxy.ts @@ -2,11 +2,11 @@ import { Command } from "https://deno.land/x/cliffy@v1.0.0-rc.4/command/mod.ts"; -import { Dict, ExplorerGuesser, ManualProxy, Runner } from "./lib/lib.ts"; +import { Dict, ExplorerGuesser, Guessing, ManualProxy, ReducingGuesser, Runner } from "./lib/lib.ts"; import { initialize_prompt } from "./lib/prompt.ts"; import { VerboseLogging } from "./lib/runner.ts"; -import { francais } from "../data/data.ts"; +import { francais, gutenberg } from "../data/data.ts"; async function main() { const args = await new Command().name("manual_proxy") @@ -16,19 +16,28 @@ async function main() { .option( "-f, --file ", "Sets dictionnary to use words from (defaults to internal french dict).", + ).option( + "-g, --guesser ", + `Guesser to use, available are ${[...guessers.keys()]}.`, + { default: "reducing" }, ).parse(Deno.args); const init = initialize_prompt(); - let dict = Dict.from_lines(francais, init.length); + let dict = Dict.from_lines(gutenberg, init.length); if (args.options.file !== undefined) dict = await Dict.from_text_file(args.options.file, init.length); for (const [index, letter] of init.constraints) dict.constraint(index, letter); - const guesser = new ExplorerGuesser(dict); + const guesser = guessers.get(args.options.guesser)!(dict); const game = new ManualProxy(init.length); const runner = new Runner(game, guesser, new VerboseLogging()); await runner.play_all(); } +const guessers = new Map Guessing>([ + ["explorer", (dict: Dict) => new ExplorerGuesser(dict)], + ["reducing", (dict: Dict) => new ReducingGuesser(dict)], +]); + if (import.meta.main) await main();