update them

This commit is contained in:
mike
2025-12-21 22:07:58 +01:00
parent 2e34efbde3
commit 83d1a907c1

View File

@@ -70,13 +70,13 @@ public class ThemePoolBuilderLength {
// ---- NEW: enforce minimum counts per length in the final pool ---- // ---- NEW: enforce minimum counts per length in the final pool ----
// Tune these to your puzzle generators appetite for short words. // Tune these to your puzzle generators appetite for short words.
int minLen2 = 4000; int minLen2 = 1000;
int minLen3 = 7000; int minLen3 = 1000;
int minLen4 = 9000; int minLen4 = 1000;
int minLen5 = 0; // set if you also want to force 5-letter words, etc. int minLen5 = 1000; // set if you also want to force 5-letter words, etc.
int minLen6 = 0; int minLen6 = 1000;
int minLen7 = 0; int minLen7 = 1000;
int minLen8 = 0; int minLen8 = 1000;
} }
static Opts parseArgs(String[] args) { static Opts parseArgs(String[] args) {
@@ -701,11 +701,17 @@ public class ThemePoolBuilderLength {
} }
static void writeWordList(Path path, Lexicon lex, BitSet bs) throws IOException { static void writeWordList(Path path, Lexicon lex, BitSet bs) throws IOException {
var out = new ArrayList<String>(bs.cardinality()); var ids = new ArrayList<Integer>(bs.cardinality());
for (var i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) { for (var i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
out.add(lex.words.get(i)); ids.add(i);
}
// Sort by score descending (higher score is easier/better)
ids.sort((a, b) -> Integer.compare(lex.score[b], lex.score[a]));
var out = new ArrayList<String>(ids.size());
for (var id : ids) {
out.add(lex.words.get(id));
} }
out.sort(String::compareTo);
Files.write(path, out, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING); Files.write(path, out, StandardCharsets.UTF_8, StandardOpenOption.CREATE, StandardOpenOption.TRUNCATE_EXISTING);
} }