Exemple #1
0
static int
setup_moves(struct node *node)
{
	move_order_setup(node->mo, node->pos,
	    is_qsearch(node), node->root_distance % 2);

	if (node->mo->count == 0) {
		if (is_qsearch(node))
			node->value = node->lower_bound;  // leaf node
		else if (is_in_check(node->pos)) {
			node->value = -max_value;  // checkmate
		}
		else {
			node->value = 0;   // stalemate
		}
		return no_legal_moves;
	}

	bool moving_piece[PIECE_ARRAY_SIZE] = {0};

	for (unsigned i = 0; i < node->mo->count; ++i) {
		enum piece p = mresultp(node->mo->moves[i]);
		if (p != pawn) {
			node->non_pawn_move_count++;
			if (!moving_piece[p]) {
				node->non_pawn_move_piece_count++;
				moving_piece[p] = true;
			}
		}
	}

	return 0;
}
Exemple #2
0
static char*
print_san_promotion(move m, char *str)
{
	if (is_promotion(m)) {
		*str++ = '=';
		*str++ = toupper((unsigned char)piece_to_char(mresultp(m)));
	}
	return str;
}
Exemple #3
0
static bool
pmove_match(uint16_t polyglot_move, move m, bool flip)
{
	if (flip)
		m = flip_m(m);
	if (pmfrom(polyglot_move) != mfrom(m)
	    || pmto(polyglot_move) != mto(m))
		return false;
	if (is_promotion(m))
		return pmpromotion(polyglot_move) == mresultp(m);
	else
		return pmpromotion(polyglot_move) == 0;
}