diff --git a/src/search.c b/src/search.c index a264d8a6..42636a03 100644 --- a/src/search.c +++ b/src/search.c @@ -600,7 +600,12 @@ int quiescence(int alpha, int beta, board* position, time* time) { noisyGenerator(moveList, position); // sort moves - quiescence_sort_moves(moveList, position); + if (moveList->count > 0) { + quiescence_sort_moves(moveList, position); + } + + + // legal moves counter //int legal_moves = 0; @@ -1026,8 +1031,7 @@ int negamax(int alpha, int beta, int depth, board* pos, time* time, bool cutNode //captureMoves++; } - const int new_depth = depth - 1 + extensions; - + int new_depth = depth - 1 + extensions; // full-depth search if (moves_searched == 0) { @@ -1200,6 +1204,7 @@ void searchPosition(int depth, board* position, bool benchmark, time* time) { position->scorePv = 0; memset(position->killerMoves, 0, sizeof(position->killerMoves)); + //memset(position->mailbox, NO_PIECE, sizeof(position->mailbox)); memset(quietHistory, 0, sizeof(quietHistory)); memset(rootHistory, 0, sizeof(rootHistory)); memset(pawnCorrectionHistory, 0, sizeof(pawnCorrectionHistory)); diff --git a/src/search.h b/src/search.h index 3c8ed690..53f725eb 100644 --- a/src/search.h +++ b/src/search.h @@ -17,8 +17,6 @@ #include #include "utils.h" -#define maxPly 64 - extern int lmr_full_depth_moves; extern int lmr_reduction_limit; extern int lateMovePruningBaseReduction; diff --git a/src/structs.h b/src/structs.h index 16073235..f3b2d6be 100644 --- a/src/structs.h +++ b/src/structs.h @@ -12,7 +12,7 @@ #define U64 unsigned long long #endif -#define maxPly 64 +#define maxPly 256 typedef struct { U64 bitboards[12]; diff --git a/src/uci.c b/src/uci.c index a4c90517..a070f1ac 100644 --- a/src/uci.c +++ b/src/uci.c @@ -375,12 +375,20 @@ void communicate(time* time) { void uciProtocol(int argc, char *argv[]) { - board position; + board *position = (board *)malloc(sizeof(board)); - time time; + position->ply = 0; + + for (int i = 0; i < 64;i++) { + position->mailbox[i] = NO_PIECE; + } + + clearStaticEvaluationHistory(position); + + time *time_ctrl = (time *)malloc(sizeof(time)); // init time control - initTimeControl(&time); + initTimeControl(time_ctrl); // max hash MB int max_hash = 32768; @@ -400,7 +408,7 @@ void uciProtocol(int argc, char *argv[]) { if (argc >= 2 && strncmp(argv[1], "bench", 5) == 0) { printf("bench running..\n"); - benchmark(14, &position, &time); + benchmark(14, position, time_ctrl); return; } @@ -434,7 +442,7 @@ void uciProtocol(int argc, char *argv[]) { else if (strncmp(input, "position", 8) == 0) { // call parse position function - parse_position(input, &position); + parse_position(input, position); // clear hash table clearHashTable(); @@ -443,7 +451,7 @@ void uciProtocol(int argc, char *argv[]) { clearQuietHistory(); //clear static eval history - clearStaticEvaluationHistory(&position); + clearStaticEvaluationHistory(position); //clear counter moves clearCounterMoves(); @@ -452,7 +460,7 @@ void uciProtocol(int argc, char *argv[]) { else if (strncmp(input, "ucinewgame", 10) == 0) { // call parse position function - parse_position("position startpos", &position); + parse_position("position startpos", position); // clear hash table clearHashTable(); @@ -461,7 +469,7 @@ void uciProtocol(int argc, char *argv[]) { clearQuietHistory(); //clear static eval history - clearStaticEvaluationHistory(&position); + clearStaticEvaluationHistory(position); //clear counter moves clearCounterMoves(); @@ -469,7 +477,7 @@ void uciProtocol(int argc, char *argv[]) { // parse UCI "go" command else if (strncmp(input, "go", 2) == 0) { // call parse go function - goCommand(input, &position, &time); + goCommand(input, position, time_ctrl); // clear hash table clearHashTable(); @@ -478,7 +486,7 @@ void uciProtocol(int argc, char *argv[]) { clearQuietHistory(); //clear static eval history - clearStaticEvaluationHistory(&position); + clearStaticEvaluationHistory(position); //clear counter moves clearCounterMoves(); @@ -515,7 +523,7 @@ void uciProtocol(int argc, char *argv[]) { printf("uciok\n"); } else if (strncmp(input, "bench", 5) == 0) { - benchmark(14, &position, &time); + benchmark(14, position, time_ctrl); } } }