change default dict to gutenberg
This commit is contained in:
parent
bc211621e5
commit
1059391e3b
1 changed files with 13 additions and 4 deletions
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
import { Command } from "https://deno.land/x/cliffy@v1.0.0-rc.4/command/mod.ts";
|
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 { initialize_prompt } from "./lib/prompt.ts";
|
||||||
import { VerboseLogging } from "./lib/runner.ts";
|
import { VerboseLogging } from "./lib/runner.ts";
|
||||||
|
|
||||||
import { francais } from "../data/data.ts";
|
import { francais, gutenberg } from "../data/data.ts";
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const args = await new Command().name("manual_proxy")
|
const args = await new Command().name("manual_proxy")
|
||||||
|
@ -16,19 +16,28 @@ async function main() {
|
||||||
.option(
|
.option(
|
||||||
"-f, --file <path:string>",
|
"-f, --file <path:string>",
|
||||||
"Sets dictionnary to use words from (defaults to internal french dict).",
|
"Sets dictionnary to use words from (defaults to internal french dict).",
|
||||||
|
).option(
|
||||||
|
"-g, --guesser <guesser:string>",
|
||||||
|
`Guesser to use, available are ${[...guessers.keys()]}.`,
|
||||||
|
{ default: "reducing" },
|
||||||
).parse(Deno.args);
|
).parse(Deno.args);
|
||||||
|
|
||||||
const init = initialize_prompt();
|
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);
|
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);
|
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 game = new ManualProxy(init.length);
|
||||||
|
|
||||||
const runner = new Runner(game, guesser, new VerboseLogging());
|
const runner = new Runner(game, guesser, new VerboseLogging());
|
||||||
await runner.play_all();
|
await runner.play_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const guessers = new Map<string, (dict: Dict) => Guessing>([
|
||||||
|
["explorer", (dict: Dict) => new ExplorerGuesser(dict)],
|
||||||
|
["reducing", (dict: Dict) => new ReducingGuesser(dict)],
|
||||||
|
]);
|
||||||
|
|
||||||
if (import.meta.main) await main();
|
if (import.meta.main) await main();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue