Exemplo n.º 1
0
/* Deterministic solver; return 0 on success, else -1 on error.
 */
static
int
deterministic( void )
{
    int i, n;

    rb->yield();

    n = allmoves( );
    while( 0 < n )
    {
        ++pass;
        for( i = 0 ; i < n ; ++i )
            if( -1 == fill( GET_INDEX( possible[ i ] ),
                            GET_DIGIT( possible[ i ] ) ) )
                return -1;
        n = allmoves( );
    }
    return 0;
}
Exemplo n.º 2
0
// Returns 1 if check_mate
// Returns 2 if stale_mate
// Returns 0 if ok
int position::in_check_mate()
{
  int ok = 0;                 // ok flag
  move_list tlist;            // temporary list
  position tpos;              // temporary position

  allmoves(&tlist, &game.ts.tdata[0]);      // find the semi-legal moves

  for(int i = 0; i < tlist.count; i++)
   {  
     tpos = (*this);
     if(tpos.exec_move(tlist.mv[i].m, 0)) { ok = 1; break; }
   }

  if(ok) return 0;                      // ok!
  else {
    if(this->in_check()) return 1;      // check_mate!
    else return 2;                      // stale_mate!
  }

}