diff --git a/Makefile b/Makefile index 8eff347..7fbfd41 100644 --- a/Makefile +++ b/Makefile @@ -64,10 +64,12 @@ CPPFLAGS += -DWARN_ON # brlib bug.h #CPPFLAGS += -DDEBUG_DEBUG # enable log() functions #CPPFLAGS += -DDEBUG_DEBUG_C # enable log() settings #CPPFLAGS += -DDEBUG_POOL # memory pools management -#CPPFLAGS += -DDEBUG_FEN # FEN decoding #CPPFLAGS += -DDEBUG_POS # position.c #CPPFLAGS += -DDEBUG_MOVE # move generation +# fen.c +#CPPFLAGS += -DDEBUG_FEN # FEN decoding + # attack.c #CPPFLAGS += -DDEBUG_ATTACK_ATTACKERS1 # sq_attackers details CPPFLAGS += -DDEBUG_ATTACK_ATTACKERS # sq_attackers @@ -284,8 +286,9 @@ memcheck: targets ##################################### test binaries .PHONY: testing test -TEST := fen-test bitboard-test movegen-test attack-test +TEST :=piece-test fen-test bitboard-test movegen-test attack-test +PIECE_OBJS := piece.o FEN_OBJS := fen.o position.o piece.o bitboard.o board.o hyperbola-quintessence.o \ attack.o BB_OBJS := fen.o position.o piece.o bitboard.o board.o hyperbola-quintessence.o \ @@ -297,6 +300,7 @@ ATTACK_OBJS := fen.o position.o piece.o bitboard.o board.o hyperbola-quintesse TEST := $(addprefix $(BINDIR)/,$(TEST)) +PIECE_OBJS := $(addprefix $(OBJDIR)/,$(PIECE_OBJS)) FEN_OBJS := $(addprefix $(OBJDIR)/,$(FEN_OBJS)) BB_OBJS := $(addprefix $(OBJDIR)/,$(BB_OBJS)) MOVEGEN_OBJS := $(addprefix $(OBJDIR)/,$(MOVEGEN_OBJS)) @@ -308,6 +312,10 @@ test: testing: $(TEST) +bin/piece-test: test/piece-test.c $(FEN_OBJS) + @echo compiling $@ test executable. + @$(CC) $(ALL_CFLAGS) $< $(FEN_OBJS) $(ALL_LDFLAGS) -o $@ + bin/fen-test: test/fen-test.c test/common-test.h $(FEN_OBJS) @echo compiling $@ test executable. @$(CC) $(ALL_CFLAGS) $< $(FEN_OBJS) $(ALL_LDFLAGS) -o $@ diff --git a/test/common-test.h b/test/common-test.h index 9ffa8c2..3064379 100644 --- a/test/common-test.h +++ b/test/common-test.h @@ -35,6 +35,41 @@ struct fentest { */ //"4k3/pppppppp/8/8/8/8/PPPPPPPP/2BRK3 w - - 0 1", //"4k3/pppppppp/8/8/8/8/PPPPPPPP/1B1R1K2 w - - 0 1", + { MOVEGEN, + "illegal white e.p.", + "3k4/8/8/2qpPK2/8/8/8/8 w - d6 0 1", + }, + { MOVEGEN, + "illegal black e.p.", + "8/8/8/8/2QPpk2/8/8/3K4 b - d3 0 1", + }, + + { MOVEGEN, + "illegal white e.p.", + "3k4/8/5K2/3pP3/8/2b5/8/8 w - d6 0 1", + }, + { MOVEGEN, + "illegal black e.p.", + "8/8/2B5/8/3Pp3/5k2/8/3K4 b - d3 0 1", + }, + + { MOVEGEN, + "legal white e.p.", + "1K1k4/8/8/3pP3/8/6b1/8/8 w - d6 0 1", + }, + { MOVEGEN, + "legal black e.p.", + "8/8/6B1/8/3Pp3/8/8/1k1K4 b - d3 0 1", + }, + + { MOVEGEN, + "white mate.", + "1nbqkbn1/ppp1pppp/8/r1rpP1K1/8/8/PPPP1PPP/RNBQ1BNR w - d6 0 1", + }, + { MOVEGEN, + "illegal e.p.", + "1nbqkbn1/ppp1pppp/8/r1rpP1K1/8/8/PPPP1PPP/RNBQ1BNR w - d6 0 1", + }, { ATTACK, "checkers: a1 h1", "1k6/8/8/8/8/8/8/r2K3r w - - 1 1" @@ -163,7 +198,7 @@ struct fentest { "6k1/6pp/R2p4/p1p5/8/1P1r3P/6P1/6K1 b - - 3 3" }, - // below tests are from: + // some of tests below are from: // - Rodent IV // - https://www.chessprogramming.net/perfect-perft/ { FEN | MOVEGEN, @@ -174,6 +209,10 @@ struct fentest { "", "8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - - 0 1" }, + { FEN | MOVEGEN, + "", + "8/2p5/3p4/Kp5r/1R3p1k/8/4P1P1/8 w - - 0 1" + }, { FEN | MOVEGEN, "", "4rrk1/pp1n3p/3q2pQ/2p1pb2/2PP4/2P3N1/P2B2PP/4RRK1 b - - 7 19" diff --git a/test/piece-test.c b/test/piece-test.c index dbb6b65..d8f7f27 100644 --- a/test/piece-test.c +++ b/test/piece-test.c @@ -1,55 +1,20 @@ #include -#include "debug.h" +#include "brlib.h" -#include "../src/fen.h" -#include "../src/position.h" -#include "../src/bitboard.h" +#include "piece.h" -int main(int ac, char**av) +int main(__unused int ac, __unused char**av) { - pos_t *pos; - printf("zobi\n");fflush(stdout); - debug_init(6, stderr, true); - log_f(5, "kfsjdhg\n"); - pos_pool_init(); - pos = pos_get(); - piece_pool_init(); - if (ac == 1) { - printf("zoba\n");fflush(stdout); - pos_startpos(pos); - } else { - fen2pos(pos, av[1]); + piece_t p; + char *test="PNBRQKpnbrqk"; + + for (u64 i = 0; i < sizeof(test); ++i) { + char c1 = test[i], *c2; + p = piece_from_fen(c1); + c2 = piece_to_fen(p); + printf("c1=%c c2=%c\n", c1, *c2); } - pos_print(pos); - pos_pieces_print(pos); - - printf("0x1c = 11100 = C1-E1:\n"); - bitboard_print(0x1c); - - printf("0x70 = 111 = A1-C1\n"); - bitboard_print(0x70); - - printf("0x0e = 1110 = B1-D1\n"); - bitboard_print(0x0e); - - printf("0x60 = 1100000 = F1-G1\n"); - bitboard_print(0x60); - - printf("A1:\n"); - bitboard_print(A1); - - printf("1:\n"); - bitboard_print(1L); - printf("H1:\n"); - bitboard_print(H1); - printf("C1:\n"); - bitboard_print(C1); - printf("D1:\n"); - bitboard_print(D1); - printf("C1|D1:\n"); - bitboard_print(C1|D1); - printf("H8:\n"); - bitboard_print(H8); + return 0; }