Enhance postcard puzzles and narration
This commit is contained in:
@@ -250,7 +250,7 @@ void main(List<String> args) {
|
||||
final seed = BigInt.parse(options['--seed'] ?? '1000001');
|
||||
boards.add(
|
||||
_fromPuzzle(
|
||||
Puzzle.generate(seed, difficulty),
|
||||
Puzzle.generateSeven(seed, difficulty),
|
||||
'practice',
|
||||
'${difficulty.label}, seed $seed',
|
||||
),
|
||||
@@ -263,7 +263,10 @@ void main(List<String> args) {
|
||||
}
|
||||
boards.add(
|
||||
_fromPuzzle(
|
||||
Puzzle.seeded(BigInt.from(epochDay(date)) * BigInt.from(7919)),
|
||||
Puzzle.generateSeven(
|
||||
BigInt.from(epochDay(date)) * BigInt.from(7919),
|
||||
Difficulty.medium,
|
||||
),
|
||||
'daily',
|
||||
value,
|
||||
),
|
||||
|
||||
@@ -1,34 +1,32 @@
|
||||
// Freeze the boards so future generator changes cannot change saved puzzles.
|
||||
// Freeze new 7x7 boards. Existing v1 completions are preserved separately.
|
||||
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.',
|
||||
'// Generated by tool/author_postcard_puzzles.dart. Stable v2 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');
|
||||
final random = JavaRandom(BigInt.from(490018 + 7919 * i));
|
||||
final p = Puzzle(7, List.generate(49, (_) => random.next(1)));
|
||||
if (!seen.add(p.solution.join())) throw StateError('Duplicate board');
|
||||
for (var j = 0; j < 49; j++) {
|
||||
p.given[j] = true;
|
||||
}
|
||||
final order = List.generate(49, (j) => j);
|
||||
random.shuffle(order);
|
||||
for (final j in order) {
|
||||
p.given[j] = false;
|
||||
if (p.countSolutions() != 1 ||
|
||||
!LogicSolver(49, p.constraints).analyze(p.initial).solved) {
|
||||
p.given[j] = true;
|
||||
}
|
||||
}
|
||||
lines.add(
|
||||
" ('${p.solution.join()}', ${[for (var j = 0; j < 25; j++)
|
||||
" ('${p.solution.join()}', ${[for (var j = 0; j < 49; j++)
|
||||
if (p.given[j]) j]}),",
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:lumen/domain/postcards.dart';
|
||||
|
||||
void main() => stdout.write(
|
||||
jsonEncode([
|
||||
for (final p in islandPostcards)
|
||||
{'id': p.id, 'title': p.title, 'text': p.message},
|
||||
]),
|
||||
);
|
||||
Reference in New Issue
Block a user