Skip to content

Commit 74c2714

Browse files
committed
add enforce_initial_conditions
1 parent f036890 commit 74c2714

File tree

3 files changed

+99
-44
lines changed

3 files changed

+99
-44
lines changed

backend/src/bin/gol.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ fn create_puzzles(output_dir: &PathBuf) -> Result<(), Box<dyn std::error::Error>
227227
let puzzles = get_all_puzzles();
228228

229229
for (name, puzzle_and_solution_creator) in puzzles {
230-
let (puzzle, solution) = puzzle_and_solution_creator();
230+
let (mut puzzle, solution) = puzzle_and_solution_creator();
231231

232232
let puzzle_path = output_dir.join(format!("{}_puzzle.bcs", name));
233233
let solution_path = output_dir.join(format!("{}_solution.bcs", name));
@@ -242,8 +242,9 @@ fn create_puzzles(output_dir: &PathBuf) -> Result<(), Box<dyn std::error::Error>
242242
println!("{puzzle:#}");
243243
println!("Created solution: {}", solution_path.display());
244244
println!("{solution:#}");
245+
puzzle.enforce_initial_conditions = true;
245246
let steps = puzzle.check_solution(&solution)?;
246-
println!("Verified solution: {steps} steps");
247+
println!("Verified solution (and hints): {steps} steps");
247248
println!();
248249
}
249250

@@ -273,7 +274,8 @@ fn create_block_puzzle_and_solution() -> (Puzzle, Board) {
273274
size: 8,
274275
minimal_steps: 1,
275276
maximal_steps: 1,
276-
is_strict: false,
277+
enforce_initial_conditions: false,
278+
must_not_succeed_one_step_early: false,
277279
initial_conditions,
278280
// Final conditions: exactly match the target pattern
279281
final_conditions: target_board.to_exactly_matching_conditions(),
@@ -312,7 +314,8 @@ fn create_beehive_puzzle_and_solution() -> (Puzzle, Board) {
312314
size: 9,
313315
minimal_steps: 1,
314316
maximal_steps: 1,
315-
is_strict: false,
317+
enforce_initial_conditions: false,
318+
must_not_succeed_one_step_early: false,
316319
initial_conditions,
317320
// Final conditions: exactly match the target pattern
318321
final_conditions: target_board.to_exactly_matching_conditions(),
@@ -353,7 +356,8 @@ fn create_loaf_puzzle_and_solution() -> (Puzzle, Board) {
353356
size: 10,
354357
minimal_steps: 1,
355358
maximal_steps: 1,
356-
is_strict: false,
359+
enforce_initial_conditions: false,
360+
must_not_succeed_one_step_early: false,
357361
initial_conditions,
358362
// Final conditions: exactly match the target pattern
359363
final_conditions: target_board.to_exactly_matching_conditions(),
@@ -391,7 +395,8 @@ fn create_boat_puzzle_and_solution() -> (Puzzle, Board) {
391395
size: 8,
392396
minimal_steps: 1,
393397
maximal_steps: 1,
394-
is_strict: false,
398+
enforce_initial_conditions: false,
399+
must_not_succeed_one_step_early: false,
395400
initial_conditions,
396401
// Final conditions: exactly match the target pattern
397402
final_conditions: target_board.to_exactly_matching_conditions(),
@@ -428,7 +433,8 @@ fn create_tub_puzzle_and_solution() -> (Puzzle, Board) {
428433
size: 7,
429434
minimal_steps: 1,
430435
maximal_steps: 1,
431-
is_strict: false,
436+
enforce_initial_conditions: false,
437+
must_not_succeed_one_step_early: false,
432438
initial_conditions,
433439
// Final conditions: exactly match the target pattern
434440
final_conditions: target_board.to_exactly_matching_conditions(),
@@ -467,7 +473,8 @@ fn create_blinker_puzzle_and_solution() -> (Puzzle, Board) {
467473
size: 7,
468474
minimal_steps: 1,
469475
maximal_steps: 1,
470-
is_strict: false,
476+
enforce_initial_conditions: false,
477+
must_not_succeed_one_step_early: false,
471478
initial_conditions,
472479
// Final conditions: exactly match the target pattern
473480
final_conditions: target_board.to_exactly_matching_conditions(),
@@ -511,7 +518,8 @@ fn create_beacon_puzzle_and_solution() -> (Puzzle, Board) {
511518
size: 8,
512519
minimal_steps: 1,
513520
maximal_steps: 1,
514-
is_strict: false,
521+
enforce_initial_conditions: false,
522+
must_not_succeed_one_step_early: false,
515523
initial_conditions,
516524
// Final conditions: exactly match the target pattern
517525
final_conditions: target_board.to_exactly_matching_conditions(),
@@ -552,7 +560,8 @@ fn create_clock_puzzle_and_solution() -> (Puzzle, Board) {
552560
size: 8,
553561
minimal_steps: 1,
554562
maximal_steps: 1,
555-
is_strict: false,
563+
enforce_initial_conditions: false,
564+
must_not_succeed_one_step_early: false,
556565
initial_conditions,
557566
// Final conditions: exactly match the target pattern
558567
final_conditions: target_board.to_exactly_matching_conditions(),
@@ -614,7 +623,8 @@ fn create_robot_face_puzzle_and_solution() -> (Puzzle, Board) {
614623
size,
615624
minimal_steps: 170,
616625
maximal_steps: 200,
617-
is_strict: false,
626+
enforce_initial_conditions: false,
627+
must_not_succeed_one_step_early: false,
618628
initial_conditions,
619629
final_conditions,
620630
};
@@ -645,7 +655,8 @@ fn create_glider_migration_puzzle_and_solution() -> (Puzzle, Board) {
645655
size: 16,
646656
minimal_steps: 40,
647657
maximal_steps: 40,
648-
is_strict: true,
658+
enforce_initial_conditions: false,
659+
must_not_succeed_one_step_early: false,
649660
initial_conditions: vec![
650661
// Hint.
651662
Condition::TestPosition {

0 commit comments

Comments
 (0)