twistturns

generates dot files of the graph of all reachable states in a Top Spin puzzle
git clone https://wehaveforgeathome.hates.computer/twistturns.git
Log | Files | Refs | LICENSE

utils.h (1250B)


      1 /**
      2 * utils.h : "header" (i.e. API interface) for utils.c code.
      3 *
      4 * adapted from http://cs/courses/fall2008/algorithms/code/c_examples/multiple_files/some_func.h
      5 **/
      6 
      7 #include "primes.h"
      8 #include "perm_gen.h"
      9 
     10 // c seems to want all the definitions, so here they are agian
     11 // DEFINTIONS
     12 // type definitions used later
     13 typedef struct advance_node_type *advance_node;
     14 typedef struct state_type *state;
     15 
     16 // since the number of times you can advance the tiles is variable,
     17 // links to the states that result from those changes will go into an
     18 // array
     19 struct advance_node_type {
     20 	int steps; // how far to advance
     21 	state leads_to; // what state you enter after making that move
     22 	advance_node next;
     23 };
     24 
     25 // 
     26 struct state_type {
     27 	link board;
     28 	state next;
     29 	state rotate;
     30 	advance_node advances;
     31 };
     32 
     33 /***
     34 *
     35 * API
     36 *
     37 ***/
     38 
     39 // build_universe
     40 // generates the "universe" of a game of twistturns
     41 // (each of the possible board states, and the links between them)
     42 // usage: state built_universe(the number of tiles in the game, the diameter of the wheel);
     43 state build_universe(int n, int d);
     44 
     45 // print_states_dot
     46 // prints out the relationships between each state in a universe in dot format
     47 // usage: print_states_dot(universe);
     48 int print_states_dot(state states);