feat: Add threads option to Main class and update usage message
This commit is contained in:
@@ -16,25 +16,27 @@ public class Main {
|
|||||||
public static class Opts {
|
public static class Opts {
|
||||||
public int seed = 1234;
|
public int seed = 1234;
|
||||||
public int pop = 18;
|
public int pop = 18;
|
||||||
public int gens = 200;
|
public int gens = 300;
|
||||||
public int tries = 5;
|
|
||||||
public String wordsPath = "/data/puzzle/pool.txt";
|
public String wordsPath = "/data/puzzle/pool.txt";
|
||||||
public double minSimplicity = 0; // 0 means no limit
|
public double minSimplicity = 0; // 0 means no limit
|
||||||
|
public int threads = Math.max(1, Runtime.getRuntime().availableProcessors());
|
||||||
|
public int tries = threads;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usage() {
|
static void usage() {
|
||||||
System.out.println("""
|
System.out.println("""
|
||||||
Usage:
|
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:
|
Defaults:
|
||||||
--seed 1
|
--seed 1234
|
||||||
--pop 18
|
--pop 18
|
||||||
--gens 100
|
--gens 1000
|
||||||
--tries 50
|
--tries 5
|
||||||
--words /data/pool.txt
|
--words /data/puzzle/pool.txt
|
||||||
--min-simplicity 0 (no limit)
|
--min-simplicity 0 (no limit)
|
||||||
""");
|
--threads %d
|
||||||
|
""".formatted(Math.max(1, Runtime.getRuntime().availableProcessors())));
|
||||||
}
|
}
|
||||||
|
|
||||||
static Opts parseArgs(String[] argv) {
|
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("--tries")) { out.tries = Integer.parseInt(v); i++; }
|
||||||
else if (a.equals("--words")) { out.wordsPath = 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("--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);
|
else throw new IllegalArgumentException("Unknown arg: " + a);
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
|
|||||||
Reference in New Issue
Block a user