/* 08_material_count.c -- material counting (and a note on evaluation).
 *
 * Functions demonstrated:
 *   SANSetMaterial() -- recompute cpmv[c_w]/cpmv[c_b], the total
 *                       piece value currently on the board for each
 *                       color (pawn=100, knight/bishop=300, rook=500,
 *                       queen=900 in this codebase's units; see
 *                       val_p/val_n/... in sandef.h)
 *   SANPosEval()      -- "positional factors" evaluation
 *
 * Honesty note: SANPosEval() is a stub in the original 1994 SAN Kit
 * source (sanpos.c literally says "routine under construction" and
 * always returns 0). Material counting via SANSetMaterial()/cpmv[]
 * is the only scoring the stock kit actually provides; a real
 * strategy module (see examples/13 and demos/xboard-engine) would
 * normally combine material with its own positional evaluation.
 */

#include "_common.h"

#include "sanint.h"
#include "sanmsc.h"
#include "sanpos.h"
#include "sanfen.h"

int
main (void)
{
  SANInit ();

  SANFENSet ("r1bqkbnr/pppp1ppp/2n5/4p3/4P3/5N2/PPPP1PPP/RNBQKB1R w KQkq - 2 3");

  SANSetMaterial ();
  printf ("Position: %s\n", SANFENGen ());
  printf ("White material: %ld\n", (long) cpmv[c_w]);
  printf ("Black material: %ld\n", (long) cpmv[c_b]);

  printf ("SANPosEval(): %ld (always 0 -- unimplemented in this kit)\n",
          (long) SANPosEval ());

  return (0);
}
