1 --- Sjeng-Free-11.2/book.c.deb 2001-07-16 20:04:48.000000000 +0800
2 +++ Sjeng-Free-11.2/book.c 2005-07-03 19:25:22.000000000 +0800
12 --- Sjeng-Free-11.2/ecache.c.deb 2001-12-28 06:25:20.000000000 +0800
13 +++ Sjeng-Free-11.2/ecache.c 2005-07-03 19:25:22.000000000 +0800
16 unsigned long stored_hash;
17 unsigned long hold_hash;
22 /*ECacheType ECache[ECACHESIZE];*/
25 void storeECache(long int score)
30 index = hash % ECacheSize;
34 void checkECache(long int *score, int *in_cache)
45 - printf("Allocated %lu eval cache entries, totalling %lu bytes.\n",
46 + printf("Allocated %u eval cache entries, totalling %zu bytes.\n",
47 ECacheSize, sizeof(ECacheType)*ECacheSize);
50 --- Sjeng-Free-11.2/epd.c.deb 2001-07-23 03:27:36.000000000 +0800
51 +++ Sjeng-Free-11.2/epd.c 2005-07-03 19:25:22.000000000 +0800
58 void setup_epd_line(char* inbuff)
63 testsuite = fopen(testname, "r");
64 + if (testsuite==NULL) {
65 + fprintf(stderr, "Cannot open file %s: %s\n", testname, strerror(errno));
69 while (fgets(readbuff, 2000, testsuite) != NULL)
75 - elapsed = (cpu_end-cpu_start)/(double) CLOCKS_PER_SEC;
76 - printf("Time: %f\n", elapsed);
77 + // elapsed = (cpu_end-cpu_start)/(double) CLOCKS_PER_SEC;
78 + // printf("Time: %f\n", elapsed);
80 if (interrupt()) rinput(tempbuff, STR_BUFF, stdin);
84 printf("Move ordering : %f%%\n", (((float)FHF*100)/(float)FH+1));
86 - printf("Material score: %d Eval : %d\n", Material, eval());
87 + printf("Material score: %d Eval : %ld\n", Material, eval());
98 --- Sjeng-Free-11.2/extvars.h.deb 2001-12-28 06:19:58.000000000 +0800
99 +++ Sjeng-Free-11.2/extvars.h 2005-07-03 19:25:22.000000000 +0800
101 extern int havercfile;
104 -extern int ECacheSize;
105 +extern unsigned int ECacheSize;
107 extern int my_rating, opp_rating;
108 extern int userealholdings;
115 --- Sjeng-Free-11.2/learn.c.deb 2001-09-28 18:14:13.000000000 +0800
116 +++ Sjeng-Free-11.2/learn.c 2005-07-03 19:25:22.000000000 +0800
121 -void Learn(int score, int best, int depth)
122 +void Learn(long score, int best, int depth)
124 int number = 0, next = 0;
128 - printf("Learning score: %d best: %d depth:%d hash: %X\n", score, best, depth, hash);
129 + printf("Learning score: %ld best: %d depth:%d hash: %lX\n", score, best, depth, hash);
131 if (Variant == Normal)
135 lrnfile = &lrn_losers;
137 + else return; // Can this happen?
139 fseek(*lrnfile, 0, SEEK_SET);
140 fread(&number, sizeof(int), 1, *lrnfile);
141 --- Sjeng-Free-11.2/leval.c.deb 2001-09-02 19:04:53.000000000 +0800
142 +++ Sjeng-Free-11.2/leval.c 2005-07-03 19:25:22.000000000 +0800
143 @@ -120,13 +120,13 @@
144 long int losers_eval (void) {
\r
146 /* return a score for the current middlegame position: */
\r
147 - int srank, pawn_file, pawns[2][11], white_back_pawn[11], black_back_pawn[11];
\r
148 + int srank = 0, pawn_file = 0, pawns[2][11], white_back_pawn[11], black_back_pawn[11];
\r
149 int isolated, backwards;
\r
151 long int score = 0;
\r
153 int wp = 0, bp = 0;
\r
155 + int wks = 0, bks = 0;
\r
156 int wpassp = 0, bpassp = 0;
\r
157 int wpawns = 0, bpawns = 0;
\r
159 --- Sjeng-Free-11.2/moves.c.deb 2001-06-07 06:12:46.000000000 +0800
160 +++ Sjeng-Free-11.2/moves.c 2005-07-03 19:25:22.000000000 +0800
163 static move_s *genfor;
169 int kingcap; /* break if we capture the king */
170 --- Sjeng-Free-11.2/neval.c.deb 2001-06-29 03:48:09.000000000 +0800
171 +++ Sjeng-Free-11.2/neval.c 2005-07-03 19:25:22.000000000 +0800
174 int wp = 0, bp = 0, wn = 0, bn = 0, wb = 0, bb = 0,
175 wq = 0, bq = 0, wr = 0, br = 0;
176 - int fwrook, fbrook, rwrook, rbrook;
177 + int fwrook = 0, fbrook = 0, rwrook = 0, rbrook = 0;
178 int wpotential = 0, bpotential = 0, tmp;
183 int wp = 0, bp = 0, wn = 0, bn = 0, wb = 0, bb = 0,
184 wq = 0, bq = 0, wr = 0, br = 0;
\r
185 - int rbrook, fbrook, rwrook,fwrook;
186 + int rbrook = 0, fbrook = 0, rwrook = 0,fwrook = 0;
190 --- Sjeng-Free-11.2/newbook.c.deb 2001-06-07 06:12:39.000000000 +0800
191 +++ Sjeng-Free-11.2/newbook.c 2005-07-03 19:25:22.000000000 +0800
195 unsigned long played;
205 - int win = 0, loss = 0;
208 /* fill in the key field */
213 - signed long scores[MOVE_BUFF], best_score = 0;
214 + long int scores[MOVE_BUFF], best_score = 0;
220 comp_to_coord(moves[i], output);
222 - printf("Move %s: %ld times played, %d learned\n", output,
223 + printf("Move %s: %ld times played, %ld learned\n", output,
224 ps->played, ps->score);
226 if ((ps->played + ps->score) >= PLAYTHRESHOLD)
229 void book_learning(int result)
232 + GDBM_FILE binbook = NULL;
239 /* don't 'overlearn' */
\r
240 - if (abs((ps->score)+pi) < (ps->played*5))
\r
241 + if ((unsigned long)labs((ps->score)+pi) < (ps->played*5))
\r
244 printf("Learning opening %lu, played %lu, old score %ld, new score %ld\n",
245 --- Sjeng-Free-11.2/probe.c.deb 2001-09-12 17:28:18.000000000 +0800
246 +++ Sjeng-Free-11.2/probe.c 2005-07-03 19:25:22.000000000 +0800
251 -const static int EGTranslate(int sqidx)
\r
253 +static int EGTranslate(int sqidx)
\r
263 int probe_egtb(void)
\r
265 --- Sjeng-Free-11.2/proof.c.deb 2001-12-28 06:52:15.000000000 +0800
266 +++ Sjeng-Free-11.2/proof.c 2005-07-03 19:25:22.000000000 +0800
268 void losers_pn_eval (node_t *this);
270 unsigned char *membuff;
272 +unsigned int bufftop = 0;
274 void* Xmalloc(int size)
278 move_s moves[MOVE_BUFF];
284 @@ -1024,7 +1023,7 @@
288 - int leastlooked, leastlooked_l, leastlooked_i;
289 + int leastlooked, leastlooked_l = 0, leastlooked_i = 0;
292 int firsts, alternates;
293 @@ -1364,7 +1363,7 @@
297 - printf("P: %d D: %d N: %d S: %d Mem: %2.2fM Iters: %d ", root->proof, root->disproof, nodecount, frees, (((nodecount) * sizeof(node_t) / (float)(1024*1024))), iters);
298 + printf("P: %d D: %d N: %d S: %ld Mem: %2.2fM Iters: %d ", root->proof, root->disproof, nodecount, frees, (((nodecount) * sizeof(node_t) / (float)(1024*1024))), iters);
302 @@ -1415,7 +1414,7 @@
306 - printf ("P: %d D: %d N: %d S: %d Mem: %2.2fM Iters: %d MaxDepth: %d\n", root->proof, root->disproof, nodecount, frees, (((nodecount) * sizeof (node_t) / (float) (1024 * 1024))), iters,maxply);
307 + printf ("P: %d D: %d N: %d S: %ld Mem: %2.2fM Iters: %d MaxDepth: %d\n", root->proof, root->disproof, nodecount, frees, (((nodecount) * sizeof (node_t) / (float) (1024 * 1024))), iters,maxply);
310 printf ("tellics whisper proof %d, disproof %d, %d nodes, %d forwards, %d iters, highest depth %d\n", root->proof, root->disproof, nodecount, forwards, iters, maxply);
311 @@ -1608,7 +1607,7 @@
315 - printf("P: %d D: %d N: %d S: %d Mem: %2.2fM Iters: %d\n", root->proof, root->disproof, nodecount, frees, (((nodecount) * sizeof(node_t) / (float)(1024*1024))), iters);
316 + printf("P: %d D: %d N: %d S: %ld Mem: %2.2fM Iters: %d\n", root->proof, root->disproof, nodecount, frees, (((nodecount) * sizeof(node_t) / (float)(1024*1024))), iters);
318 while(currentnode != root)
320 --- Sjeng-Free-11.2/protos.h.deb 2001-07-18 09:21:37.000000000 +0800
321 +++ Sjeng-Free-11.2/protos.h 2005-07-03 19:25:22.000000000 +0800
325 void push_slidE (int target);
326 -long int qsearch (int alpha, int beta, int depth);
327 +long int qsearch (long alpha, long beta, int depth);
328 void rdelay (int time_in_s);
329 long int rdifftime (rtime_t end, rtime_t start);
330 bool remove_one (int *marker, long int move_ordering[], int num_moves);
332 void check_piece_square (void);
333 void rinput (char str[], int n, FILE *stream);
334 rtime_t rtime (void);
335 -long int search (int alpha, int beta, int depth, int is_null);
336 -move_s search_root (int alpha, int beta, int depth);
337 +long int search (long alpha, long beta, int depth, int is_null);
338 +move_s search_root (long alpha, long beta, int depth);
339 void start_up (void);
341 void toggle_bool (bool *var);
342 @@ -111,14 +111,14 @@
343 move_s choose_book_move(void);
344 move_s choose_binary_book_move(void);
346 -void StoreTT(int score, int alpha, int beta, int best , int threat, int depth);
347 -void QStoreTT(int score, int alpha, int beta, int best);
348 -int ProbeTT(int *score, int alpha, int beta, int *best, int *threat, int *donull, int depth);
349 -int QProbeTT(int *score, int alpha, int beta, int *best);
350 -void LearnStoreTT(int score, unsigned nhash, unsigned hhash, int tomove, int best, int depth);
351 +void StoreTT(long score, long alpha, long beta, int best , int threat, int depth);
352 +void QStoreTT(long score, long alpha, long beta, int best);
353 +int ProbeTT(long *score, long alpha, long beta, int *best, int *threat, int *donull, int depth);
354 +int QProbeTT(long *score, long alpha, long beta, int *best);
355 +void LearnStoreTT(long score, unsigned nhash, unsigned hhash, int tomove, int best, int depth);
357 void LoadLearn(void);
358 -void Learn(int score, int best, int depth);
359 +void Learn(long score, int best, int depth);
361 void pinput (int n, FILE *stream);
364 void gen_all_tables(void);
367 +int load_2piece(void);
368 +int load_3piece(int w1_man, int b1_man, int b2_man, signed char *t);
369 +int init_segtb(void);
373 --- Sjeng-Free-11.2/rcfile.c.deb 2001-09-28 18:19:18.000000000 +0800
374 +++ Sjeng-Free-11.2/rcfile.c 2005-07-03 19:25:22.000000000 +0800
381 +#include <sys/types.h>
391 +unsigned int ECacheSize;
397 fgets(line, STR_BUFF, rcfile);
398 while (line[0] == '#') fgets(line, STR_BUFF, rcfile);
399 - sscanf(line, "%d", &ECacheSize);
400 + sscanf(line, "%u", &ECacheSize);
402 fgets(line, STR_BUFF, rcfile);
403 while (line[0] == '#') fgets(line, STR_BUFF, rcfile);
406 sprintf(setcode, "%u", setc);
412 --- Sjeng-Free-11.2/search.c.deb 2001-12-28 06:20:56.000000000 +0800
413 +++ Sjeng-Free-11.2/search.c 2005-07-03 19:25:22.000000000 +0800
418 -long int qsearch (int alpha, int beta, int depth) {
419 +long int qsearch (long alpha, long beta, int depth) {
421 /* perform a quiscense search on the current node using alpha-beta with
424 move_ordering[MOVE_BUFF],
425 see_values[MOVE_BUFF];
426 bool legal_move, no_moves = TRUE;
427 - int sbest, best_score, best, delta, bound;
430 + long best_score, bound, delta;
432 + long originalalpha;
436 pv_length[ply] = ply;
439 oldtime = time_for_move;
440 time_for_move += allocate_time();
441 - printf("Extended from %d to %d, time left %d\n", oldtime,
442 + printf("Extended from %ld to %ld, time left %ld\n", oldtime,
450 -long int search (int alpha, int beta, int depth, int is_null) {
451 +long int search (long alpha, long beta, int depth, int is_null) {
453 /* search the current node using alpha-beta with negamax search */
455 @@ -481,16 +482,18 @@
457 long int score = -INF, move_ordering[MOVE_BUFF], see_values[MOVE_BUFF];
458 bool no_moves, legal_move;
459 - int bound, threat, donull, best, sbest, best_score, old_ep;
460 + long int best_score, bound;
461 + int threat, donull, best, sbest, old_ep;
463 - int extend, fscore, fmax, selective;
464 + long int fscore, fmax;
465 + int extend, selective;
469 + long originalalpha;
476 static const int rc_index[14] = {0,1,1,2,2,5,5,3,3,4,4,2,2,0};
480 oldtime = time_for_move;
481 time_for_move += allocate_time();
482 - printf("Extended from %d to %d, time left %d\n", oldtime,
483 + printf("Extended from %ld to %ld, time left %ld\n", oldtime,
487 @@ -826,11 +829,12 @@
488 afterincheck = f_in_check(&moves[0], i);
489 checks[ply] = afterincheck;
491 - if (!afterincheck && ((Variant == Normal)
492 - || (Variant == Suicide)
493 - || (Variant == Losers)) && (depth < 3) &&
494 - (((board[moves[i].target] == wpawn) && (rank(moves[i].target) >= 6)
495 - || ((board[moves[i].target] == bpawn) && (rank(moves[i].target) <= 3)))))
497 + && ((Variant == Normal) || (Variant == Suicide) || (Variant == Losers))
499 + && (((board[moves[i].target] == wpawn) && (rank(moves[i].target) >= 6))
501 + ((board[moves[i].target] == bpawn) && (rank(moves[i].target) <= 3))))
505 @@ -1066,7 +1070,7 @@
509 -move_s search_root (int originalalpha, int originalbeta, int depth) {
510 +move_s search_root (long originalalpha, long originalbeta, int depth) {
512 /* search the root node using alpha-beta with negamax search */
514 @@ -1074,7 +1078,7 @@
516 long int root_score = -INF, move_ordering[MOVE_BUFF], see_values[MOVE_BUFF];
517 bool no_moves, legal_move, first;
523 @@ -1447,15 +1451,15 @@
525 move_s comp_move, temp_move, old_move;
527 - long int elapsed, temp_score, true_score;
528 + long int elapsed, temp_score = 0, true_score;
529 char postmove[STR_BUFF];
530 clock_t cpu_start, cpu_end;
536 move_s moves[MOVE_BUFF];
537 - int l, lastlegal, ic;
538 + int l, lastlegal = 0, ic;
542 @@ -1632,7 +1636,7 @@
544 if (pn_restart) time_for_move = (float)time_for_move * (float)2/((float)pn_restart+1.0);
546 - printf("Time for move : %d\n", time_for_move);
547 + printf("Time for move : %ld\n", time_for_move);
549 if (time_for_move > 50)
551 @@ -1658,6 +1662,7 @@
552 if ((forcedwin || result) && (pn_move.target != dummy.target)
555 + cpu_start = clock();
559 @@ -1861,7 +1866,7 @@
563 - for (j = 0; j < num_moves; j++)
564 + for (j = 0, k = 0; j < num_moves; j++)
566 if (rootlosers[j]) k++;
568 @@ -1883,7 +1888,7 @@
570 elapsed = rdifftime (rtime (), start_time);
572 - printf("Used time : %d\n", elapsed);
573 + printf("Used time : %ld\n", elapsed);
575 /* update our elapsed time_cushion: */
576 if (moves_to_tc && !is_pondering) {
577 @@ -1937,7 +1942,7 @@
579 if ((et > 0) && (Variant != Bughouse))
581 - 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",
582 + 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",
583 true_i_depth, (float)temp_score/100.0, postpv, nodes,
584 (((float)qnodes*100)/((float)nodes+1)),
585 ((float)FHF*100)/((float)(FH+1)),
586 --- Sjeng-Free-11.2/segtb.c.deb 2001-12-28 06:46:41.000000000 +0800
587 +++ Sjeng-Free-11.2/segtb.c 2005-07-03 19:25:22.000000000 +0800
588 @@ -742,10 +742,10 @@
592 - int w1_man, w2_man, b1_man, b2_man;
593 - int w1, w2, b1, b2;
594 + int w1_man = 0, w2_man = 0, b1_man = 0, b2_man = 0;
595 + int w1 = 0, w2 = 0, b1 = 0, b2 = 0;
596 int w_count = 0, b_count = 0;
597 - int i, t, temp, junk, bpc;
598 + int i, t, temp, junk = 0, bpc;
601 /* first figure out what kind of position we have */
602 --- Sjeng-Free-11.2/seval.c.deb 2001-07-12 03:25:51.000000000 +0800
603 +++ Sjeng-Free-11.2/seval.c 2005-07-03 19:25:22.000000000 +0800
606 static int black_saccers(int square)
608 - register int ndir, a_sq;
609 - register int basq, i;
610 register int f = FALSE;
612 /* for white pawn on square, any black
616 else if (rank(square) == 4 &&
617 - board[square + 35] == bpawn ||
618 - board[square + 37] == bpawn)
619 + (board[square + 35] == bpawn ||
620 + board[square + 37] == bpawn))
625 /* for black pawn on square, any black
626 * pieces that can sac themselves to it? */
628 - register int ndir, a_sq;
629 - register int basq, i;
630 register int f = FALSE;
632 /* for white pawn on square, any black
636 else if (rank(square) == 5 &&
637 - board[square - 35] == wpawn ||
638 - board[square - 37] == wpawn)
639 + (board[square - 35] == wpawn ||
640 + board[square - 37] == wpawn))
645 int isolated, backwards, i, a, j;
648 - int wb = 0, bb = 0, wbc, bbc;
649 + int wb = 0, bb = 0, wbc = 0, bbc = 0;
650 int wk = 0, bk = 0, wr = 0, br = 0;
651 int wn = 0, bn = 0, wp = 0, bp = 0;
653 --- Sjeng-Free-11.2/sjeng.c.deb 2001-12-28 06:20:38.000000000 +0800
654 +++ Sjeng-Free-11.2/sjeng.c 2005-07-03 19:25:22.000000000 +0800
656 #include "config.h"
\r
658 char divider[50] = "-------------------------------------------------";
\r
659 -move_s dummy = {0,0,0,0,0};
\r
660 +move_s dummy = {0,0,0,0,0,0};
\r
662 int board[144], moved[144], ep_square, white_to_move, comp_color, wking_loc,
\r
663 bking_loc, white_castled, black_castled, result, ply, pv_length[PV_BUFF],
\r
668 -int main (int argc, char *argv[]) {
\r
671 char input[STR_BUFF], *p, output[STR_BUFF];
\r
672 char readbuff[STR_BUFF];
\r
675 bool force_mode, show_board;
\r
676 double nps, elapsed;
\r
677 - clock_t cpu_start, cpu_end;
\r
678 + clock_t cpu_start = 0, cpu_end = 0;
\r
679 move_s game_history[600];
\r
680 move_x game_history_x[600];
\r
681 - int is_edit_mode, edit_color;
\r
682 + int is_edit_mode, edit_color = 0;
\r
684 int braindeadinterface;
\r
686 @@ -334,10 +371,10 @@
688 printf("Move ordering : %f%%\n", (((float)FHF*100)/(float)(FH+1)));
\r
690 - printf("Material score: %d Eval : %d White hand: %d Black hand : %d\n",
\r
691 + printf("Material score: %d Eval : %ld White hand: %d Black hand : %d\n",
\r
692 Material, eval(), white_hand_eval, black_hand_eval);
\r
694 - printf("Hash : %X HoldHash : %X\n", hash, hold_hash);
\r
695 + printf("Hash : %lX HoldHash : %lX\n", hash, hold_hash);
\r
697 /* check to see if we mate our opponent with our current move: */
\r
701 else if (!strcmp (input, "eval")) {
\r
703 - printf("Eval: %d\n", eval());
\r
704 + printf("Eval: %ld\n", eval());
\r
706 else if (!strcmp (input, "go")) {
\r
707 comp_color = white_to_move;
\r
711 else if (!strncmp (input, "rating", 6)) {
\r
712 - sscanf (input+7, "%ld %ld", &my_rating, &opp_rating);
\r
713 + sscanf (input+7, "%d %d", &my_rating, &opp_rating);
\r
714 if (my_rating == 0) my_rating = 2000;
\r
715 if (opp_rating == 0) opp_rating = 2000;
\r
718 printf("Move number : %d\n", move_number);
\r
719 if (move_number > 0)
\r
722 path_x[0] = game_history_x[--move_number];
\r
723 unmake(&game_history[move_number], 0);
\r
724 reset_piece_square();
\r
725 @@ -738,10 +776,12 @@
726 else if (!strncmp (input, "remove", 5)) {
\r
727 if (move_number > 1)
\r
730 path_x[0] = game_history_x[--move_number];
\r
731 unmake(&game_history[move_number], 0);
\r
732 reset_piece_square();
\r
735 path_x[0] = game_history_x[--move_number];
\r
736 unmake(&game_history[move_number], 0);
\r
737 reset_piece_square();
\r
739 run_epd_testsuite();
\r
741 else if (!strncmp (input, "st", 2)) {
\r
742 - sscanf(input+3, "%d", &fixed_time);
\r
743 + sscanf(input+3, "%ld", &fixed_time);
\r
744 fixed_time = fixed_time * 100;
\r
746 else if (!strncmp (input, "book", 4)) {
\r
747 --- Sjeng-Free-11.2/ttable.c.deb 2001-07-13 02:04:48.000000000 +0800
748 +++ Sjeng-Free-11.2/ttable.c 2005-07-03 19:25:22.000000000 +0800
753 -void QStoreTT(int score, int alpha, int beta, int best)
754 +void QStoreTT(long score, long alpha, long beta, int best)
762 -void StoreTT(int score, int alpha, int beta, int best, int threat, int depth)
763 +void StoreTT(long score, long alpha, long beta, int best, int threat, int depth)
771 -void LearnStoreTT(int score, unsigned nhash, unsigned hhash, int tomove, int best, int depth)
772 +void LearnStoreTT(long score, unsigned nhash, unsigned hhash, int tomove, int best, int depth)
780 -int ProbeTT(int *score, int alpha, int beta, int *best, int *threat, int *donull, int depth)
781 +int ProbeTT(long *score, long alpha, long beta, int *best, int *threat, int *donull, int depth)
789 -int QProbeTT(int *score, int alpha, int beta, int *best)
790 +int QProbeTT(long *score, long alpha, long beta, int *best)
794 --- Sjeng-Free-11.2/utils.c.deb 2001-07-14 00:36:40.000000000 +0800
795 +++ Sjeng-Free-11.2/utils.c 2005-07-03 19:25:22.000000000 +0800
798 void hash_extract_pv(int level, char str[])
803 move_s moves[MOVE_BUFF];
805 char output[STR_BUFF];
810 - if(ProbeTT(&dummy, 0, 0, &bm, &dummy, &dummy, 0) != HMISS)
811 + if(ProbeTT(&dummy_long, 0, 0, &bm, &dummy_int, &dummy_int, 0) != HMISS)
814 num_moves = numb_moves;
815 @@ -1342,7 +1343,7 @@
818 /* invalidate the ecache */
819 - hash = (++hash) % ULONG_MAX;