rename hyperbola functions to hq

This commit is contained in:
2024-07-06 19:11:56 +02:00
parent 8483ffa101
commit 23051cb427
6 changed files with 41 additions and 43 deletions

View File

@@ -52,11 +52,11 @@ bool sq_is_attacked(const pos_t *pos, const bitboard_t occ, const square_t sq, c
*/
/* bishop / queen */
if (hyperbola_bishop_moves(occ, sq) & (pos->bb[c][BISHOP] | pos->bb[c][QUEEN]))
if (hq_bishop_moves(occ, sq) & (pos->bb[c][BISHOP] | pos->bb[c][QUEEN]))
return true;
/* rook / queen */
if (hyperbola_rook_moves(occ, sq) & (pos->bb[c][ROOK] | pos->bb[c][QUEEN]))
if (hq_rook_moves(occ, sq) & (pos->bb[c][ROOK] | pos->bb[c][QUEEN]))
return true;
/* knight */
@@ -137,7 +137,7 @@ bitboard_t sq_attackers(const pos_t *pos, const bitboard_t occ, const square_t s
/* bishop / queen */
to = pos->bb[c][BISHOP] | pos->bb[c][QUEEN];
tmp = hyperbola_bishop_moves(occ, sq) & to;
tmp = hq_bishop_moves(occ, sq) & to;
attackers |= tmp;
# ifdef DEBUG_ATTACK_ATTACKERS
bb_print("att bishop/queen", tmp);
@@ -145,7 +145,7 @@ bitboard_t sq_attackers(const pos_t *pos, const bitboard_t occ, const square_t s
/* rook / queen */
to = pos->bb[c][ROOK] | pos->bb[c][QUEEN];
tmp = hyperbola_rook_moves(occ, sq) & to;
tmp = hq_rook_moves(occ, sq) & to;
attackers |= tmp;
# ifdef DEBUG_ATTACK_ATTACKERS
bb_print("att rook/queen", tmp);

View File

@@ -95,7 +95,7 @@ void hyperbola_init()
*
* @Return: bitboard of @piece available pseudo-moves.
*/
bitboard_t hyperbola_rank_moves(bitboard_t occ, square_t sq)
bitboard_t hq_rank_moves(bitboard_t occ, square_t sq)
{
u32 rank = sq & SQ_RANKMASK;
u32 file = sq & SQ_FILEMASK;
@@ -122,7 +122,7 @@ bitboard_t hyperbola_rank_moves(bitboard_t occ, square_t sq)
*
* @Return: bitboard of piece available pseudo-moves.
*/
bitboard_t hyperbola_moves(const bitboard_t pieces, const square_t sq,
bitboard_t hq_moves(const bitboard_t pieces, const square_t sq,
const bitboard_t mask)
{
bitboard_t o = pieces & mask;
@@ -141,9 +141,9 @@ bitboard_t hyperbola_moves(const bitboard_t pieces, const square_t sq,
*
* @Return: bitboard of piece available pseudo-moves on its file.
*/
bitboard_t hyperbola_file_moves(const bitboard_t occ, const square_t sq)
bitboard_t hq_file_moves(const bitboard_t occ, const square_t sq)
{
return hyperbola_moves(occ, sq, bb_sqfile[sq]);
return hq_moves(occ, sq, bb_sqfile[sq]);
}
/**
@@ -153,9 +153,9 @@ bitboard_t hyperbola_file_moves(const bitboard_t occ, const square_t sq)
*
* @Return: bitboard of piece available pseudo-moves on its diagonal.
*/
bitboard_t hyperbola_diag_moves(const bitboard_t occ, const square_t sq)
bitboard_t hq_diag_moves(const bitboard_t occ, const square_t sq)
{
return hyperbola_moves(occ, sq, bb_sqdiag[sq]);
return hq_moves(occ, sq, bb_sqdiag[sq]);
}
/**
@@ -165,9 +165,9 @@ bitboard_t hyperbola_diag_moves(const bitboard_t occ, const square_t sq)
*
* @Return: bitboard of piece available pseudo-moves on its anti-diagonal.
*/
bitboard_t hyperbola_anti_moves(const bitboard_t occ, const square_t sq)
bitboard_t hq_anti_moves(const bitboard_t occ, const square_t sq)
{
return hyperbola_moves(occ, sq, bb_sqanti[sq]);
return hq_moves(occ, sq, bb_sqanti[sq]);
}
/**
@@ -177,9 +177,9 @@ bitboard_t hyperbola_anti_moves(const bitboard_t occ, const square_t sq)
*
* @Return: bitboard of bishop available pseudo-moves.
*/
bitboard_t hyperbola_bishop_moves(const bitboard_t occ, const square_t sq)
bitboard_t hq_bishop_moves(const bitboard_t occ, const square_t sq)
{
return hyperbola_diag_moves(occ, sq) | hyperbola_anti_moves(occ, sq);
return hq_diag_moves(occ, sq) | hq_anti_moves(occ, sq);
}
/**
@@ -189,9 +189,9 @@ bitboard_t hyperbola_bishop_moves(const bitboard_t occ, const square_t sq)
*
* @Return: bitboard of rook available pseudo-moves.
*/
bitboard_t hyperbola_rook_moves(const bitboard_t occ, const square_t sq)
bitboard_t hq_rook_moves(const bitboard_t occ, const square_t sq)
{
return hyperbola_file_moves(occ, sq) | hyperbola_rank_moves(occ, sq);
return hq_file_moves(occ, sq) | hq_rank_moves(occ, sq);
}
/**
@@ -204,7 +204,7 @@ bitboard_t hyperbola_rook_moves(const bitboard_t occ, const square_t sq)
*
* @Return: bitboard of queen available pseudo-moves.
*/
bitboard_t hyperbola_queen_moves(const bitboard_t occ, const square_t sq)
bitboard_t hq_queen_moves(const bitboard_t occ, const square_t sq)
{
return hyperbola_bishop_moves(occ, sq) | hyperbola_rook_moves(occ, sq);
return hq_bishop_moves(occ, sq) | hq_rook_moves(occ, sq);
}

View File

@@ -11,23 +11,23 @@
*
*/
#ifndef _HYPERBOLA_QUINTESSENCE_H
#define _HYPERBOLA_QUINTESSENCE_H
#ifndef _HQ_H
#define _HQ_H
#include "board.h"
#include "bitboard.h"
void hyperbola_init(void);
bitboard_t hyperbola_rank_moves(const bitboard_t occ, const square_t sq);
bitboard_t hyperbola_moves(const bitboard_t pieces, const square_t sq,
bitboard_t hq_rank_moves(const bitboard_t occ, const square_t sq);
bitboard_t hq_moves(const bitboard_t pieces, const square_t sq,
const bitboard_t mask);
bitboard_t hyperbola_file_moves(const bitboard_t occ, const square_t sq);
bitboard_t hyperbola_diag_moves(const bitboard_t occ, const square_t sq);
bitboard_t hyperbola_anti_moves(const bitboard_t occ, const square_t sq);
bitboard_t hq_file_moves(const bitboard_t occ, const square_t sq);
bitboard_t hq_diag_moves(const bitboard_t occ, const square_t sq);
bitboard_t hq_anti_moves(const bitboard_t occ, const square_t sq);
bitboard_t hyperbola_bishop_moves(const bitboard_t occ, const square_t sq);
bitboard_t hyperbola_rook_moves(const bitboard_t occ, const square_t sq);
bitboard_t hyperbola_queen_moves(const bitboard_t occ, const square_t sq);
bitboard_t hq_bishop_moves(const bitboard_t occ, const square_t sq);
bitboard_t hq_rook_moves(const bitboard_t occ, const square_t sq);
bitboard_t hq_queen_moves(const bitboard_t occ, const square_t sq);
#endif /* _HYPERBOLA_QUINTESSENCE_H */
#endif /* _HQ_H */

View File

@@ -99,7 +99,7 @@ bool pseudo_is_legal(const pos_t *pos, const move_t move)
bitboard_t exclude = BIT(ep + sq_up(them)) | BIT(from);
bitboard_t rooks = (pos->bb[them][ROOK] | pos->bb[them][QUEEN]) & rank5;
return !(hyperbola_rank_moves(occ ^ exclude, kingsq) & rooks);
return !(hq_rank_moves(occ ^ exclude, kingsq) & rooks);
}
}
return true;
@@ -394,13 +394,13 @@ movelist_t *pos_gen_pseudo(pos_t *pos, movelist_t *movelist)
from_bb = pos->bb[us][BISHOP] | pos->bb[us][QUEEN];
while (from_bb) {
from = bb_next(&from_bb);
to_bb = hyperbola_bishop_moves(occ, from) & dest_squares;
to_bb = hq_bishop_moves(occ, from) & dest_squares;
moves = moves_gen(moves, from, to_bb);
}
from_bb = pos->bb[us][ROOK] | pos->bb[us][QUEEN];
while (from_bb) {
from = bb_next(&from_bb);
to_bb = hyperbola_rook_moves(occ, from) & dest_squares;
to_bb = hq_rook_moves(occ, from) & dest_squares;
moves = moves_gen(moves, from, to_bb);
}

View File

@@ -152,15 +152,13 @@ move_t move_from_str(const char *str)
/**
* move_find_in_movelist() - find a partial move in movelist.
* @target: partial move
* @list: &movelist_t to search
* @move: move (may be partial)
* @movelist: &movelist_t to search
*
* Look for @target into @list. @target must at least contain from and
* to square, as well as promotion information - see move_from_str().
* If these three pieces of information match, the corresponding move in
* @list is returned.
* Look for @target into @list, by comparing its from, to, and promotion
* information.
*
* @return: move, or MOVE_NONE if error.
* @return: move in @movelist if match found, MOVE_NONE otherwise.
*/
move_t move_find_in_movelist(move_t target, movelist_t *list)
{

View File

@@ -218,7 +218,7 @@ void pos_set_checkers_pinners_blockers(pos_t *pos)
attackers = pos->bb[them][BISHOP] | pos->bb[them][QUEEN];
/* targets is all "target" pieces if K was a bishop */
targets = hyperbola_bishop_moves(occ, king) & occ;
targets = hq_bishop_moves(occ, king) & occ;
/* checkers = only opponent B/Q */
tmpcheckers = targets & attackers;
@@ -229,7 +229,7 @@ void pos_set_checkers_pinners_blockers(pos_t *pos)
/* we find second targets, by removing first ones (excl. checkers) */
if (maybeblockers) {
targets = hyperbola_bishop_moves(occ ^ maybeblockers, king) ^ tmpcheckers;
targets = hq_bishop_moves(occ ^ maybeblockers, king) ^ tmpcheckers;
/* pinners = only B/Q */
tmppinners = targets & attackers;
@@ -244,14 +244,14 @@ void pos_set_checkers_pinners_blockers(pos_t *pos)
/* same for rook type */
attackers = pos->bb[them][ROOK] | pos->bb[them][QUEEN];
targets = hyperbola_rook_moves(occ, king) & occ;
targets = hq_rook_moves(occ, king) & occ;
tmpcheckers = targets & attackers;
checkers |= tmpcheckers;
maybeblockers = targets & ~tmpcheckers;
if (maybeblockers) {
targets = hyperbola_rook_moves(occ ^ maybeblockers, king) ^ tmpcheckers;
targets = hq_rook_moves(occ ^ maybeblockers, king) ^ tmpcheckers;
tmppinners = targets & attackers;
while (tmppinners) {
pinner = bb_next(&tmppinners);