/* 07_perft_enumerate.c -- counting move-tree leaves ("perft").
 *
 * Function demonstrated:
 *   SANEnumerate(depth) -- recursively play out every legal move to
 *                          the given depth and return the total leaf
 *                          count (the classic chess-programming
 *                          "perft" exercise, useful for validating a
 *                          move generator against known-correct
 *                          counts).
 *
 * Note: when called at the top level, SANEnumerate() also prints a
 * "divide"-style breakdown (one line per root move, with that move's
 * own subtree leaf count) directly to stdout as a side effect -- this
 * is the library's own behavior, not something this example adds.
 * See demos/perft for a small command-line tool built around this.
 */

#include "_common.h"

#include "sanint.h"
#include "sanenu.h"

int
main (void)
{
  siT depth;

  SANInit ();

  for (depth = 1; depth <= 4; depth++)
    {
      printf ("--- perft(%d) ---\n", depth);
      printf ("Nodes: %ld\n\n", SANEnumerate (depth));
    };

  /* known-correct perft(4) from the initial position is 197281;
     this is the standard first sanity check for any move generator */

  return (0);
}
