/* 13_search_strategies.c -- picking and using a move-selection strategy.
 *
 * Functions/globals demonstrated:
 *   ssv[c_w], ssv[c_b] -- which strategy (ssT) is active for each color
 *   SANSelect()        -- ask the active strategy to choose a move for
 *                         the side to move, storing it in select_m
 *   SANPlayMove(&select_m) -- play the chosen move
 *
 * The SAN Kit ships five example strategies (see sansss.c):
 *   ss_eat  "eat"  best simple capture (falls back to a plausible move)
 *   ss_gtp  "gtp"  Gillogly TECH program
 *   ss_ran  "ran"  purely random legal move
 *   ss_sc0  "sc0"  Stanback Chess Program, internal variant
 *   ss_sc1  "sc1"  Stanback Chess Program, external variant
 *
 * None of them is a strong engine (see demos/xboard-engine for a
 * small, playable wrapper around them); they exist mainly as worked
 * examples for people plugging in their own strategy.
 */

#include "_common.h"

#include "sanint.h"
#include "sansel.h"
#include "sanmpu.h"
#include "sanmne.h"
#include "sanfen.h"

int
main (void)
{
  siT i;
  sanT san;

  SANInit ();
  optnv[optn_nabd] = 1;
  optnv[optn_namd] = 1;

  /* let the "eat" strategy (its own default) play White, and the
     "random" strategy play Black */
  ssv[c_w] = ss_eat;
  ssv[c_b] = ss_ran;

  printf ("White: %s   Black: %s\n\n", ssstrv[ssv[c_w]], ssstrv[ssv[c_b]]);

  for (i = 0; i < 10; i++)
    {
      SANSelect ();                 /* fills in the global select_m */
      SANEncode (&select_m, san);   /* look at it before playing it */
      SANPlayMove (&select_m);      /* commit to it */
      printf ("%2d. %-8s (chosen by %s)\n", i + 1, san,
              ssstrv[ssv[curr_e.e_pasc]]);
    };

  printf ("\nFinal position: %s\n", SANFENGen ());

  return (0);
}
