diff --git a/Makefile b/Makefile index 971b987..4849fb0 100644 --- a/Makefile +++ b/Makefile @@ -398,9 +398,9 @@ TEST += movedo-test perft-test tt-test PIECE_OBJS := piece.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) -MOVEGEN_OBJS := $(BB_OBJS) move.o move-gen.o +MOVEGEN_OBJS := $(BB_OBJS) move-gen.o ATTACK_OBJS := $(MOVEGEN_OBJS) MOVEDO_OBJS := $(ATTACK_OBJS) move-do.o PERFT_OBJS := $(MOVEDO_OBJS) search.o diff --git a/src/move.h b/src/move.h index 3376242..ca7fade 100644 --- a/src/move.h +++ b/src/move.h @@ -49,7 +49,7 @@ typedef enum { /* special move_t values */ #define MOVE_NULL 0 /* hack: from = to = A1 */ #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_flags(move) ((move) & M_FLAGS_MASK) diff --git a/test/tt-test.c b/test/tt-test.c index 2d1f112..a300083 100644 --- a/test/tt-test.c +++ b/test/tt-test.c @@ -29,50 +29,6 @@ #include "move-gen.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) { if (!entry) @@ -91,7 +47,7 @@ int main() hentry_t *entry; move_t move; state_t state; - //movelist_t movelist; + movelist_t movelist; const char *moves_array[] = { "e2e4 e7e5 g1f3 b8c6", @@ -113,19 +69,22 @@ int main() depth++; printf("%s ", token); - //pos_set_checkers_pinners_blockers(pos); - //pos_legal(pos, pos_gen_pseudo(pos, &movelist)); - move = move_from_str(pos, token); + move = move_from_str(token); + pos_set_checkers_pinners_blockers(pos); + pos_legal(pos, pos_gen_pseudo(pos, &movelist)); printf("move: %s\n", move_to_str(buf, move, 0)); - move_do(pos, move, &state); - if ((entry = tt_probe_perft(pos->key, depth))) { - printf("tt hit: depth=%d val=%lu", - HASH_PERFT_DEPTH(entry->data), - HASH_PERFT_VAL(entry->data)); - } else { - tt_store_perft(pos->key, i + 1, depth); - printf("tt store: depth=%d val=%lu", depth, (u64)i * 123); - }; + move = move_find_in_movelist(move, &movelist); + if (move != MOVE_NONE) { + move_do(pos, move, &state); + if ((entry = tt_probe_perft(pos->key, depth))) { + printf("tt hit: depth=%d val=%lu", + HASH_PERFT_DEPTH(entry->data), + HASH_PERFT_VAL(entry->data)); + } else { + tt_store_perft(pos->key, i + 1, depth); + printf("tt store: depth=%d val=%lu", depth, (u64)i * 123); + }; + } token = strtok(NULL, " \t"); }