Commits

Shlomi Fish committed 1bf27af

Revert "Revert "Convert to fcs_vacant_state_resources_info_t.""

This reverts commit 54f26f905e233831d4acbaceaf7cab8d79c64e0a.

Comments (0)

Files changed (5)

fc-solve/source/freecell.c

     return;
 }
 
+#define SET_EMPTY_TWO_COLS_COUNTERS() \
+    int dest_fc_idx_idx = 0; \
+    int dest_stack_idx_idx = 0;
+
 /*
  * This function empties two stacks from the new state
  * into freeeclls and empty columns
     fcs_kv_state_t * kv_ptr_new_state,
     fcs_move_stack_t * moves,
     const int cols_indexes[3],
-    int nc1, int nc2
+    int nc1, int nc2,
+    const fcs_vacant_state_resources_info_t * const vacant_state_resources_ptr,
+    const int num_vacant_freecells,
+    const int num_vacant_stacks,
+    int * const ptr_fc_idx_idx,
+    int * const ptr_stack_idx_idx
 )
 {
 #define key_ptr_new_state_key (kv_ptr_new_state->key)
     const int * col_idx = cols_indexes;
     int * col_num_cards = num_cards_to_move_from_columns;
 
-#if ((!defined(HARD_CODED_NUM_FREECELLS)) || (!defined(HARD_CODED_NUM_STACKS)))
-    SET_INSTANCE_GAME_PARAMS(soft_thread->hard_thread->instance);
-#endif
-
 #ifdef INDIRECT_STACK_STATES
     char * indirect_stacks_buffer = soft_thread->hard_thread->indirect_stacks_buffer;
 #endif
     {
         int dest_fc_idx;
 
-        dest_fc_idx = 0;
-
         while (1)
         {
             while ((*col_num_cards) == 0)
                 }
             }
 
-            /* Find a vacant freecell */
-            for( ; dest_fc_idx < LOCAL_FREECELLS_NUM ; dest_fc_idx++)
+            if (*ptr_fc_idx_idx == num_vacant_freecells)
             {
-                if (fcs_freecell_rank(
-                        temp_new_state_key, dest_fc_idx
-                    ) == 0)
-                {
-                    break;
-                }
-            }
-            if (dest_fc_idx == LOCAL_FREECELLS_NUM)
-            {
-                /*  Move on to the stacks. */
                 break;
             }
+            dest_fc_idx = vacant_state_resources_ptr->vacant_freecell_idxs[
+                (*ptr_fc_idx_idx)++
+            ];
 
             fcs_cards_column_t new_from_which_col = fcs_state_get_col(temp_new_state_key, *col_idx);
 
     {
         int put_cards_in_col_idx;
 
-        put_cards_in_col_idx = 0;
         /* Fill the free stacks with the cards below them */
         while (1)
         {
                 }
             }
 
-            /*  Find a vacant stack */
-            for( ; put_cards_in_col_idx < LOCAL_STACKS_NUM ; put_cards_in_col_idx++)
-            {
-                if (fcs_col_len(
-                    fcs_state_get_col(temp_new_state_key, put_cards_in_col_idx)
-                    ) == 0)
-                {
-                    break;
-                }
-            }
-
-            assert(put_cards_in_col_idx < LOCAL_STACKS_NUM );
+            assert((*ptr_stack_idx_idx) < num_vacant_stacks);
+            put_cards_in_col_idx =
+                vacant_state_resources_ptr->vacant_stack_idxs[
+                    (*ptr_stack_idx_idx)++
+                ];
 
             fcs_copy_stack(temp_new_state_key, *(kv_ptr_new_state->val), put_cards_in_col_idx, indirect_stacks_buffer);
 
     SET_GAME_PARAMS();
 #endif
 
-    fcs_game_limit_t num_vacant_freecells = soft_thread->num_vacant_freecells;
-    fcs_game_limit_t num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_FREECELLS_AND_STACKS();
 
     int initial_derived_states_num_states = derived_states_list->num_states;
 
                         cols_indexes[1] = -1;
                         cols_indexes[2] = -1;
 
+                        SET_EMPTY_TWO_COLS_COUNTERS();
+
                         empty_two_cols_from_new_state(
                                 soft_thread,
                                 NEW_STATE_BY_REF(),
                                 moves,
                                 cols_indexes,
                                 dest_cards_num - dc - 1,
-                                0
+                                0,
+                                vacant_state_resources_ptr,
+                                num_vacant_freecells,
+                                num_vacant_stacks,
+                                &dest_fc_idx_idx,
+                                &dest_stack_idx_idx
                         );
 
                         new_dest_col = fcs_state_get_col(new_state, ds);
 #if ((!defined(HARD_CODED_NUM_FREECELLS)) || (!defined(HARD_CODED_NUM_STACKS)))
     SET_GAME_PARAMS();
 #endif
-    fcs_game_limit_t num_vacant_freecells = soft_thread->num_vacant_freecells;
-    fcs_game_limit_t num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_FREECELLS_AND_STACKS();
 
     /* Now let's check if a card that is under some other cards can be placed
      * in the foundations. */
                         cols_indexes[1] = -1;
                         cols_indexes[2] = -1;
 
+                        SET_EMPTY_TWO_COLS_COUNTERS();
+
                         empty_two_cols_from_new_state(
                             soft_thread,
                             NEW_STATE_BY_REF(),
                             moves,
                             cols_indexes,
                             cards_num-(c+1),
-                            0
+                            0,
+                            vacant_state_resources_ptr,
+                            num_vacant_freecells,
+                            num_vacant_stacks,
+                            &dest_fc_idx_idx,
+                            &dest_stack_idx_idx
                         );
 
                         new_src_col = fcs_state_get_col(new_state, stack_idx);
     SET_GAME_PARAMS();
 #endif
 
-    fcs_game_limit_t num_vacant_freecells = soft_thread->num_vacant_freecells;
-    fcs_game_limit_t num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_FREECELLS_AND_STACKS();
 
     /*
      * Now let's try to move a stack card to a parent card which is found
                                 /* We can move it */
                                 sfs_check_state_begin()
 
+                                SET_EMPTY_TWO_COLS_COUNTERS();
+
                                 my_copy_stack(ds);
 
                                 fcs_cards_column_t new_dest_col = fcs_state_get_col(new_state, ds);
                                     cols_indexes,
                                     /* We're moving one extra card */
                                     cards_num - c,
-                                    0
+                                    0,
+                                    vacant_state_resources_ptr,
+                                    num_vacant_freecells,
+                                    num_vacant_stacks,
+                                    &dest_fc_idx_idx,
+                                    &dest_stack_idx_idx
                                 );
 
                                 int source_index = last_dest & 0xFF;
                                     moves,
                                     cols_indexes,
                                     c - dc - 1,
-                                    0
+                                    0,
+                                    vacant_state_resources_ptr,
+                                    num_vacant_freecells,
+                                    num_vacant_stacks,
+                                    &dest_fc_idx_idx,
+                                    &dest_stack_idx_idx
                                 );
 
                                 fcs_card_t moved_card;
     SET_GAME_PARAMS();
 #endif
 
-    const fcs_game_limit_t num_vacant_freecells
-        = soft_thread->num_vacant_freecells;
-    const fcs_game_limit_t num_vacant_stacks
-         = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_FREECELLS_AND_STACKS();
 
     const int initial_derived_states_num_states =
         derived_states_list->num_states;
                 {
                     sfs_check_state_begin()
 
+                    SET_EMPTY_TWO_COLS_COUNTERS();
+
                     my_copy_stack(stack_idx);
                     my_copy_stack(ds);
 
                         moves,
                         cols_indexes,
                         fcs_col_len(dest_col) - dc - 1,
-                        fcs_col_len(col) - seq_end - 1
+                        fcs_col_len(col) - seq_end - 1,
+                        vacant_state_resources_ptr,
+                        num_vacant_freecells,
+                        num_vacant_stacks,
+                        &dest_fc_idx_idx,
+                        &dest_stack_idx_idx
                     );
 
                     fcs_move_sequence(ds, stack_idx, c, seq_end);
 #if ((!defined(HARD_CODED_NUM_FREECELLS)) || (!defined(HARD_CODED_NUM_STACKS)))
     SET_GAME_PARAMS();
 #endif
-    const fcs_game_limit_t num_vacant_freecells = soft_thread->num_vacant_freecells;
-    const fcs_game_limit_t num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_FREECELLS_AND_STACKS();
 
     const int max_sequence_len = calc_max_sequence_move(num_vacant_freecells, num_vacant_stacks-1);
 
                             int cols_indexes[3];
                             int empty_ret;
 
+
                             sfs_check_state_begin();
 
+                            SET_EMPTY_TWO_COLS_COUNTERS();
+
                             /* Fill the freecells with the top cards */
 
                             my_copy_stack(stack_idx);
                                 moves,
                                 cols_indexes,
                                 freecells_to_fill + freestacks_to_fill,
-                                0
+                                0,
+                                vacant_state_resources_ptr,
+                                num_vacant_freecells,
+                                num_vacant_stacks,
+                                &dest_fc_idx_idx,
+                                &dest_stack_idx_idx
                             );
 
                             int b;
     SET_GAME_PARAMS();
 #endif
 
-    if (soft_thread->num_vacant_stacks)
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
+
+    if (num_vacant_stacks)
     {
         int stack_idx;
         for (stack_idx = 0 ; stack_idx < LOCAL_STACKS_NUM ; stack_idx++)
 #if ((!defined(HARD_CODED_NUM_FREECELLS)) || (!defined(HARD_CODED_NUM_STACKS)) || (!defined(HARD_CODED_NUM_DECKS)))
     SET_GAME_PARAMS();
 #endif
-    const fcs_game_limit_t num_vacant_freecells = soft_thread->num_vacant_freecells;
-    const fcs_game_limit_t num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_FREECELLS_AND_STACKS();
 
     const int initial_derived_states_num_states = derived_states_list->num_states;
 
                 {
                     int cols_indexes[3];
 
+                    SET_EMPTY_TWO_COLS_COUNTERS();
+
                     sfs_check_state_begin()
 
                     /* Fill the freecells with the top cards */
                         moves,
                         cols_indexes,
                         freestacks_to_fill + freecells_to_fill,
-                        0
+                        0,
+                        vacant_state_resources_ptr,
+                        num_vacant_freecells,
+                        num_vacant_stacks,
+                        &dest_fc_idx_idx,
+                        &dest_stack_idx_idx
                     );
 
                     my_copy_stack(stack_idx);
     SET_GAME_PARAMS();
 #endif
 
-    const fcs_game_limit_t num_vacant_freecells = soft_thread->num_vacant_freecells;
-    const fcs_game_limit_t num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_FREECELLS_AND_STACKS();
 
     /* Now, let's try to empty an entire stack into the freecells, so other cards can
      * inhabit it */
 #ifndef HARD_CODED_NUM_STACKS
     int stacks_num;
 #endif
-    fcs_game_limit_t num_vacant_stacks;
-
     fcs_internal_move_t temp_move;
 
     tests_define_accessors();
 
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_STACKS();
     temp_move = fc_solve_empty_move;
 
     if (num_vacant_stacks == 0)
         return;
     }
 
-    const fcs_game_limit_t num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     if (num_vacant_stacks == 0)
     {
     SET_GAME_PARAMS();
 #endif
 
-    const fcs_game_limit_t num_vacant_freecells = soft_thread->num_vacant_freecells;
+    SET_VACANT_PTR();
+    SET_VACANT_FREECELLS();
 
     if (num_vacant_freecells == 0)
     {
         return;
     }
 
-    const fcs_game_limit_t num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     if (num_vacant_stacks == 0)
     {

fc-solve/source/instance.h

     fcs_by_depth_tests_order_t * by_depth_tests;
 } fcs_by_depth_tests_order_array_t;
 
+typedef struct
+{
+    fcs_game_limit_t num_vacant_freecells, num_vacant_stacks;
+    fcs_game_limit_t vacant_freecell_idxs[MAX_NUM_FREECELLS],
+                     vacant_stack_idxs[MAX_NUM_STACKS];
+} fcs_vacant_state_resources_info_t;
+
 typedef struct {
     /*
      * The number of Freecells, Stacks and Foundations present in the game.
     int derived_states_random_indexes_max_size;
     int * derived_states_random_indexes;
     char * positions_by_rank;
-    fcs_game_limit_t num_vacant_stacks;
-    fcs_game_limit_t num_vacant_freecells;
+    fcs_vacant_state_resources_info_t vacant_state_resources;
 } fcs_soft_dfs_stack_item_t;
 
 enum
              * performed. FCS performs each test separately, so
              * states_to_check and friends will not be overpopulated.
              *
-             * num_vacant_stacks - the number of unoccpied stacks that
-             * correspond
-             * to solution_states.
-             *
-             * num_vacant_freecells - ditto for the freecells.
+             * vacant_state_resources_ptr - the number and indexes of
+             * unoccupied stacks and freecells that correspond to
+             * solution_states.
              *
              * */
 
                     double befs_weights[5];
                 } befs;
             } meth;
+            fcs_vacant_state_resources_info_t vacant_state_resources;
         } befs;
     } method_specific;
 
     fcs_runtime_flags_t runtime_flags;
 
     /*
-     * The number of vacant stacks in the current state - is read from
-     * the test functions in freecell.c .
-     * */
-     fcs_game_limit_t num_vacant_stacks;
-
-    /*
-     * The number of vacant freecells in the current state - is read
-     * from the test functions in freecell.c .
+     * The number and indexes of vacant stacks and freecells
+     * in the current state - is read from the test functions in
+     * freecell.c .
      * */
-    fcs_game_limit_t num_vacant_freecells;
+    fcs_vacant_state_resources_info_t * vacant_state_resources_ptr;
 
     /*
      * The number of iterations with which to process this scan

fc-solve/source/meta_move_funcs_helpers.h

  * */
 #define tests__should_not_empty_columns() tests__is_filled_by_none()
 
+#define SET_VACANT_PTR() \
+    const fcs_vacant_state_resources_info_t * const \
+        vacant_state_resources_ptr = \
+            soft_thread->vacant_state_resources_ptr;
+
+/* Requires adding a SET_VACANT_PTR() before it. */
+#define SET_VACANT_FREECELLS() \
+    const fcs_game_limit_t num_vacant_freecells = \
+        vacant_state_resources_ptr->num_vacant_freecells;
+
+/* Requires adding a SET_VACANT_PTR() before it. */
+#define SET_VACANT_STACKS() \
+    const fcs_game_limit_t num_vacant_stacks = \
+        vacant_state_resources_ptr->num_vacant_stacks;
+
+#define SET_VACANT_FREECELLS_AND_STACKS() \
+    SET_VACANT_FREECELLS(); \
+    SET_VACANT_STACKS();
+
 #ifdef __cplusplus
 }
 #endif

fc-solve/source/scans.c

 #endif
 
 
-static GCC_INLINE fcs_game_limit_t count_num_vacant_freecells(
+static GCC_INLINE void calc_num_vacanct_resources(
         const fcs_game_limit_t freecells_num,
-        const fcs_state_t * const state_ptr
+        const fcs_game_limit_t stacks_num,
+        const fcs_state_t * const state_ptr,
+        fcs_vacant_state_resources_info_t * const out_resources
         )
 {
-    fcs_game_limit_t num_vacant_freecells = 0;
-    for(int i=0;i<freecells_num;i++)
     {
-        if (fcs_freecell_is_empty(*state_ptr, i))
+        fcs_game_limit_t num_vacant_freecells = 0;
+        for (int i = 0 ; i < freecells_num ; i++)
         {
-            num_vacant_freecells++;
+            if (fcs_freecell_is_empty(*state_ptr, i))
+            {
+                out_resources->vacant_freecell_idxs[num_vacant_freecells++] = i;
+            }
         }
-    }
-
-    return num_vacant_freecells;
-}
 
-static GCC_INLINE fcs_game_limit_t count_num_vacant_stacks(
-        const fcs_game_limit_t stacks_num,
-        const fcs_state_t * const state_ptr
-        )
-{
-    fcs_game_limit_t num_vacant_stacks = 0;
-
-    for (int  i=0 ; i < stacks_num ; i++ )
+        out_resources->num_vacant_freecells = num_vacant_freecells;
+    }
     {
-        if (fcs_col_len(fcs_state_get_col(*state_ptr, i)) == 0)
+        fcs_game_limit_t num_vacant_stacks = 0;
+
+        for (int i=0 ; i < stacks_num ; i++ )
         {
-            num_vacant_stacks++;
+            if (fcs_col_len(fcs_state_get_col(*state_ptr, i)) == 0)
+            {
+                out_resources->vacant_stack_idxs[num_vacant_stacks++] = i;
+            }
         }
+
+        out_resources->num_vacant_stacks = num_vacant_stacks;
     }
 
-    return num_vacant_stacks;
+    return;
 }
 
 
             dfs_max_depth = soft_thread->method_specific.soft_dfs.dfs_max_depth;
             /* This too has to be re-synced */
             derived_states_list = &(the_soft_dfs_info->derived_states_list);
+            soft_thread->vacant_state_resources_ptr = &(the_soft_dfs_info->vacant_state_resources);
         }
 
         TRACE0("Before current_state_index check");
 
                     VERIFY_PTR_STATE_TRACE0("Verify Foo");
 
-                    soft_thread->num_vacant_freecells = the_soft_dfs_info->num_vacant_freecells;
-                    soft_thread->num_vacant_stacks = the_soft_dfs_info->num_vacant_stacks;
+                    soft_thread->vacant_state_resources_ptr = &(the_soft_dfs_info->vacant_state_resources);
 
                     if (unlikely(DEPTH() < by_depth_min_depth))
                     {
                 && (the_soft_dfs_info->tests_list_index == 0)
                )
             {
-                fcs_game_limit_t num_vacant_stacks, num_vacant_freecells;
-
                 TRACE0("In iter_handler");
 
                 if (debug_iter_output_func)
                         );
                 }
 
-                num_vacant_freecells =
-                    count_num_vacant_freecells(LOCAL_FREECELLS_NUM, &the_state);
-
-                num_vacant_stacks =
-                    count_num_vacant_stacks(LOCAL_STACKS_NUM, &the_state);
+                calc_num_vacanct_resources(
+                    LOCAL_FREECELLS_NUM,
+                    LOCAL_STACKS_NUM,
+                    &the_state,
+                    &(the_soft_dfs_info->vacant_state_resources)
+                );
 
                 /* Check if we have reached the empty state */
-                if (unlikely((num_vacant_stacks == LOCAL_STACKS_NUM) &&
-                    (num_vacant_freecells  == LOCAL_FREECELLS_NUM)))
+                if (unlikely((the_soft_dfs_info->vacant_state_resources.num_vacant_stacks == LOCAL_STACKS_NUM) &&
+                    (the_soft_dfs_info->vacant_state_resources.num_vacant_freecells  == LOCAL_FREECELLS_NUM)))
                 {
                     instance->final_state = PTR_STATE;
 
                     appropriate stacks, so they won't be calculated over and over
                     again.
                   */
-                soft_thread->num_vacant_freecells =
-                    the_soft_dfs_info->num_vacant_freecells =
-                    num_vacant_freecells;
-                soft_thread->num_vacant_stacks =
-                    the_soft_dfs_info->num_vacant_stacks =
-                    num_vacant_stacks;
+                soft_thread->vacant_state_resources_ptr =
+                    &(the_soft_dfs_info->vacant_state_resources);
 
                 /* Perform the pruning. */
                 if (SHOULD_STATE_BE_PRUNED(enable_pruning, PTR_STATE))
     pass.key = &(instance->state_copy_ptr->s);
     pass.val = &(instance->state_copy_ptr->info);
 
+    soft_thread->vacant_state_resources_ptr =
+        &(soft_thread->method_specific.befs.vacant_state_resources);
+
     if (soft_thread->method == FCS_METHOD_A_STAR)
     {
         /* Initialize the priotity queue of the BeFS scan */
 
         TRACE0("Counting cells");
 
-        const fcs_game_limit_t num_vacant_freecells =
-            count_num_vacant_freecells(LOCAL_FREECELLS_NUM, &the_state);
-
-        const fcs_game_limit_t num_vacant_stacks =
-            count_num_vacant_stacks(LOCAL_STACKS_NUM, &the_state);
+        calc_num_vacanct_resources(
+            LOCAL_FREECELLS_NUM,
+            LOCAL_STACKS_NUM,
+            &the_state,
+            &(soft_thread->method_specific.befs.vacant_state_resources)
+        );
 
         if (check_if_limits_exceeded())
         {
         }
 
 
-        if ((num_vacant_stacks == LOCAL_STACKS_NUM) && (num_vacant_freecells == LOCAL_FREECELLS_NUM))
+        if ((soft_thread->method_specific.befs.vacant_state_resources.num_vacant_stacks == LOCAL_STACKS_NUM)
+            && (soft_thread->method_specific.befs.vacant_state_resources.num_vacant_freecells == LOCAL_FREECELLS_NUM))
         {
             instance->final_state = PTR_STATE;
 
 
         calculate_real_depth (calc_real_depth, PTR_STATE);
 
-        soft_thread->num_vacant_freecells = num_vacant_freecells;
-        soft_thread->num_vacant_stacks = num_vacant_stacks;
-
         if (soft_thread->method_specific.befs.befs_positions_by_rank)
         {
             free(soft_thread->method_specific.befs.befs_positions_by_rank);

fc-solve/source/simpsim.c

 
 DECLARE_MOVE_FUNCTION(fc_solve_sfs_simple_simon_move_sequence_to_true_parent)
 {
-    fcs_game_limit_t num_vacant_stacks;
-
     /*
      * stack - the source stack index on which the sequence currently resides.
      * cards_num - the number of cards in "stack".
     SET_GAME_PARAMS();
 #endif
 
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     for(stack_idx=0;stack_idx<LOCAL_STACKS_NUM;stack_idx++)
     {
     fcs_card_t card, dest_card;
     int rank, num_true_seqs, h, ds, dest_cards_num ;
     fcs_cards_column_t col, dest_col;
-    fcs_game_limit_t num_vacant_stacks;
 
     tests_define_accessors();
 
     SET_GAME_PARAMS();
 #endif
 
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     for(stack_idx=0;stack_idx<LOCAL_STACKS_NUM;stack_idx++)
     {
     int stacks_map[MAX_NUM_STACKS];
     int after_junk_num_freestacks;
     int junk_move_to_stacks[MAX_NUM_STACKS];
-    fcs_game_limit_t num_vacant_stacks;
 
     tests_define_accessors();
 
 #ifndef HARD_CODED_NUM_STACKS
     SET_GAME_PARAMS();
 #endif
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     for(stack_idx=0;stack_idx<LOCAL_STACKS_NUM;stack_idx++)
     {
     int after_junk_num_freestacks;
     int false_seq_index;
     int junk_move_to_stacks[MAX_NUM_CARDS_IN_A_STACK];
-    fcs_game_limit_t num_vacant_stacks;
 
     fcs_cards_column_t col;
     fcs_cards_column_t dest_col;
     SET_GAME_PARAMS();
 #endif
 
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     for(stack_idx=0;stack_idx<LOCAL_STACKS_NUM;stack_idx++)
     {
     int num_src_junk_true_seqs;
     int end_of_junk;
     int num_true_seqs;
-    fcs_game_limit_t num_vacant_stacks;
 
     fcs_cards_column_t col;
     fcs_cards_column_t dest_col;
 #ifndef HARD_CODED_NUM_STACKS
     SET_GAME_PARAMS();
 #endif
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     for(stack_idx=0;stack_idx<LOCAL_STACKS_NUM;stack_idx++)
     {
     int after_junk_num_freestacks;
     int false_seq_index;
     int junk_move_to_stacks[MAX_NUM_STACKS];
-    fcs_game_limit_t num_vacant_stacks;
 
     fcs_cards_column_t col;
     fcs_cards_column_t dest_col;
 #ifndef HARD_CODED_NUM_STACKS
     SET_GAME_PARAMS();
 #endif
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     for(stack_idx=0;stack_idx<LOCAL_STACKS_NUM;stack_idx++)
     {
     int false_seq_index;
     int child_seq_index;
 
-    fcs_game_limit_t num_vacant_stacks;
-
     fcs_cards_column_t col;
     fcs_cards_column_t clear_junk_dest_col;
     tests_define_accessors();
 #ifndef HARD_CODED_NUM_STACKS
     SET_GAME_PARAMS();
 #endif
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     for(stack_idx=0 ; stack_idx < LOCAL_STACKS_NUM ; stack_idx++)
     {
     int num_true_seqs, seq_size, h, ds, dest_cards_num;
     fcs_cards_column_t col, dest_col;
     int cards_num;
-    fcs_game_limit_t num_vacant_stacks;
 
     tests_define_accessors();
 
 #ifndef HARD_CODED_NUM_STACKS
     SET_GAME_PARAMS();
 #endif
-    num_vacant_stacks = soft_thread->num_vacant_stacks;
+    SET_VACANT_PTR();
+    SET_VACANT_STACKS();
 
     for(stack_idx=0 ; stack_idx < LOCAL_STACKS_NUM ; stack_idx++)
     {