Commits

Shlomi Fish committed c80a12c

Less magic numbers.

  • Participants
  • Parent commits 2a26fd4

Comments (0)

Files changed (1)

black-hole-solitaire/c-solver/black_hole_solver.c

 #include "alloc.h"
 #include "rank_reach_prune.h"
 
+#define NUM_SUITS 4
 enum BHS_SUITS
 {
     SUIT_H,
     return BLACK_HOLE_SOLVER__SUCCESS;
 }
 
+#define NUM_STATES_INCREMENT 16
+
 static void initialize_states_in_solution(bhs_solver_t * solver)
 {
     if (! solver->states_in_solution)
         int i, num_states, max_num_states;
 
         num_states = 0;
-        max_num_states = 53;
+        max_num_states = NUM_SUITS * NUM_RANKS + 1;
 
         states = malloc(sizeof(states[0]) * max_num_states);
 
                 states =
                     realloc(
                         states,
-                        sizeof(states[0]) * (max_num_states += 16)
+                        sizeof(states[0]) * (max_num_states += NUM_STATES_INCREMENT)
                     );
             }
 
 
     ret = malloc(
         /* 3 bytes per card. */
-        (3 * 4 * 13)
+        (3 * NUM_SUITS * NUM_RANKS)
             +
         /* newline and a leading ":" per column */
         (2 * BHS__MAX_NUM_COLUMNS)