GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Chess Programming Wiki
  • All pages
  • Other namespaces
  • Categories
  • Credits

This view

  • Original page
  • New address

GeezerVison is showing chessprogramming.org — CPW-Engine recognize - Chess Programming Wiki

CPW-Engine recognize

Home * Engines * CPW-Engine * Recognizer

#include "stdafx.h"

int is_rim[64] = {
  1,   1,   1,   1,   1,   1,   1,   1,
  1,   0,   0,   0,   0,   0,   0,   1,
  1,   0,   0,   0,   0,   0,   0,   1,
  1,   0,   0,   0,   0,   0,   0,   1,
  1,   0,   0,   0,   0,   0,   0,   1,
  1,   0,   0,   0,   0,   0,   0,   1,
  1,   0,   0,   0,   0,   0,   0,   1,
  1,   1,   1,   1,   1,   1,   1,   1
};

/* please note that this recognizer assumes that the position is legal,
i.e. side to move is not in check */

int isDraw() {

  /* no pawns */
  if (!b.PawnMaterial[WHITE] && !b.PawnMaterial[BLACK]) {

    /* both sides have at most one minor piece - to guard against the possibility
    of a helpmate in the corner, we do not claim an immediate draw if the king
    of the weaker side stands on the edge of the board */

    if (b.PieceMaterial[WHITE] < 400 &&
      b.PieceMaterial[BLACK] < 400 &&
      (!is_rim[b.KingLoc[WHITE]] || b.PieceMaterial[BLACK] == 0) &&
      (!is_rim[b.KingLoc[BLACK]] || b.PieceMaterial[WHITE] == 0)
      )
      return 1;

  }

  /* default: no draw spotted */
  return 0;
}

Up one Level

What links here

Contributors: GerdIsenberg.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.