#ifndef SEARCH_H #define SEARCH_H #include #include "bitboard.h" #include "engine/moves.h" #include "engine/ttable.h" #include "ipc/go_args.h" #define SEARCH_MATE 30000 #define SEARCH_INF 32000 typedef struct { i32 score; move_t best_move; } search_result_t; // shared per-search context. `stop` is signalled by the UCI thread (SIGSTOP), // `go_args` carries the time/node/depth limits, `nodes` counts visited nodes. typedef struct { ttable_t *ttable; go_args_t *go_args; atomic_bool *stop; u64 *nodes; } search_ctx_t; search_result_t search( position_t position, int depth, int alpha, int beta, search_ctx_t *ctx ); // Reconstruct the principal variation by following TT best-move entries. // Writes at most `max_len` moves into `pv_out`; returns the number written. int reconstruct_pv( position_t position, ttable_t tt, move_t *pv_out, int max_len ); #endif // SEARCH_H