/*>>> sanenu.c: SAN project position subtree enumeration */

/* Revised: 1993.04.11 */

#include <stdio.h>

#include "sandef.h"
#include "sanvar.h"

#include "sandsp.h"
#include "sanenu.h"
#include "sangen.h"
#include "sanmer.h"

/*--> SANEnumerate: enumerate subtree nodes */
nonstatic
liT
SANEnumerate (siT depth)
{
  liT count, msum;
  siT i, next;
  mptrT mptr;
  mT m;

  count = 0;

  if (an == 0)
    SANGenMoves ();
  else
    SANGenFullPL ();

  next = depth - 1;
  curr_g.g_curr = curr_g.g_base;

  for (i = 0; i < curr_g.g_gmvc; i++)
    {
      mptr = curr_g.g_curr;
      m = *mptr;
      SANExecute ();
      if (mptr->m_flag & mf_bust)
	msum = 0;
      else
	{
	  if (next == 0)
	    msum = 1;
	  else
	    msum = SANEnumerate (next);
	  if (an == 1)
	    {
	      SANDspSANTB (mptr);
	      SANDspStrLINL (": ", msum);
	    };
	  fflush (stdout);
	};
      SANRetract ();
      curr_g.g_curr++;
      count += msum;
    };

  return (count);
}

/*<<< sanenu.c: EOF */
