From 86f8184c56724dfd1a43ce47debf0325837660a2 Mon Sep 17 00:00:00 2001 From: Bruno Raoult Date: Wed, 15 May 2024 18:34:50 +0200 Subject: [PATCH] misc.c: init_all() --- Makefile | 11 +++++++---- src/chessdefs.h | 2 ++ src/init.c | 4 ++-- test/movedo-test.c | 5 +---- test/perft-test.c | 7 ++----- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 0928bf6..b9b359c 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,9 @@ CPPFLAGS += -DWARN_ON # brlib bug.h # fen.c #CPPFLAGS += -DDEBUG_FEN # FEN decoding +# hash +CPPFLAGS += -DDEBUG_HASH # chk zobrist consistency + # attack.c #CPPFLAGS += -DDEBUG_ATTACK_ATTACKERS # sq_attackers #CPPFLAGS += -DDEBUG_ATTACK_PINNERS # sq_pinners details @@ -342,12 +345,12 @@ TEST += movedo-test perft-test PIECE_OBJS := piece.o FEN_OBJS := $(PIECE_OBJS) fen.o position.o bitboard.o board.o \ - hyperbola-quintessence.o attack.o + hyperbola-quintessence.o attack.o hash.o init.o BB_OBJS := $(FEN_OBJS) MOVEGEN_OBJS := $(BB_OBJS) move.o move-gen.o ATTACK_OBJS := $(MOVEGEN_OBJS) -MOVEDO_OBJS := $(ATTACK_OBJS) move-do.o hash.o -PERFT_OBJS := $(MOVEDO_OBJS) search.o misc.o +MOVEDO_OBJS := $(ATTACK_OBJS) move-do.o misc.o +PERFT_OBJS := $(MOVEDO_OBJS) search.o TEST := $(addprefix $(BINDIR)/,$(TEST)) @@ -387,7 +390,7 @@ bin/attack-test: test/attack-test.c test/common-test.h $(ATTACK_OBJS) bin/movedo-test: test/movedo-test.c test/common-test.h $(MOVEDO_OBJS) @echo compiling $@ test executable. - @$(CC) $(ALL_CFLAGS) $< $(MOVEDO_OBJS) $(ALL_LDFLAGS) -o $@ + $(CC) $(ALL_CFLAGS) $< $(MOVEDO_OBJS) $(ALL_LDFLAGS) -o $@ bin/perft-test: test/perft-test.c test/common-test.h $(PERFT_OBJS) @echo compiling $@ test executable. diff --git a/src/chessdefs.h b/src/chessdefs.h index 59f2837..75e9665 100644 --- a/src/chessdefs.h +++ b/src/chessdefs.h @@ -178,4 +178,6 @@ double clock_elapsed_sec(mclock_t *clock); void rand_init(u64 seed); u64 rand64(void); +void init_all(void); + #endif /* _CHESSDEFS_H */ diff --git a/src/init.c b/src/init.c index a12957a..175594e 100644 --- a/src/init.c +++ b/src/init.c @@ -21,7 +21,7 @@ #include "hash.h" -void init_all() +void init_all(void) { /* for printf() numeric thousands separator */ setlocale(LC_NUMERIC, ""); @@ -37,6 +37,6 @@ void init_all() /* zobrist tables & default tt hashtable */ zobrist_init(); - hash_create(HASH_DEFAULT); + hash_create(HASH_SIZE_DEFAULT); } diff --git a/test/movedo-test.c b/test/movedo-test.c index 1415c29..bc534ff 100644 --- a/test/movedo-test.c +++ b/test/movedo-test.c @@ -32,10 +32,7 @@ int main(int __unused ac, __unused char**av) movelist_t pseudo; move_t move; - setlinebuf(stdout); /* line-buffered stdout */ - - bitboard_init(); - hyperbola_init(); + init_all(); while ((fen = next_fen(MOVEDO))) { test_line = cur_line(); diff --git a/test/perft-test.c b/test/perft-test.c index 872e8e3..2a1e07e 100644 --- a/test/perft-test.c +++ b/test/perft-test.c @@ -277,17 +277,14 @@ int main(int __unused ac, __unused char**av) // run = atoi(av[2]) & 3; printf("depth = %d run = %x sf = %s\n", depth, run, sf_run? "true": "false"); + init_all(); + if (!run) exit(0); - setlocale(LC_NUMERIC, ""); - setlinebuf(stdout); /* line-buffered stdout */ if (sf_run) outfd = open_stockfish(); - bitboard_init(); - hyperbola_init(); - CLOCK_DEFINE(clock, CLOCK_PROCESS); while ((fen = next_fen(PERFT | MOVEDO))) { test_line = cur_line();