Shlomi Fish avatar Shlomi Fish committed 733120d

Revert "Adapt empty_two_cols_from_new_state() for vacant."

This reverts commit 7272119b19a0b22cd6dd716f54e5dd0efbaea7c5.

Comments (0)

Files changed (1)

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,
-    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
+    int nc1, int nc2
 )
 {
 #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)
                 }
             }
 
-            if (*ptr_fc_idx_idx == num_vacant_freecells)
+            /* Find a vacant freecell */
+            for( ; dest_fc_idx < LOCAL_FREECELLS_NUM ; dest_fc_idx++)
+            {
+                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)
         {
                 }
             }
 
-            assert((*ptr_stack_idx_idx) < num_vacant_stacks);
-            put_cards_in_col_idx =
-                vacant_state_resources_ptr->vacant_stack_idxs[
-                    (*ptr_stack_idx_idx)++
-                ];
+            /*  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 );
 
             fcs_copy_stack(temp_new_state_key, *(kv_ptr_new_state->val), put_cards_in_col_idx, indirect_stacks_buffer);
 
                         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,
-                                vacant_state_resources_ptr,
-                                num_vacant_freecells,
-                                num_vacant_stacks,
-                                &dest_fc_idx_idx,
-                                &dest_stack_idx_idx
+                                0
                         );
 
                         new_dest_col = fcs_state_get_col(new_state, ds);
                         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,
-                            vacant_state_resources_ptr,
-                            num_vacant_freecells,
-                            num_vacant_stacks,
-                            &dest_fc_idx_idx,
-                            &dest_stack_idx_idx
+                            0
                         );
 
                         new_src_col = fcs_state_get_col(new_state, stack_idx);
                                 /* 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,
-                                    vacant_state_resources_ptr,
-                                    num_vacant_freecells,
-                                    num_vacant_stacks,
-                                    &dest_fc_idx_idx,
-                                    &dest_stack_idx_idx
+                                    0
                                 );
 
                                 int source_index = last_dest & 0xFF;
                                     moves,
                                     cols_indexes,
                                     c - dc - 1,
-                                    0,
-                                    vacant_state_resources_ptr,
-                                    num_vacant_freecells,
-                                    num_vacant_stacks,
-                                    &dest_fc_idx_idx,
-                                    &dest_stack_idx_idx
+                                    0
                                 );
 
                                 fcs_card_t moved_card;
                 {
                     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,
-                        vacant_state_resources_ptr,
-                        num_vacant_freecells,
-                        num_vacant_stacks,
-                        &dest_fc_idx_idx,
-                        &dest_stack_idx_idx
+                        fcs_col_len(col) - seq_end - 1
                     );
 
                     fcs_move_sequence(ds, stack_idx, c, seq_end);
                             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,
-                                vacant_state_resources_ptr,
-                                num_vacant_freecells,
-                                num_vacant_stacks,
-                                &dest_fc_idx_idx,
-                                &dest_stack_idx_idx
+                                0
                             );
 
                             int b;
                 {
                     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,
-                        vacant_state_resources_ptr,
-                        num_vacant_freecells,
-                        num_vacant_stacks,
-                        &dest_fc_idx_idx,
-                        &dest_stack_idx_idx
+                        0
                     );
 
                     my_copy_stack(stack_idx);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.