Example #1
0
t_bool game_isattacked(t_game* me, t_square square, t_color attacker)
{
    t_board* p_board = &(me->board);
    t_bitboard attack_bb;

	/* Pawns */
	attack_bb = pawn_caps_bbs[COLOR_FLIP(attacker)][square];
	if (attack_bb & p_board->piece_bbs[PAWN] & p_board->color_bbs[attacker])
    {
        return TRUE;
    }
	
    /* Knights */
	attack_bb = knight_move_bbs[square];
	if (attack_bb & p_board->piece_bbs[KNIGHT] & p_board->color_bbs[attacker])
    {
        return TRUE;
    }
	
    /* Kings */
	attack_bb = king_move_bbs[square];
	if (attack_bb & p_board->piece_bbs[KING] & p_board->color_bbs[attacker])
    {
        return TRUE;
    }
	
    /* Bishop sliders */
	attack_bb = bb_get_attack(p_board, BISHOP, square);
	if (attack_bb & (p_board->piece_bbs[BISHOP] | p_board->piece_bbs[QUEEN]) & p_board->color_bbs[attacker])
    {
        return TRUE;
    }

	/* Rook sliders */
	attack_bb = bb_get_attack(p_board, ROOK, square);
	if (attack_bb & (p_board->piece_bbs[ROOK] | p_board->piece_bbs[QUEEN]) & p_board->color_bbs[attacker])
    {
		return TRUE;
    }

	return FALSE;
}
Example #2
0
/**
extend_node():
Calculate a new depth for this node, based on extensions, reductions, and any
possible pruning. This is done after eval, null move, and IID, so we have
some information to go on.
Created 081808; last modified 081808
**/
void extend_node(SEARCH_BLOCK *sb)
{
#if 0
	COLOR color;
	EVAL_BLOCK *old_eval;
	EVAL_BLOCK *new_eval;
	VALUE ks_delta[2];
	VALUE pp_delta[2];
	VALUE eval_delta[2];
	BOOL ks_def_good;
	BOOL ks_att_good;
	BOOL ks_good;
	BOOL pp_def_good;
	BOOL pp_att_good;
	BOOL pp_good;
	BOOL eval_own_good;
	BOOL eval_opp_good;
	BOOL eval_good;

	old_eval = &(sb - 1)->eval_block;
	new_eval = &sb->eval_block;

	for (color = WHITE; color <= BLACK; color++)
	{
		ks_delta[color] = new_eval->king_safety[color] -
			old_eval->king_safety[color];
		pp_delta[color] = new_eval->passed_pawn[color] -
			old_eval->passed_pawn[color];
		eval_delta[color] = -new_eval->eval[color] - old_eval->eval[color];
	}

	/* Take the values of the side not-to-move, as they just finished making
		a move. We look at the difference in eval caused by that move. */
	color = board.side_ntm;

	/* King Safety */
	ks_def_good = (ks_delta[color] > 10);
	ks_att_good = (ks_delta[COLOR_FLIP(color)] < 10);
	ks_good = (ks_delta[color] - ks_delta[COLOR_FLIP(color)] > -10);

	pp_def_good = (pp_delta[color] > 10);
	pp_att_good = (pp_delta[COLOR_FLIP(color)] < 10);
	pp_good = (pp_delta[color] - pp_delta[COLOR_FLIP(color)] > -10);

	eval_own_good = (eval_delta[color] > 0);
	eval_opp_good = (eval_delta[COLOR_FLIP(color)] < 0);
	eval_good = (eval_delta[color] - eval_delta[COLOR_FLIP(color)] > 0);

	/* If the last move wasn't reduced normally, try to reduce it now
		based on evaluation factors. */
	if (!((sb - 1)->move & MOVE_ISREDUCED) && //!(sb->move & MOVE_NOREDUCE) &&
	/*	!ks_att_good && */!ks_good &&
	/*	!pp_att_good &&*/ !pp_good &&
		!eval_good)
	{
		sb->depth -= PLY;
//		sb->move |= MOVE_ISREDUCED;
	}

	/* Extend the node by dynamic null-move-based threat detection. */
	if (sb->threat)
	{
		sb->depth += zct->threat_extension;
		zct->threat_extensions_done++;
	}
	/* XXX what to do now? Ideas:
		--"refuting" lmr based on eval
		--make null move AZW for cutoff vs. really bad
		--threat move, null move score, iid score? -> double check pruning
		--extension for moves that increase one term a lot
		--extension for uncertain moves, that increase one and
			decrease another
		--reductions based on this stuff
		--intelligent move sorting based on evaluation bitboard:
			mark squares in front of passed pawns, near king, maybe
			good squares. Bad square bitboard too?
		--make new file for selectivity stuff like this, extend_move, etc.
		--change this function to allow pruning and dropping into qsearch
	*/
#endif
}
Example #3
0
void game_set_stm(t_game* me, t_color color)
{
    me->side_tm = color;
    me->side_ntm = COLOR_FLIP(color);
}