Commits

Shlomi Fish committed 711a827

Added the ds_order.c target.

git-svn-id: file:///home/shlomif/Backup/svn-dumps/google-code/svnsync-repos/fc-solve/trunk@555 e7e8a897-7ba4-4ee7-b36f-f4c66519b19a

Comments (0)

Files changed (8)

fc-solve/source/Makefile.am

 
 lib_LTLIBRARIES = libfreecell-solver.la
 libfreecell_solverincludedir=$(includedir)/freecell-solver
-libfreecell_solver_la_SOURCES = alloc.c app_str.c caas.c card.c cl_chop.c cmd_line.c fcs_dm.c fcs_hash.c fcs_isa.c freecell.c intrface.c lib.c lookup2.c move.c pqueue.c preset.c rand.c scans.c simpsim.c state.c tests.c
+libfreecell_solver_la_SOURCES = alloc.c app_str.c caas.c card.c cl_chop.c cmd_line.c ds_order.c fcs_dm.c fcs_hash.c fcs_isa.c freecell.c intrface.c lib.c lookup2.c move.c pqueue.c preset.c rand.c scans.c simpsim.c state.c tests.c
 libfreecell_solver_la_LDFLAGS = -version-info 5:0:5
 libfreecell_solverinclude_HEADERS = fcs_user.h fcs_enums.h fcs_move.h fcs_cl.h
 

fc-solve/source/Makefile.gnu

           card.o              \
           cl_chop.o           \
           cmd_line.o          \
+          ds_order.o          \
           fcs_dm.o            \
           fcs_hash.o          \
           fcs_isa.o           \

fc-solve/source/Makefile.lite

 cmd_line.o: cmd_line.c $(INCLUDES)
 	$(CC) -c $(OFLAGS) -o $@ $<
 
+ds_order.o: ds_order.c $(INCLUDES)
+	$(CC) -c $(OFLAGS) -o $@ $<
+
 fcs_dm.o: fcs_dm.c $(INCLUDES)
 	$(CC) -c $(OFLAGS) -o $@ $<
 
 main.o: main.c $(INCLUDES)
 	$(CC) -c $(OFLAGS) -o $@ $<
 
-OBJECTS = alloc.o app_str.o caas.o card.o cl_chop.o cmd_line.o fcs_dm.o fcs_hash.o fcs_isa.o freecell.o intrface.o lib.o lookup2.o move.o pqueue.o preset.o rand.o scans.o simpsim.o state.o tests.o main.o
+OBJECTS = alloc.o app_str.o caas.o card.o cl_chop.o cmd_line.o ds_order.o fcs_dm.o fcs_hash.o fcs_isa.o freecell.o intrface.o lib.o lookup2.o move.o pqueue.o preset.o rand.o scans.o simpsim.o state.o tests.o main.o
 #>>>OBJECTS.END
 
 fc-solve: $(OBJECTS)

fc-solve/source/Makefile.win32

 LIB32=link.exe
 
 
-OBJECTS = alloc.obj app_str.obj caas.obj card.obj cl_chop.obj cmd_line.obj fcs_dm.obj fcs_hash.obj fcs_isa.obj freecell.obj intrface.obj lib.obj lookup2.obj move.obj pqueue.obj preset.obj rand.obj scans.obj simpsim.obj state.obj tests.obj
+OBJECTS = alloc.obj app_str.obj caas.obj card.obj cl_chop.obj cmd_line.obj ds_order.obj fcs_dm.obj fcs_hash.obj fcs_isa.obj freecell.obj intrface.obj lib.obj lookup2.obj move.obj pqueue.obj preset.obj rand.obj scans.obj simpsim.obj state.obj tests.obj
 
 
 alloc.obj: alloc.c $(INCLUDES)
 cmd_line.obj: cmd_line.c $(INCLUDES)
 	$(CC) /c /Focmd_line.obj $(OFLAGS) cmd_line.c
 
+ds_order.obj: ds_order.c $(INCLUDES)
+	$(CC) /c /Fods_order.obj $(OFLAGS) ds_order.c
+
 fcs_dm.obj: fcs_dm.c $(INCLUDES)
 	$(CC) /c /Fofcs_dm.obj $(OFLAGS) fcs_dm.c
 

fc-solve/source/ds_order.c

+#include "ds_order.h"
+
+static int random_init_instance(
+    fcs_derived_states_order_t * order,
+    fcs_derived_states_order_instance_t * order_instance,
+    freecell_solver_soft_thread_t * soft_thread,
+    const char * spec_string,
+    const char * * end_of_spec
+    )
+{
+    char * s;
+    order_instance->order = order;
+    order_instance->soft_thread = soft_thread;
+    order_instance->context = NULL;
+    if(*spec_string == '(')
+    {
+        char * s;
+
+        s = spec_string;
+        while ((*s) && (*s != ')'))
+        {
+            s++;
+        }
+        *end_of_spec = s;
+    }
+}
+
+static int random_give_init_state(
+    fcs_derived_states_order_instance_t * order_instance,
+    fcs_state_with_locations_t * init_state
+    )
+{
+    return 0;
+}
+
+static int random_free_instance(
+    fcs_derived_states_order_instance_t * order_instance    
+    )
+{
+    free(order_instance);
+}
+
+static int random_order_states(
+    fcs_derived_states_order_instance_t * order_instance,
+    fcs_state_with_locations_t * src_state,
+    fcs_derived_states_list_t * derived_states,
+    int * rand_array
+    )
+{
+    int a, j;
+    int * ra_ptr;
+    int num_states = derived_states->num_states;
+
+    for(a=0, ra_ptr = rand_array; a < num_states ; a++)
+    {
+        *(ra_ptr++) = a;
+    }
+
+    a = num_states-1;
+    while (a > 0)
+    {
+        j =
+            (
+                freecell_solver_rand_get_random_number(
+                    soft_thread->rand_gen
+                )
+                % (a+1)
+            );
+
+        swap_save = rand_array[a];
+        rand_array[a] = rand_array[j];
+        rand_array[j] = swap_save;
+        a--;
+    }
+
+    return 0;
+}
+
+
+fcs_derived_states_order_t freecell_solver_random_states_order = 
+{
+    /* Name */
+    "random",
+    /* init_instance */
+    random_init_instance,
+    /* give_init_state */
+    random_give_init_state,
+    /* order_states */
+    random_order_states    
+};
+
+fcs_derived_states_order_name_match_t freecell_solver_states_orders_names[FREECELL_SOLVER_NUM_STATES_ORDERS_NAMES] =
+{
+    {
+        "random",
+        freecell_solver_random_states_order
+    },
+};
+
+

fc-solve/source/ds_order.h

 
 struct fcs_derived_states_order_struct
 {
-    char * name;
+    const char * name;
     int (*init_instance)(
         fcs_derived_states_order_t * order,
-        fcs_derived_states_order_instance_t * order_instance,        
+        fcs_derived_states_order_instance_t * order_instance,
         freecell_solver_soft_thread_t * soft_thread,
         char * spec_string,
         char * * end_of_spec
         fcs_derived_states_order_instance_t * order_instance,
         fcs_state_with_locations_t * src_state,
         fcs_derived_states_list_t * derived_states,
-        int * * out_indexes
+        int * out_indexes
         );
 };
 
     void * context;
 };
 
+struct fcs_derived_states_order_name_match_struct
+{
+    const char * name;
+    fcs_derived_states_order_t * order;
+};
+
+typedef struct fcs_derived_states_order_name_match_struct fcs_derived_states_order_name_match_t;
+
+#define FREECELL_SOLVER_NUM_STATES_ORDERS_NAMES 1
+extern fcs_derived_states_order_name_match_t freecell_solver_states_orders_names[FREECELL_SOLVER_NUM_STATES_ORDERS_NAMES];
+
+extern fcs_dervied_states_order_t freecell_solver_random_states_order;
+
 #endif /* #ifndef __DS_ORDER_H */
+
+

fc-solve/source/gen_makefile.pl

 }
 
 my @objects=(
-    qw(alloc app_str caas card cl_chop cmd_line fcs_dm fcs_hash fcs_isa), 
-    qw(freecell intrface lib lookup2 move pqueue preset rand), 
+    qw(alloc app_str caas card cl_chop cmd_line ds_order fcs_dm fcs_hash),
+    qw(fcs_isa freecell intrface lib lookup2 move pqueue preset rand), 
     qw(scans simpsim state tests)
     );
 

fc-solve/source/preset.c

     TEST_TYPE_TEST,
     TEST_TYPE_START_GROUP,
     TEST_TYPE_END_GROUP,
+    TEST_TYPE_SET_ORDER,
     TEST_TYPE_ERROR
 };
 
         {
             ret.type = TEST_TYPE_END_GROUP;
         }
+        else if (*s == '=')
+        {
+            ret.type = TEST_TYPE_SET_ORDER;
+        }
         else
         {
             ret.type = TEST_TYPE_TEST;