Commits

Shlomi Fish committed 1cdb589

Fixed for --flares-choice fcpro .

fc_pro_iface.c: now duplicating the state. Restored two traces and
sanity checks.

lib.c: add initial_non_canonized_state which is the initial state before
its stack indices are mangled. Passing it to
fc_solve_moves_processed_gen() .

  • Participants
  • Parent commits ea12797

Comments (0)

Files changed (2)

File fc-solve/source/fc_pro_iface.c

 )
 {
     fcs_state_keyval_pair_t pos_proto;
+    DECLARE_IND_BUF_T(indirect_stacks_buffer)
+
+    fcs_kv_state_t orig_pass;
+    orig_pass.key = &(orig->s);
+    orig_pass.val = &(orig->info);
+
+    fcs_kv_state_t pos_pass;
+    pos_pass.key = &(pos_proto.s);
+    pos_pass.val = &(pos_proto.info);
+
+    fcs_duplicate_kv_state(&pos_pass, &orig_pass);
+    for (int i = 0 ; i < 8 ; i++)
+    {
+        fcs_copy_stack(pos_proto.s, pos_proto.info, i, indirect_stacks_buffer);
+    }
+
 #define pos (pos_proto.s)
     fcs_moves_processed_t * ret;
     int virtual_stack_len[8];
     int i, j, move_idx, num_back_end_moves;
     fcs_move_t move, out_move, * next_move_ptr;
 
-    pos_proto = *orig;
-
     num_back_end_moves = moves_seq->num_moves;
     next_move_ptr = moves_seq->moves;
 
 
     for(i=0;i<8;i++)
     {
-        fcs_cards_column_t col = fcs_state_get_col(orig->s, i);
+        fcs_cards_column_t col = fcs_state_get_col(pos, i);
         virtual_stack_len[i] = fcs_col_len(col);
     }
 #ifndef NDEBUG
                 /* Check the intermediate position validity */
                 char exists[4*13];
                 int rank, suit;
-                int fc, col, count, i;
+                int fc, col, count;
                 fcs_card_t card;
 
                 memset(exists, '\0', sizeof(exists));
                 }
                 for (col=0;col<8;col++)
                 {
-                    count = pos.tableau[col].count;
+                    fcs_cards_column_t col_col = fcs_state_get_col(pos, col);
+                    count = fcs_col_len(col_col);
                     for (i=0;i<count;i++)
                     {
-                        card = pos.tableau[col].cards[i];
-                        exists[(card & 0x0F)-1+(card >> 4)*13] = 1;
+                        card = fcs_col_get_card(col_col, i);
+                        exists[fcs_card_rank(card)-1+fcs_card_suit(card)*13] = 1;
                     }
                 }
                 for (fc=0;fc<num_freecells;fc++)
                 {
-                    card = pos.hold[fc];
-                    if (card != 0)
+                    card = fcs_freecell_card(pos, fc);
+                    if (! fcs_card_is_empty(card))
                     {
-                        exists[(card & 0x0F)-1+(card >> 4)*13] = 1;
+                        exists[fcs_card_rank(card)-1+fcs_card_suit(card)*13] = 1;
                     }
                 }
                 for (i=0;i<52;i++)
             }
 #endif
 
+#if 0
+    fcs_state_locs_struct_t locs;
+    fc_solve_init_locs(&locs);
+            printf("STATE=<<<\n%s\n>>>\n",
+                fc_solve_state_as_string(
+                    &pos,
+                    &pos_proto.info,
+                    &locs,
+                    4,
+                    8,
+                    1,
+                    TRUE,
+                    FALSE,
+                    TRUE
+                )
+            );
+#endif
+
             for (i = 0 ; i < 8 ; i++)
             {
                 int rank, suit;

File fc-solve/source/lib.c

     fc_solve_instance_t * fc_solve_obj;
     fcs_state_keyval_pair_t state;
     fcs_state_keyval_pair_t running_state;
+    fcs_state_keyval_pair_t initial_non_canonized_state;
     fcs_state_locs_struct_t state_locs;
     fcs_state_locs_struct_t trace_solution_state_locs;
     fcs_state_locs_struct_t initial_state_locs;
 #endif
 
 static int calc_moves_seq(
-    fcs_move_stack_t * solution_moves,
+    const fcs_move_stack_t * const solution_moves,
     fcs_moves_sequence_t * const moves_seq
 )
 {
             calc_moves_seq(&(flare->obj->solution_moves), &moves_seq);
 
             flare->fc_pro_moves = fc_solve_moves_processed_gen(
-                &(user->state),
+                &(user->initial_non_canonized_state),
                 user->common_preset.game_params.freecells_num,
                 &(moves_seq)
             );
 
             state_pass.key = &(user->state.s);
             state_pass.val = &(user->state.info);
-            /* running_state is a normalized state. So We're duplicating
-             * state to it before state state_pass is canonized
+            /* running_state and initial_non_canonized_state are
+             * normalized state. So We're duplicating
+             * state to it before state state_pass is canonized.
              * */
             {
                 fcs_kv_state_t pass;
                 fcs_duplicate_kv_state(&pass, &state_pass);
             }
 
+            {
+                fcs_kv_state_t initial_pass;
+                initial_pass.key = &(user->initial_non_canonized_state.s);
+                initial_pass.val = &(user->initial_non_canonized_state.info);
+
+                fcs_duplicate_kv_state(&initial_pass, &state_pass);
+            }
+
             fc_solve_canonize_state_with_locs
                 (
                  &state_pass,