Commits

Shlomi Fish  committed 23be47c

Convert Stack to soft_thread->to_stack.

  • Participants
  • Parent commits 8d01408
  • Branches make-code-suitable-for-fc-solve

Comments (0)

Files changed (5)

File patsolve/pat.c

 			win(soft_thread, pos);
 
 			if (soft_thread->Noexit) {
-				Numsol++;
+				soft_thread->num_solutions++;
 				return NULL;
 			}
 			Status = WIN;

File patsolve/pat.h

 /* Command line flags. */
 
 extern int Cutoff;
-extern int Numsol;
-extern int Stack;
 extern int Quiet;
 
 enum statuscode { FAIL = -1, WIN = 0, NOSOL = 1 };
     int Treebytes;
     int Interactive; /* interactive mode. */
     int Noexit;     /* -E means don't exit */
+    int num_solutions;             /* number of solutions found in -E mode */
+    /* -S means stack, not queue, the moves to be done.
+     * Default should be FALSE.
+     * */
+    int to_stack;      
 };
 
 typedef struct fc_solve_soft_thread_struct fc_solve_soft_thread_t;

File patsolve/patmain.c

   "-s implies -aw10 -t4, -f implies -aw8 -t4\n";
 #define USAGE() fc_solve_msg(Usage, Progname)
 
-int Numsol;             /* number of solutions found in -E mode */
-int Stack = FALSE;      /* -S means stack, not queue, the moves to be done */
 int Cutoff = 1;         /* switch between depth- and breadth-first */
 int Status;             /* win, lose, or fail */
 int Quiet = FALSE;      /* print entertaining messages, else exit(Status); */
 
     soft_thread->Interactive = TRUE;
     soft_thread->Noexit = FALSE;
+    soft_thread->to_stack = FALSE;
     soft_thread->Mem_remain = (50 * 1000 * 1000);
     soft_thread->Freepos = NULL;
     /* Default variation. */
 				break;
 
 			case 'S':
-				Stack = TRUE;
+				soft_thread->to_stack = TRUE;
 				break;
 
 			case 'w':
 
 	/* Set parameters. */
 
-	if (!soft_thread_struct.Same_suit && !soft_thread_struct.King_only && !Stack) {
+	if (!soft_thread_struct.Same_suit && !soft_thread_struct.King_only && !soft_thread->to_stack) {
 		set_param(soft_thread, FreecellBest);
-	} else if (!soft_thread_struct.Same_suit && !soft_thread_struct.King_only && Stack) {
+	} else if (!soft_thread_struct.Same_suit && !soft_thread_struct.King_only && soft_thread->to_stack) {
 		set_param(soft_thread, FreecellSpeed);
-	} else if (soft_thread_struct.Same_suit && !soft_thread_struct.King_only && !Stack) {
+	} else if (soft_thread_struct.Same_suit && !soft_thread_struct.King_only && !soft_thread->to_stack) {
 		set_param(soft_thread, SeahavenBest);
-	} else if (soft_thread_struct.Same_suit && !soft_thread_struct.King_only && Stack) {
+	} else if (soft_thread_struct.Same_suit && !soft_thread_struct.King_only && soft_thread->to_stack) {
 		set_param(soft_thread, SeahavenSpeed);
-	} else if (soft_thread_struct.Same_suit && soft_thread_struct.King_only && !Stack) {
+	} else if (soft_thread_struct.Same_suit && soft_thread_struct.King_only && !soft_thread->to_stack) {
 		set_param(soft_thread, SeahavenKing);
-	} else if (soft_thread_struct.Same_suit && soft_thread_struct.King_only && Stack) {
+	} else if (soft_thread_struct.Same_suit && soft_thread_struct.King_only && soft_thread->to_stack) {
 		set_param(soft_thread, SeahavenKingSpeed);
 	} else {
 		set_param(soft_thread, 0);   /* default */
 		}
 	}
 
-	if (Stack && soft_thread->Noexit) {
+	if (soft_thread->to_stack && soft_thread->Noexit) {
 		fatalerr("-S and -E may not be used together.");
 	}
 	if (soft_thread->Mem_remain < BLOCKSIZE * 2) {
 
 	soft_thread->Total_positions = 0;
 	soft_thread->Total_generated = 0;
-	Numsol = 0;
+	soft_thread->num_solutions = 0;
 
 	Status = NOSOL;
 
 	if (Status != WIN && !Quiet) {
 		if (Status == FAIL) {
 			printf("Out of memory.\n");
-		} else if (soft_thread->Noexit && Numsol > 0) {
+		} else if (soft_thread->Noexit && soft_thread->num_solutions > 0) {
 			printf("No shorter solutions.\n");
 		} else {
 			printf("No solution.\n");

File patsolve/patsolve.c

 		soft_thread->Qhead[pri] = pos;
 		soft_thread->Qtail[pri] = pos;
 	} else {
-		if (Stack) {
+		if (soft_thread->to_stack) {
 			pos->queue = soft_thread->Qhead[pri];
 			soft_thread->Qhead[pri] = pos;
 		} else {

File patsolve/tree.c

 	so we can prune the original path. */
 
 	c = FOUND;
-	if (d < t->depth && !Stack) {
+	if (d < t->depth && !soft_thread->to_stack) {
 		t->depth = d;
 		c = FOUND_BETTER;
 		*node = t;