Commits

Shlomi Fish committed bdafa98

Implement the 6th BEFS weight.

For depth of irreveresibility moves. It seems to yield interesting
resutls.

Comments (0)

Files changed (7)

fc-solve/source/NEWS.txt

 a leading colon (":"). As a result, one can input the states as output from
 the solver with the +-p+ and +-t+ flags directly there.
 
+4. Added a 6th BeFS weight (see the +-asw+ flag) of the count of irreversible
+moves done. Using
++./freecell-solver-range-parallel-solve 1 32000 1 -p -t -sam --method a-star -to 0123467589 -asw 0,0,0,0,0,1 -sp r:tf -mi 100000+
+appears to be interesting.
+
+
 Version 3.12.0: (12-Jun-2012)
 -----------------------------
 

fc-solve/source/USAGE.txt

 $ fc-solve -g freecell --sequences-are-built-by rank --sequence-move unlimited
 ------------------------------------------
 
-5. Solving Algorithm Options
-----------------------------
+Solving Algorithm Options
+-------------------------
 
 -mi [Iterations num] , --max-iters [Iterations num]
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 3. The number of cards under sequences.
 4. The length of the sequences which are found over renegade cards.
 5. The depth of the board in the solution.
+6. The irreversibility-depth-cardinality of the layout, as a function of the
+number of cards not above their parents, and the number of cards in the
+foundations.
 
-The default weights are respectively: 0.5,0,0.3,0,0.2
+The default weights are respectively: {0.5, 0, 0.3, 0, 0.2, 0}
 
 
 -seed [Seed Number]

fc-solve/source/fcs_enums.h

 #define FCS_METHOD_OPTIMIZE 4
 #define FCS_METHOD_RANDOM_DFS 5
 
-#define FCS_NUM_BEFS_WEIGHTS 5
+#define FCS_NUM_BEFS_WEIGHTS 6
 
 #ifdef __cplusplus
 }

fc-solve/source/instance.c

     a guideline for the user.
 */
 
-const double fc_solve_default_befs_weights[5] = {0.5,0,0.3,0,0.2};
-
-
+const double fc_solve_default_befs_weights[FCS_NUM_BEFS_WEIGHTS] = {0.5, 0, 0.3, 0, 0.2, 0};
 
 static GCC_INLINE void normalize_befs_weights(
     fc_solve_soft_thread_t * soft_thread

fc-solve/source/instance.h

 #define FCS_BEFS_WEIGHT_CARDS_UNDER_SEQUENCES 2
 #define FCS_BEFS_WEIGHT_SEQS_OVER_RENEGADE_CARDS 3
 #define FCS_BEFS_WEIGHT_DEPTH 4
+#define FCS_BEFS_WEIGHT_IRREVERSIBLILITY_DEPTH 5
 
 fc_solve_instance_t * fc_solve_alloc_instance(void);
 

fc-solve/source/main.c

 "     3. The number of cards under sequences.\n"
 "     4. The length of the sequences which are found over renegade cards.\n"
 "     5. The depth of the board in the solution.\n"
+"     6. The depth of irreversible moves conducted in the board.\n"
 "\n"
 "-seed [seed_number]\n"
 "     Set the seed for the random number generator used by the\n"

fc-solve/source/scans.c

 #ifndef FCS_FREECELL_ONLY
     fc_solve_hard_thread_t * const hard_thread = soft_thread->hard_thread;
     fc_solve_instance_t * const instance = hard_thread->instance;
+    const int sequences_are_built_by =
+        GET_INSTANCE_SEQUENCES_ARE_BUILT_BY(instance)
+        ;
 #endif
     fcs_state_t * const state = raw_pass_raw->key;
 
 
     ret += ((double)num_cards_in_founds/(LOCAL_DECKS_NUM*52)) * befs_weights[FCS_BEFS_WEIGHT_CARDS_OUT];
 
+    {
+        int num_cards_not_on_parents = 0;
+
+        for (int stack_idx = 0 ; stack_idx < LOCAL_STACKS_NUM ; stack_idx++)
+        {
+            const fcs_cards_column_t col =
+                fcs_state_get_col(*state, stack_idx);
+
+            int col_len_minus_1 = fcs_col_len(col) - 1;
+            fcs_card_t parent_card = fcs_col_get_card(col, 0);
+            fcs_card_t child_card;
+            for (int h = 0 ; h < col_len_minus_1 ; h++)
+            {
+                child_card = fcs_col_get_card(col, h+1);
+
+                if (! fcs_is_parent_card(parent_card, child_card))
+                {
+                    num_cards_not_on_parents++;
+                }
+                parent_card = child_card;
+            }
+        }
+
+        /* 0 < num_cards_not_on_parents < 52
+         * 0 < num_cards_in_founds < 52
+         * -52 < -num_cards_not_on_parents < 0
+         * -52 < num_cards_in_founds - num_cards_not_on_parents < 52
+         *   */
+        ret += ( ((double)(num_cards_in_founds - num_cards_not_on_parents + (LOCAL_DECKS_NUM*52)))/(LOCAL_DECKS_NUM * (52 * 2))) * befs_weights[FCS_BEFS_WEIGHT_IRREVERSIBLILITY_DEPTH];
+    }
+
     fcs_game_limit_t num_vacant_freecells = 0;
     for (int freecell_idx = 0 ; freecell_idx < LOCAL_FREECELLS_NUM ; freecell_idx++)
     {