Commits

Shlomi Fish  committed 7898a31 Merge

Merge from default the test and got it to pass.

  • Participants
  • Parent commits a19eee4, 2ce4496
  • Branches merge-all-in-a-row-and-black-hole-code-trial

Comments (0)

Files changed (3)

File black-hole-solitaire/all-in-a-row-c-solver/black_hole_solver.c

 
     solver = (bhs_solver_t *)instance_proto;
 
+    solver->num_columns = num_columns;
+
     s = board_string;
 
     /* Read the foundations. */
         (
             (num_columns % BHS__ALL_IN_A_ROW__COLS_PER_BYTE ) ? 1 : 0
         )
+        - 1
     );
 
     for (two_cols_idx = 0, two_cols_offset = 0;

File black-hole-solitaire/all-in-a-row-c-solver/t/data/24.all_in_a_row.board.txt

+Foundations: -
+4C JS 9H 8S
+5H 5S 5C 4S
+QC 6C TC 4H
+5D 9C TS KS
+2D 3C AD 6D
+7H 6H 4D 8D
+AH JC QS 7C
+7S TH 3H JD
+2C KH 3S 9D
+QH 6S JH 2H
+9S 7D TD QD
+2S 8C KC 3D
+KD AC 8H AS

File black-hole-solitaire/all-in-a-row-c-solver/t/output.t

 use strict;
 use warnings;
 
-use Test::More tests => 6;
+use Test::More tests => 2;
 use Test::Differences;
 
 use File::Spec;
 
 trap
 {
-    system("./black-hole-solve",
+    system("./all-in-a-row-solve",
         File::Spec->catfile(
-            $bin_dir, "data", "26464608654870335080.bh.board.txt"
+            $bin_dir, "data", "24.all_in_a_row.board.txt"
         )
     );
 };
 
 # TEST
-ok (! ($trap->exit), "Running the program successfully.");
+ok (! ($trap->exit), "Running the program successfully for board #24.");
 
 my $expected_output = <<'EOF';
 Solved!
-Move a card from stack 16 to the foundations
+Move a card from stack 12 to the foundations
 
-Info: Card moved is 2D
+Info: Card moved is AS
 
 
 ====================
 
-Move a card from stack 13 to the foundations
+Move a card from stack 3 to the foundations
 
-Info: Card moved is 3H
+Info: Card moved is KS
 
 
 ====================
 
-Move a card from stack 16 to the foundations
+Move a card from stack 10 to the foundations
 
-Info: Card moved is 2S
+Info: Card moved is QD
 
 
 ====================
 
-Move a card from stack 13 to the foundations
+Move a card from stack 7 to the foundations
 
-Info: Card moved is 3C
+Info: Card moved is JD
+
+
+====================
+
+Move a card from stack 10 to the foundations
+
+Info: Card moved is TD
+
+
+====================
+
+Move a card from stack 8 to the foundations
+
+Info: Card moved is 9D
+
+
+====================
+
+Move a card from stack 12 to the foundations
+
+Info: Card moved is 8H
+
+
+====================
+
+Move a card from stack 10 to the foundations
+
+Info: Card moved is 7D
+
+
+====================
+
+Move a card from stack 0 to the foundations
+
+Info: Card moved is 8S
+
+
+====================
+
+Move a card from stack 0 to the foundations
+
+Info: Card moved is 9H
+
+
+====================
+
+Move a card from stack 3 to the foundations
+
+Info: Card moved is TS
+
+
+====================
+
+Move a card from stack 3 to the foundations
+
+Info: Card moved is 9C
+
+
+====================
+
+Move a card from stack 5 to the foundations
+
+Info: Card moved is 8D
+
+
+====================
+
+Move a card from stack 6 to the foundations
+
+Info: Card moved is 7C
+
+
+====================
+
+Move a card from stack 4 to the foundations
+
+Info: Card moved is 6D
+
+
+====================
+
+Move a card from stack 3 to the foundations
+
+Info: Card moved is 5D
+
+
+====================
+
+Move a card from stack 5 to the foundations
+
+Info: Card moved is 4D
+
+
+====================
+
+Move a card from stack 11 to the foundations
+
+Info: Card moved is 3D
+
+
+====================
+
+Move a card from stack 1 to the foundations
+
+Info: Card moved is 4S
+
+
+====================
+
+Move a card from stack 1 to the foundations
+
+Info: Card moved is 5C
+
+
+====================
+
+Move a card from stack 5 to the foundations
+
+Info: Card moved is 6H
+
+
+====================
+
+Move a card from stack 1 to the foundations
+
+Info: Card moved is 5S
 
 
 ====================
 
 ====================
 
-Move a card from stack 3 to the foundations
+Move a card from stack 7 to the foundations
 
-Info: Card moved is 5S
+Info: Card moved is 3H
 
 
 ====================
 
-Move a card from stack 13 to the foundations
+Move a card from stack 9 to the foundations
 
-Info: Card moved is 6D
+Info: Card moved is 2H
 
 
 ====================
 
-Move a card from stack 15 to the foundations
+Move a card from stack 12 to the foundations
 
-Info: Card moved is 7C
+Info: Card moved is AC
+
+
+====================
+
+Move a card from stack 11 to the foundations
+
+Info: Card moved is KC
+
+
+====================
+
+Move a card from stack 6 to the foundations
+
+Info: Card moved is QS
+
+
+====================
+
+Move a card from stack 9 to the foundations
+
+Info: Card moved is JH
+
+
+====================
+
+Move a card from stack 7 to the foundations
+
+Info: Card moved is TH
+
+
+====================
+
+Move a card from stack 0 to the foundations
+
+Info: Card moved is JS
+
+
+====================
+
+Move a card from stack 2 to the foundations
+
+Info: Card moved is TC
+
+
+====================
+
+Move a card from stack 10 to the foundations
+
+Info: Card moved is 9S
 
 
 ====================
 
 ====================
 
-Move a card from stack 16 to the foundations
+Move a card from stack 7 to the foundations
 
-Info: Card moved is 9H
+Info: Card moved is 7S
 
 
 ====================
 
-Move a card from stack 14 to the foundations
+Move a card from stack 9 to the foundations
 
-Info: Card moved is TH
-
-
-====================
-
-Move a card from stack 3 to the foundations
-
-Info: Card moved is 9S
+Info: Card moved is 6S
 
 
 ====================
 
 Move a card from stack 5 to the foundations
 
-Info: Card moved is 8S
+Info: Card moved is 7H
 
 
 ====================
 
-Move a card from stack 5 to the foundations
+Move a card from stack 2 to the foundations
 
-Info: Card moved is 9D
+Info: Card moved is 6C
+
+
+====================
+
+Move a card from stack 1 to the foundations
+
+Info: Card moved is 5H
+
+
+====================
+
+Move a card from stack 0 to the foundations
+
+Info: Card moved is 4C
+
+
+====================
+
+Move a card from stack 8 to the foundations
+
+Info: Card moved is 3S
+
+
+====================
+
+Move a card from stack 11 to the foundations
+
+Info: Card moved is 2S
+
+
+====================
+
+Move a card from stack 4 to the foundations
+
+Info: Card moved is AD
 
 
 ====================
 
 Move a card from stack 12 to the foundations
 
-Info: Card moved is TC
-
-
-====================
-
-Move a card from stack 0 to the foundations
-
-Info: Card moved is JS
+Info: Card moved is KD
 
 
 ====================
 
 Move a card from stack 9 to the foundations
 
-Info: Card moved is QC
+Info: Card moved is QH
 
 
 ====================
 
-Move a card from stack 14 to the foundations
+Move a card from stack 6 to the foundations
 
-Info: Card moved is KS
+Info: Card moved is JC
 
 
 ====================
 
-Move a card from stack 7 to the foundations
+Move a card from stack 2 to the foundations
 
-Info: Card moved is QH
-
-
-====================
-
-Move a card from stack 7 to the foundations
-
-Info: Card moved is JC
+Info: Card moved is QC
 
 
 ====================
 
 Move a card from stack 8 to the foundations
 
-Info: Card moved is TS
+Info: Card moved is KH
 
 
 ====================
 
-Move a card from stack 0 to the foundations
+Move a card from stack 6 to the foundations
 
-Info: Card moved is JH
-
-
-====================
-
-Move a card from stack 9 to the foundations
-
-Info: Card moved is QS
-
-
-====================
-
-Move a card from stack 10 to the foundations
-
-Info: Card moved is KH
-
-
-====================
-
-Move a card from stack 7 to the foundations
-
-Info: Card moved is AC
-
-
-====================
-
-Move a card from stack 14 to the foundations
-
-Info: Card moved is 2C
-
-
-====================
-
-Move a card from stack 10 to the foundations
-
-Info: Card moved is 3D
+Info: Card moved is AH
 
 
 ====================
 
 Move a card from stack 8 to the foundations
 
-Info: Card moved is 4S
-
-
-====================
-
-Move a card from stack 15 to the foundations
-
-Info: Card moved is 5D
-
-
-====================
-
-Move a card from stack 6 to the foundations
-
-Info: Card moved is 6S
-
-
-====================
-
-Move a card from stack 1 to the foundations
-
-Info: Card moved is 7D
+Info: Card moved is 2C
 
 
 ====================
 
 Move a card from stack 4 to the foundations
 
-Info: Card moved is 6H
-
-
-====================
-
-Move a card from stack 11 to the foundations
-
-Info: Card moved is 5C
-
-
-====================
-
-Move a card from stack 1 to the foundations
-
-Info: Card moved is 4C
+Info: Card moved is 3C
 
 
 ====================
 
 Move a card from stack 4 to the foundations
 
-Info: Card moved is 3S
+Info: Card moved is 2D
 
 
 ====================
 
-Move a card from stack 6 to the foundations
-
-Info: Card moved is 2H
-
-
-====================
-
-Move a card from stack 15 to the foundations
-
-Info: Card moved is AD
-
-
-====================
-
-Move a card from stack 12 to the foundations
-
-Info: Card moved is KC
-
-
-====================
-
-Move a card from stack 4 to the foundations
-
-Info: Card moved is AH
-
-
-====================
-
-Move a card from stack 0 to the foundations
-
-Info: Card moved is KD
-
-
-====================
-
-Move a card from stack 8 to the foundations
-
-Info: Card moved is QD
-
-
-====================
-
-Move a card from stack 3 to the foundations
-
-Info: Card moved is JD
-
-
-====================
-
-Move a card from stack 2 to the foundations
-
-Info: Card moved is TD
-
-
-====================
-
-Move a card from stack 5 to the foundations
-
-Info: Card moved is 9C
-
-
-====================
-
-Move a card from stack 10 to the foundations
-
-Info: Card moved is 8D
-
-
-====================
-
-Move a card from stack 6 to the foundations
-
-Info: Card moved is 7S
-
-
-====================
-
-Move a card from stack 1 to the foundations
-
-Info: Card moved is 8H
-
-
-====================
-
-Move a card from stack 2 to the foundations
-
-Info: Card moved is 7H
-
-
-====================
-
-Move a card from stack 9 to the foundations
-
-Info: Card moved is 6C
-
-
-====================
-
-Move a card from stack 11 to the foundations
-
-Info: Card moved is 5H
-
-
-====================
-
-Move a card from stack 12 to the foundations
-
-Info: Card moved is 4D
-
-
-====================
-
 
 
 --------------------
-Total number of states checked is 8636.
-This scan generated 8672 states.
+Total number of states checked is 18022.
+This scan generated 18056 states.
 EOF
 
 # TEST
-eq_or_diff ($trap->stdout(), $expected_output, "Right output.");
-
-trap
-{
-    system("./black-hole-solve",
-        File::Spec->catfile(
-            $bin_dir, "data", "1.bh.board.txt"
-        )
-    );
-};
-
-$expected_output = <<'EOF';
-Unsolved!
-
-
---------------------
-Total number of states checked is 8.
-This scan generated 8 states.
-EOF
-
-# TEST
-eq_or_diff ($trap->stdout(), $expected_output, "Right output.");
-
-
-trap
-{
-    system("./black-hole-solve",
-        "--max-iters", "10000",
-        File::Spec->catfile(
-            $bin_dir, "data", "26464608654870335080.bh.board.txt"
-        )
-    );
-};
-
-# TEST
-ok (! ($trap->exit), "Running --max-iters program successfully.");
-
-$expected_output = <<'EOF';
-Solved!
-Move a card from stack 16 to the foundations
-
-Info: Card moved is 2D
-
-
-====================
-
-Move a card from stack 13 to the foundations
-
-Info: Card moved is 3H
-
-
-====================
-
-Move a card from stack 16 to the foundations
-
-Info: Card moved is 2S
-
-
-====================
-
-Move a card from stack 13 to the foundations
-
-Info: Card moved is 3C
-
-
-====================
-
-Move a card from stack 2 to the foundations
-
-Info: Card moved is 4H
-
-
-====================
-
-Move a card from stack 3 to the foundations
-
-Info: Card moved is 5S
-
-
-====================
-
-Move a card from stack 13 to the foundations
-
-Info: Card moved is 6D
-
-
-====================
-
-Move a card from stack 15 to the foundations
-
-Info: Card moved is 7C
-
-
-====================
-
-Move a card from stack 11 to the foundations
-
-Info: Card moved is 8C
-
-
-====================
-
-Move a card from stack 16 to the foundations
-
-Info: Card moved is 9H
-
-
-====================
-
-Move a card from stack 14 to the foundations
-
-Info: Card moved is TH
-
-
-====================
-
-Move a card from stack 3 to the foundations
-
-Info: Card moved is 9S
-
-
-====================
-
-Move a card from stack 5 to the foundations
-
-Info: Card moved is 8S
-
-
-====================
-
-Move a card from stack 5 to the foundations
-
-Info: Card moved is 9D
-
-
-====================
-
-Move a card from stack 12 to the foundations
-
-Info: Card moved is TC
-
-
-====================
-
-Move a card from stack 0 to the foundations
-
-Info: Card moved is JS
-
-
-====================
-
-Move a card from stack 9 to the foundations
-
-Info: Card moved is QC
-
-
-====================
-
-Move a card from stack 14 to the foundations
-
-Info: Card moved is KS
-
-
-====================
-
-Move a card from stack 7 to the foundations
-
-Info: Card moved is QH
-
-
-====================
-
-Move a card from stack 7 to the foundations
-
-Info: Card moved is JC
-
-
-====================
-
-Move a card from stack 8 to the foundations
-
-Info: Card moved is TS
-
-
-====================
-
-Move a card from stack 0 to the foundations
-
-Info: Card moved is JH
-
-
-====================
-
-Move a card from stack 9 to the foundations
-
-Info: Card moved is QS
-
-
-====================
-
-Move a card from stack 10 to the foundations
-
-Info: Card moved is KH
-
-
-====================
-
-Move a card from stack 7 to the foundations
-
-Info: Card moved is AC
-
-
-====================
-
-Move a card from stack 14 to the foundations
-
-Info: Card moved is 2C
-
-
-====================
-
-Move a card from stack 10 to the foundations
-
-Info: Card moved is 3D
-
-
-====================
-
-Move a card from stack 8 to the foundations
-
-Info: Card moved is 4S
-
-
-====================
-
-Move a card from stack 15 to the foundations
-
-Info: Card moved is 5D
-
-
-====================
-
-Move a card from stack 6 to the foundations
-
-Info: Card moved is 6S
-
-
-====================
-
-Move a card from stack 1 to the foundations
-
-Info: Card moved is 7D
-
-
-====================
-
-Move a card from stack 4 to the foundations
-
-Info: Card moved is 6H
-
-
-====================
-
-Move a card from stack 11 to the foundations
-
-Info: Card moved is 5C
-
-
-====================
-
-Move a card from stack 1 to the foundations
-
-Info: Card moved is 4C
-
-
-====================
-
-Move a card from stack 4 to the foundations
-
-Info: Card moved is 3S
-
-
-====================
-
-Move a card from stack 6 to the foundations
-
-Info: Card moved is 2H
-
-
-====================
-
-Move a card from stack 15 to the foundations
-
-Info: Card moved is AD
-
-
-====================
-
-Move a card from stack 12 to the foundations
-
-Info: Card moved is KC
-
-
-====================
-
-Move a card from stack 4 to the foundations
-
-Info: Card moved is AH
-
-
-====================
-
-Move a card from stack 0 to the foundations
-
-Info: Card moved is KD
-
-
-====================
-
-Move a card from stack 8 to the foundations
-
-Info: Card moved is QD
-
-
-====================
-
-Move a card from stack 3 to the foundations
-
-Info: Card moved is JD
-
-
-====================
-
-Move a card from stack 2 to the foundations
-
-Info: Card moved is TD
-
-
-====================
-
-Move a card from stack 5 to the foundations
-
-Info: Card moved is 9C
-
-
-====================
-
-Move a card from stack 10 to the foundations
-
-Info: Card moved is 8D
-
-
-====================
-
-Move a card from stack 6 to the foundations
-
-Info: Card moved is 7S
-
-
-====================
-
-Move a card from stack 1 to the foundations
-
-Info: Card moved is 8H
-
-
-====================
-
-Move a card from stack 2 to the foundations
-
-Info: Card moved is 7H
-
-
-====================
-
-Move a card from stack 9 to the foundations
-
-Info: Card moved is 6C
-
-
-====================
-
-Move a card from stack 11 to the foundations
-
-Info: Card moved is 5H
-
-
-====================
-
-Move a card from stack 12 to the foundations
-
-Info: Card moved is 4D
-
-
-====================
-
-
-
---------------------
-Total number of states checked is 8636.
-This scan generated 8672 states.
-EOF
-
-# TEST
-eq_or_diff ($trap->stdout(), $expected_output, "Right output.");
-
-trap
-{
-    system("./black-hole-solve",
-        File::Spec->catfile(
-            $bin_dir, "data", "1.bh.board.txt"
-        )
-    );
-};
-
-$expected_output = <<'EOF';
-Unsolved!
-
-
---------------------
-Total number of states checked is 8.
-This scan generated 8 states.
-EOF
-
-# TEST
-eq_or_diff ($trap->stdout(), $expected_output, "Right output for --max-iters.");
+eq_or_diff ($trap->stdout(), $expected_output, "Right output from board 24.");