feat: Add threads option to Main class and update usage message

This commit is contained in:
mike
2025-12-27 02:54:10 +01:00
committed by mike (aider)
parent 31658d2f72
commit 5016bb1974

View File

@@ -16,25 +16,27 @@ public class Main {
public static class Opts {
public int seed = 1234;
public int pop = 18;
public int gens = 200;
public int tries = 5;
public int gens = 300;
public String wordsPath = "/data/puzzle/pool.txt";
public double minSimplicity = 0; // 0 means no limit
public int threads = Math.max(1, Runtime.getRuntime().availableProcessors());
public int tries = threads;
}
static void usage() {
System.out.println("""
Usage:
java SwedishGenerator [--seed N] [--pop N] [--gens N] [--tries N] [--words word-list.txt] [--min-simplicity N.N]
java SwedishGenerator [--seed N] [--pop N] [--gens N] [--tries N] [--words word-list.txt] [--min-simplicity N.N] [--threads N]
Defaults:
--seed 1
--seed 1234
--pop 18
--gens 100
--tries 50
--words /data/pool.txt
--gens 1000
--tries 5
--words /data/puzzle/pool.txt
--min-simplicity 0 (no limit)
""");
--threads %d
""".formatted(Math.max(1, Runtime.getRuntime().availableProcessors())));
}
static Opts parseArgs(String[] argv) {
@@ -52,6 +54,7 @@ public class Main {
else if (a.equals("--tries")) { out.tries = Integer.parseInt(v); i++; }
else if (a.equals("--words")) { out.wordsPath = v; i++; }
else if (a.equals("--min-simplicity")) { out.minSimplicity = Double.parseDouble(v); i++; }
else if (a.equals("--threads")) { out.threads = Integer.parseInt(v); i++; }
else throw new IllegalArgumentException("Unknown arg: " + a);
}
return out;