Author: Lukas Geyer Description: General code cleanup. --- sjeng-11.2.orig/search.c +++ sjeng-11.2/search.c @@ -264,7 +264,7 @@ } -long int qsearch (int alpha, int beta, int depth) { +long int qsearch (long alpha, long beta, int depth) { /* perform a quiscense search on the current node using alpha-beta with negamax search */ @@ -275,9 +275,10 @@ move_ordering[MOVE_BUFF], see_values[MOVE_BUFF]; bool legal_move, no_moves = TRUE; - int sbest, best_score, best, delta, bound; - int originalalpha; - int oldtime; + long best_score, bound, delta; + int sbest, best; + long originalalpha; + long int oldtime; int seev; pv_length[ply] = ply; @@ -301,7 +302,7 @@ extendedtime = 1; oldtime = time_for_move; time_for_move += allocate_time(); - printf("Extended from %d to %d, time left %d\n", oldtime, + printf("Extended from %ld to %ld, time left %ld\n", oldtime, time_for_move, time_left); } @@ -473,7 +474,7 @@ } -long int search (int alpha, int beta, int depth, int is_null) { +long int search (long alpha, long beta, int depth, int is_null) { /* search the current node using alpha-beta with negamax search */ @@ -481,16 +482,18 @@ int num_moves, i, j; long int score = -INF, move_ordering[MOVE_BUFF], see_values[MOVE_BUFF]; bool no_moves, legal_move; - int bound, threat, donull, best, sbest, best_score, old_ep; + long int best_score, bound; + int threat, donull, best, sbest, old_ep; bool incheck, first; - int extend, fscore, fmax, selective; + long int fscore, fmax; + int extend, selective; move_s kswap; int ksswap; - int originalalpha; + long originalalpha; int afterincheck; int legalmoves; int dropcut; - int oldtime; + long int oldtime; int egscore; static const int rc_index[14] = {0,1,1,2,2,5,5,3,3,4,4,2,2,0}; @@ -512,7 +515,7 @@ extendedtime = 1; oldtime = time_for_move; time_for_move += allocate_time(); - printf("Extended from %d to %d, time left %d\n", oldtime, + printf("Extended from %ld to %ld, time left %ld\n", oldtime, time_for_move, time_left); } @@ -826,11 +829,12 @@ afterincheck = f_in_check(&moves[0], i); checks[ply] = afterincheck; - if (!afterincheck && ((Variant == Normal) - || (Variant == Suicide) - || (Variant == Losers)) && (depth < 3) && - (((board[moves[i].target] == wpawn) && (rank(moves[i].target) >= 6) - || ((board[moves[i].target] == bpawn) && (rank(moves[i].target) <= 3))))) + if (!afterincheck + && ((Variant == Normal) || (Variant == Suicide) || (Variant == Losers)) + && (depth < 3) + && (((board[moves[i].target] == wpawn) && (rank(moves[i].target) >= 6)) + || + ((board[moves[i].target] == bpawn) && (rank(moves[i].target) <= 3)))) { extend++; }; @@ -1066,7 +1070,7 @@ } -move_s search_root (int originalalpha, int originalbeta, int depth) { +move_s search_root (long originalalpha, long originalbeta, int depth) { /* search the root node using alpha-beta with negamax search */ @@ -1074,7 +1078,7 @@ int num_moves, i, j; long int root_score = -INF, move_ordering[MOVE_BUFF], see_values[MOVE_BUFF]; bool no_moves, legal_move, first; - int alpha, beta; + long alpha, beta; move_s kswap; move_s oldbest; int oldbestnum; @@ -1447,15 +1451,15 @@ move_s comp_move, temp_move, old_move; int i, j, k; - long int elapsed, temp_score, true_score; + long int elapsed, temp_score = 0, true_score; char postmove[STR_BUFF]; clock_t cpu_start, cpu_end; float et = 0; - int alpha, beta; + long alpha, beta; int tmptmp; int rs; move_s moves[MOVE_BUFF]; - int l, lastlegal, ic; + int l, lastlegal = 0, ic; int pn_restart; int num_moves; char output[8]; @@ -1632,7 +1636,7 @@ if (pn_restart) time_for_move = (float)time_for_move * (float)2/((float)pn_restart+1.0); - printf("Time for move : %d\n", time_for_move); + printf("Time for move : %ld\n", time_for_move); if (time_for_move > 50) LoadLearn(); @@ -1658,6 +1662,7 @@ if ((forcedwin || result) && (pn_move.target != dummy.target) && !is_analyzing) { + cpu_start = clock(); comp_move = pn_move; } else @@ -1861,7 +1866,7 @@ break; } } - for (j = 0; j < num_moves; j++) + for (j = 0, k = 0; j < num_moves; j++) { if (rootlosers[j]) k++; } @@ -1883,7 +1888,7 @@ } elapsed = rdifftime (rtime (), start_time); - printf("Used time : %d\n", elapsed); + printf("Used time : %ld\n", elapsed); /* update our elapsed time_cushion: */ if (moves_to_tc && !is_pondering) { @@ -1937,7 +1942,7 @@ if ((et > 0) && (Variant != Bughouse)) { - printf("tellics whisper d%d %+.2f %sn: %ld qp: %.0f%% fh: %.0f%% c-x: %d r-x: %d 1-x: %d egtb: %d time: %.2f nps: %ld\n", + printf("tellics whisper d%d %+.2f %sn: %ld qp: %.0f%% fh: %.0f%% c-x: %ld r-x: %ld 1-x: %ld egtb: %d time: %.2f nps: %ld\n", true_i_depth, (float)temp_score/100.0, postpv, nodes, (((float)qnodes*100)/((float)nodes+1)), ((float)FHF*100)/((float)(FH+1)),