Expand Lumen stories and add island postcards
This commit is contained in:
@@ -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');
|
||||
}
|
||||
Reference in New Issue
Block a user