remove MOVE_NO_MOVE (use only MOVE_NONE)

This commit is contained in:
2024-06-28 11:43:52 +02:00
parent b4f008b223
commit b8f0f6a120
3 changed files with 19 additions and 60 deletions

View File

@@ -398,9 +398,9 @@ TEST += movedo-test perft-test tt-test
PIECE_OBJS := piece.o PIECE_OBJS := piece.o
FEN_OBJS := $(PIECE_OBJS) fen.o position.o bitboard.o board.o \ FEN_OBJS := $(PIECE_OBJS) fen.o position.o bitboard.o board.o \
hyperbola-quintessence.o attack.o hash.o init.o misc.o hyperbola-quintessence.o attack.o hash.o init.o misc.o move.o
BB_OBJS := $(FEN_OBJS) BB_OBJS := $(FEN_OBJS)
MOVEGEN_OBJS := $(BB_OBJS) move.o move-gen.o MOVEGEN_OBJS := $(BB_OBJS) move-gen.o
ATTACK_OBJS := $(MOVEGEN_OBJS) ATTACK_OBJS := $(MOVEGEN_OBJS)
MOVEDO_OBJS := $(ATTACK_OBJS) move-do.o MOVEDO_OBJS := $(ATTACK_OBJS) move-do.o
PERFT_OBJS := $(MOVEDO_OBJS) search.o PERFT_OBJS := $(MOVEDO_OBJS) search.o

View File

@@ -49,7 +49,7 @@ typedef enum {
/* special move_t values */ /* special move_t values */
#define MOVE_NULL 0 /* hack: from = to = A1 */ #define MOVE_NULL 0 /* hack: from = to = A1 */
#define MOVE_NONE 07777 /* hack: from = to = H8 */ #define MOVE_NONE 07777 /* hack: from = to = H8 */
#define MOVE_NO_MOVE 01010 /* hack: from = to = A2 */ // #define MOVE_NO_MOVE 01010 /* hack: from = to = A2 */
#define move_set_flags(move, flags) ((move) | (flags)) #define move_set_flags(move, flags) ((move) | (flags))
#define move_flags(move) ((move) & M_FLAGS_MASK) #define move_flags(move) ((move) & M_FLAGS_MASK)

View File

@@ -29,50 +29,6 @@
#include "move-gen.h" #include "move-gen.h"
#include "search.h" #include "search.h"
// #include "common-test.h"
static move_t move_in_movelist(movelist_t *ml, square_t from, square_t to, piece_type_t pt)
{
const int nmoves = ml->nmoves;
const move_t *moves = ml->move;
int movenum = 0;
move_t move;
for (movenum = 0; movenum < nmoves; ++movenum) {
move = moves[movenum];
printf("compare %s%s to %s%s pt=%d ",
sq_to_string(from), sq_to_string(to),
sq_to_string(move_from(move)),
sq_to_string(move_to(move)),
pt
);
if (move_from(move) == from && move_to(move) == to) {
printf("HIT!\n");
if (pt != NO_PIECE_TYPE && move_promoted(move) != pt)
continue;
printf("move_in_movelist(%s%s) found from=%s to=%s\n",
sq_to_string(from), sq_to_string(to),
sq_to_string(move_from(move)),
sq_to_string(move_to(move)));
return move;
} else
puts("");
}
return MOVE_NONE;
}
static move_t move_from_str(pos_t *pos, const char *move)
{
movelist_t movelist;
square_t from = sq_from_string(move);
square_t to = sq_from_string(move + 2);
piece_type_t promoted = piece_t_from_char(*(move + 4));
printf("from=%o to=%o promoted=%d\n", from, to, promoted);
pos_set_checkers_pinners_blockers(pos);
pos_legal(pos, pos_gen_pseudo(pos, &movelist));
return move_in_movelist(&movelist, from, to, promoted);
}
static void pr_entry(hentry_t *entry) static void pr_entry(hentry_t *entry)
{ {
if (!entry) if (!entry)
@@ -91,7 +47,7 @@ int main()
hentry_t *entry; hentry_t *entry;
move_t move; move_t move;
state_t state; state_t state;
//movelist_t movelist; movelist_t movelist;
const char *moves_array[] = { const char *moves_array[] = {
"e2e4 e7e5 g1f3 b8c6", "e2e4 e7e5 g1f3 b8c6",
@@ -113,19 +69,22 @@ int main()
depth++; depth++;
printf("%s ", token); printf("%s ", token);
//pos_set_checkers_pinners_blockers(pos); move = move_from_str(token);
//pos_legal(pos, pos_gen_pseudo(pos, &movelist)); pos_set_checkers_pinners_blockers(pos);
move = move_from_str(pos, token); pos_legal(pos, pos_gen_pseudo(pos, &movelist));
printf("move: %s\n", move_to_str(buf, move, 0)); printf("move: %s\n", move_to_str(buf, move, 0));
move_do(pos, move, &state); move = move_find_in_movelist(move, &movelist);
if ((entry = tt_probe_perft(pos->key, depth))) { if (move != MOVE_NONE) {
printf("tt hit: depth=%d val=%lu", move_do(pos, move, &state);
HASH_PERFT_DEPTH(entry->data), if ((entry = tt_probe_perft(pos->key, depth))) {
HASH_PERFT_VAL(entry->data)); printf("tt hit: depth=%d val=%lu",
} else { HASH_PERFT_DEPTH(entry->data),
tt_store_perft(pos->key, i + 1, depth); HASH_PERFT_VAL(entry->data));
printf("tt store: depth=%d val=%lu", depth, (u64)i * 123); } else {
}; tt_store_perft(pos->key, i + 1, depth);
printf("tt store: depth=%d val=%lu", depth, (u64)i * 123);
};
}
token = strtok(NULL, " \t"); token = strtok(NULL, " \t");
} }