Commits

Shlomi Fish committed ef3e781

atomic moves to vacant_state_resources_ptr.

Comments (0)

Files changed (1)

fc-solve/source/freecell.c

 
     if (num_vacant_stacks > 0)
     {
-        int dest_stack_idx = -1;
+        int dest_stack_idx = vacant_state_resources_ptr->vacant_stack_idxs[0];
         for (int stack_idx = 0 ; stack_idx < LOCAL_STACKS_NUM ; stack_idx++)
         {
             fcs_cards_column_t col = fcs_state_get_col(state, stack_idx);
                     {
                         sfs_check_state_begin();
 
-                        if (dest_stack_idx < 0)
-                        {
-                            for (dest_stack_idx = 0 ;
-                                 dest_stack_idx < LOCAL_STACKS_NUM;
-                                 dest_stack_idx++)
-                            {
-                                if (fcs_col_len(
-                                    fcs_state_get_col(new_state, dest_stack_idx)
-                                    ) == 0)
-                                {
-                                    break;
-                                }
-                            }
-                        }
-
                         my_copy_stack(dest_stack_idx);
                         my_copy_stack(stack_idx);
 
     SET_GAME_PARAMS();
 #endif
 
-    int empty_stack_idx;
-    for (empty_stack_idx = 0 ; empty_stack_idx < LOCAL_STACKS_NUM ; empty_stack_idx++)
-    {
-        if (fcs_col_len(
-            fcs_state_get_col(state, empty_stack_idx)
-            ) == 0)
-        {
-            break;
-        }
-    }
+    int empty_stack_idx = vacant_state_resources_ptr->vacant_stack_idxs[0];
 
     for (int stack_idx = 0 ; stack_idx < LOCAL_STACKS_NUM ; stack_idx++)
     {
 
     const int num_cards_in_col_threshold = tests__should_not_empty_columns() ? 1 : 0;
 
-    int ds;
-    for (ds = 0 ; ds < LOCAL_FREECELLS_NUM ; ds++)
-    {
-        if (fcs_freecell_is_empty(state, ds))
-        {
-            break;
-        }
-    }
+    int ds = vacant_state_resources_ptr->vacant_freecell_idxs[0];
 
     for (int stack_idx = 0 ; stack_idx < LOCAL_STACKS_NUM ; stack_idx++)
     {
     }
 
     /* Find a vacant stack */
-    int ds;
-    for (ds = 0 ; ds < LOCAL_STACKS_NUM ; ds++)
-    {
-        if (fcs_col_len(
-            fcs_state_get_col(state, ds)
-            ) == 0)
-        {
-            break;
-        }
-    }
+    int ds = vacant_state_resources_ptr->vacant_stack_idxs[0];
 
     for (int fc = 0 ; fc < LOCAL_FREECELLS_NUM ; fc++)
     {