Ejemplo n.º 1
0
static void note_quiet_moves(list_t * list, const board_t * board, bool in_pv, int ThreadId) {

   int size;
   int i, move;
   int move_piece;

   ASSERT(list_is_ok(list));
   ASSERT(board!=NULL);

   size = LIST_SIZE(list);

   if (size >= 2) {
      for (i = 0; i < size; i++) {
         move = LIST_MOVE(list,i);
         list->value[i] = quiet_move_value(move,board,ThreadId);
         if (TryQuietKingAttacks && in_pv) {
            move_piece = MOVE_PIECE(move,board);
            if (!(PIECE_IS_PAWN(move_piece) || PIECE_IS_KING(move_piece))) {
               if (narrow_piece_attack_king(board,move_piece,MOVE_TO(move),KING_POS(board,COLOUR_OPP(board->turn)))) {
                  if (see_move(move,board) >= 0) {
//                   if (1 == NumberThreadsInternal) print_board(board);
                     list->value[i] += 16;
                  }
               }
            }
         }
      }
   }
}
Ejemplo n.º 2
0
static bool capture_is_dangerous(int move, const board_t * board) {

   int piece, capture;

   ASSERT(move_is_ok(move));
   ASSERT(board!=NULL);

   ASSERT(move_is_tactical(move,board));

   piece = MOVE_PIECE(move,board);

   if (PIECE_IS_PAWN(piece)
    && PAWN_RANK(MOVE_TO(move),board->turn) >= Rank7) {
      return true;
   }

   capture = move_capture(move,board);

   if (PIECE_IS_QUEEN(capture)) return true;

   if (PIECE_IS_PAWN(capture)
    && PAWN_RANK(MOVE_TO(move),board->turn) <= Rank2) {
      return true;
   }

   return false;
}
Ejemplo n.º 3
0
static int full_new_depth(int depth, int move, board_t * board, bool single_reply, bool mate_threat, bool in_pv, int height) {

   int new_depth;

   ASSERT(depth_is_ok(depth));
   ASSERT(move_is_ok(move));
   ASSERT(board!=NULL);
   ASSERT(single_reply==true||single_reply==false);
   ASSERT(in_pv==true||in_pv==false);

   ASSERT(depth>0);

   new_depth = depth - 1;
   
   if (in_pv && board->square[MOVE_TO(move)] != Empty && !PIECE_IS_PAWN(board->square[MOVE_TO(move)])){
	   if ((board->piece_size[White] + board->piece_size[Black]) == 3){
			return new_depth+1;
	   }
	   else if ((board->piece_size[White] == 3 && board->piece_size[Black] == 2) 
		   || (board->piece_size[White] == 2 && board->piece_size[Black] == 3))
		   return new_depth+1; 
   }
   //else{ 
		if ((single_reply && ExtendSingleReply)
			|| (in_pv && MOVE_TO(move) == board->cap_sq // recapture
		/*		&& (see_move(move,board) > 0 || ABS(VALUE_PIECE(board->square[MOVE_TO(move)])-VALUE_PIECE(board->square[MOVE_FROM(move)])) <= 250 ) */)  
			|| (in_pv && PIECE_IS_PAWN(MOVE_PIECE(move,board))
				  && (PAWN_RANK(MOVE_TO(move),board->turn) == Rank7 || PAWN_RANK(MOVE_TO(move),board->turn) == Rank6)
				  /* && see_move(move,board) >= 0 */)
			|| (in_pv &&  board->square[MOVE_TO(move)] != PieceNone256 && SearchCurrent->max_extensions-height >= 6) 
			//|| (in_pv &&  depth <= 1 && height <= SearchCurrent->max_extensions)
			//|| (in_pv && mate_threat == true)
			|| move_is_check(move,board)) {
			return new_depth+1;
		}
	//	else{
			if (in_pv && PIECE_IS_PAWN(MOVE_PIECE(move,board))){
				if (passed_pawn_move(move,board))
					return new_depth+1;
			}
	//	}
//   }
  
   ASSERT(new_depth>=0&&new_depth<=depth);

   return new_depth;
}
Ejemplo n.º 4
0
static int full_new_depth(int depth, int move, board_t * board, bool single_reply, bool in_pv, int height, bool extended, bool * cap_extended, int ThreadId) {

   int new_depth;

   ASSERT(depth_is_ok(depth));
   ASSERT(move_is_ok(move));
   ASSERT(board!=NULL);
   ASSERT(single_reply==true||single_reply==false);
   ASSERT(in_pv==true||in_pv==false);

   ASSERT(depth>0);

   new_depth = depth - 1;
   *cap_extended = false;
   
   if (in_pv && board->square[MOVE_TO(move)] != Empty && !PIECE_IS_PAWN(board->square[MOVE_TO(move)])){
	   if ((board->piece_size[White] + board->piece_size[Black]) == 3){
			return new_depth+1;
	   }
	   else if ((board->piece_size[White] == 3 && board->piece_size[Black] == 2) 
		   || (board->piece_size[White] == 2 && board->piece_size[Black] == 3))
		   return new_depth+1; 
   }
   if ((single_reply && ExtendSingleReply)
		//|| (in_pv && MOVE_TO(move) == board->cap_sq // recapture
		//	&& see_move(move,board) >= -100 /*|| ABS(VALUE_PIECE(board->square[MOVE_TO(move)])-VALUE_PIECE(board->square[MOVE_FROM(move)])) <= 250 )*/)  
		//|| (in_pv && PIECE_IS_PAWN(MOVE_PIECE(move,board))
		//	  && (PAWN_RANK(MOVE_TO(move),board->turn) == Rank7 || PAWN_RANK(MOVE_TO(move),board->turn) == Rank6))
		//|| (in_pv &&  board->square[MOVE_TO(move)] != PieceNone256 && SearchCurrent[ThreadId]->act_iteration-height >= 6 && see_move(move,board) >= -100) 
		//|| (in_pv &&  board->square[MOVE_TO(move)] != PieceNone256 && !extended && see_move(move,board) >= -100)
		//|| (in_pv && mate_threat == true)
		|| move_is_check(move,board) && (in_pv || see_move(move,board) >= -100)) {
        // @tried no check extension in endgame (~ -5 elo)
        // @tried no bad SEE check extension in PV (~ -5 elo)
		return new_depth+1;
   }
   if (in_pv && PIECE_IS_PAWN(MOVE_PIECE(move,board))){
			if (is_passed(board,MOVE_TO(move)))
				return new_depth+1;
   }

  if (in_pv &&  board->square[MOVE_TO(move)] != PieceNone256 
	   && !extended && see_move(move,board) >= -100){
		   *cap_extended = true;
		   return new_depth+1;
   }
  
   ASSERT(new_depth>=0&&new_depth<=depth);

   return new_depth;
}
Ejemplo n.º 5
0
int see(Move_t move, Board_t *board) {
    Board_t temp_board = *global_board();
    Board_t *ptr = &temp_board;
    
    int attacking_piece = MOVE_PIECE(move);
    int captured_piece;
    int gain[32];
    int depth = 0;
    int from = MOVE_FROM(move);
    int to = MOVE_TO(move);
    
    if (ENEMY_PAWNS(ptr) & SQ_MASK(to))
        captured_piece = PAWN;
    else if (ENEMY_KNIGHTS(ptr) & SQ_MASK(to))
        captured_piece = KNIGHT;
    else if (ENEMY_BISHOPS(ptr) & SQ_MASK(to))
        captured_piece = BISHOP;
    else if (ENEMY_ROOKS(ptr) & SQ_MASK(to))
        captured_piece = ROOK;
    else if (ENEMY_QUEENS(ptr) & SQ_MASK(to))
        captured_piece = QUEEN;
    else
        captured_piece = 0;
        
    gain[0] = Piece_Values[captured_piece];
    
    if (MOVE_IS_EN_PASSANT(move))
        gain[0] = Piece_Values[PAWN];
    
    do {
        make_quick_move_on_board(ptr, from, to, captured_piece, attacking_piece);
        
        captured_piece = attacking_piece;
        depth++;
        gain[depth] = Piece_Values[captured_piece] - gain[depth-1];
        
        if (MAX(-gain[depth-1], gain[depth]) < 0)
            break;
        
        attacking_piece = get_least_valuable_attacker(ptr, to, &from);
        
    } while (attacking_piece);
    
    while (--depth)
        gain[depth-1] = -MAX(-gain[depth-1], gain[depth]);
    
    return gain[0];
}
Ejemplo n.º 6
0
static bool move_is_dangerous(int move, const board_t * board) {

   int piece;

   ASSERT(move_is_ok(move));
   ASSERT(board!=NULL);

   ASSERT(!move_is_tactical(move,board));

   piece = MOVE_PIECE(move,board);

   if (PIECE_IS_PAWN(piece)
    && is_passed(board,MOVE_TO(move)) /*PAWN_RANK(MOVE_TO(move),board->turn) >= Rank7*/) {
      return true;
   }

   return false;
}