loopgen.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536
  1. /*
  2. * loopgen.h: interface file for loop generation functions for grid.[ch].
  3. */
  4. #ifndef PUZZLES_LOOPGEN_H
  5. #define PUZZLES_LOOPGEN_H
  6. #include "puzzles.h"
  7. #include "grid.h"
  8. enum face_colour { FACE_WHITE, FACE_GREY, FACE_BLACK };
  9. /* face should be of type grid_face* here. */
  10. #define FACE_COLOUR(face) \
  11. ( (face) == NULL ? FACE_BLACK : \
  12. board[(face)->index] )
  13. typedef int (*loopgen_bias_fn_t)(void *ctx, char *board, int face);
  14. /* 'board' should be a char array whose length is the same as
  15. * g->num_faces: this will be filled in with FACE_WHITE or FACE_BLACK
  16. * after loop generation.
  17. *
  18. * If 'bias' is non-null, it should be a user-provided function which
  19. * rates a half-finished board (i.e. may include some FACE_GREYs) for
  20. * desirability; this will cause the loop generator to bias in favour
  21. * of loops with a high return value from that function. The 'face'
  22. * parameter to the bias function indicates which face of the grid has
  23. * been modified since the last call; it is guaranteed that only one
  24. * will have been (so that bias functions can work incrementally
  25. * rather than re-scanning the whole grid on every call). */
  26. extern void generate_loop(grid *g, char *board, random_state *rs,
  27. loopgen_bias_fn_t bias, void *biasctx);
  28. #endif