Commits

Shlomi Fish committed 603c91c

Revert "atomic moves to vacant_state_resources_ptr."

This reverts commit ef3e781006bcca1975005a56504eca4b0a2ae0b1.

Comments (0)

Files changed (1)

fc-solve/source/freecell.c

 
     if (num_vacant_stacks > 0)
     {
-        int dest_stack_idx = vacant_state_resources_ptr->vacant_stack_idxs[0];
+        int dest_stack_idx = -1;
         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 = vacant_state_resources_ptr->vacant_stack_idxs[0];
+    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;
+        }
+    }
 
     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 = vacant_state_resources_ptr->vacant_freecell_idxs[0];
+    int ds;
+    for (ds = 0 ; ds < LOCAL_FREECELLS_NUM ; ds++)
+    {
+        if (fcs_freecell_is_empty(state, ds))
+        {
+            break;
+        }
+    }
 
     for (int stack_idx = 0 ; stack_idx < LOCAL_STACKS_NUM ; stack_idx++)
     {
     }
 
     /* Find a vacant stack */
-    int ds = vacant_state_resources_ptr->vacant_stack_idxs[0];
+    int ds;
+    for (ds = 0 ; ds < LOCAL_STACKS_NUM ; ds++)
+    {
+        if (fcs_col_len(
+            fcs_state_get_col(state, ds)
+            ) == 0)
+        {
+            break;
+        }
+    }
 
     for (int fc = 0 ; fc < LOCAL_FREECELLS_NUM ; fc++)
     {