Expand Lumen stories and add island postcards

This commit is contained in:
Hadrian Burkhardt
2026-11-13 10:18:42 +01:00
parent 7e6b203a02
commit abaab927d9
211 changed files with 10839 additions and 7278 deletions
+38
View File
@@ -0,0 +1,38 @@
// Freeze the boards so future generator changes cannot change saved puzzles.
import 'dart:io';
import 'package:lumen/domain/puzzle.dart';
void main() {
final lines = <String>[
'// Generated by tool/author_postcard_puzzles.dart. Stable v1 save identities.',
'const postcardPatterns = <(String, List<int>)>[',
];
final seen = <String>{};
for (var i = 0; i < 42; i++) {
final difficulty = i < 6 || i % 3 == 0
? Difficulty.easy
: i % 3 == 1 || i < 18
? Difficulty.medium
: Difficulty.hard;
var seed = 830000 + i * 1000;
Puzzle p;
do {
p = Puzzle.generate(BigInt.from(seed++), difficulty);
} while (!seen.add(p.solution.join()));
if (p.countSolutions() != 1 ||
!LogicSolver(
p.solution.length,
p.constraints,
).analyze(p.initial).solved) {
throw StateError('Invalid postcard board $i');
}
lines.add(
" ('${p.solution.join()}', ${[for (var j = 0; j < 25; j++)
if (p.given[j]) j]}),",
);
}
lines.add('];');
File('lib/domain/postcard_patterns.dart')
.writeAsStringSync('${lines.join('\n')}\n');
}