File: newbook.c.patch

package info (click to toggle)
sjeng 11.2-15
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,436 kB
  • sloc: ansic: 13,378; sh: 324; makefile: 29
file content (60 lines) | stat: -rw-r--r-- 1,429 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Author: Lukas Geyer <lukas@debian.org>
Description: Made all score variables long int, also
             fixed several format mismatches in fprintf():
Bugs: #192902

--- sjeng-11.2.orig/newbook.c
+++ sjeng-11.2/newbook.c
@@ -43,7 +43,7 @@
 typedef struct 
 {
   unsigned long played;
-  signed long score;
+  long int score;
 } posinfo_t;
 
 typedef struct 
@@ -118,7 +118,6 @@
   posinfo_t *pst;
   datum index;
   datum data;
-  int win = 0, loss = 0;
   int ret;
   
   /* fill in the key field */
@@ -461,7 +460,7 @@
   int raw;
   int num_moves, i;
   char output[6];
-  signed long scores[MOVE_BUFF], best_score = 0;
+  long int scores[MOVE_BUFF], best_score = 0;
   
   srand(time(0));
   
@@ -524,7 +523,7 @@
 			
 	      comp_to_coord(moves[i], output);
 	      
-	      printf("Move %s: %ld times played, %d learned\n", output,
+	      printf("Move %s: %ld times played, %ld learned\n", output,
 		     ps->played, ps->score);
 	      
 	      if ((ps->played + ps->score) >=  PLAYTHRESHOLD)
@@ -593,7 +592,7 @@
 
 void book_learning(int result)
 {
-  GDBM_FILE binbook;
+  GDBM_FILE binbook = NULL;
   hashkey_t key;
   posinfo_t *ps;
   datum index;
@@ -675,7 +674,7 @@
 	  }
 
 		/* don't 'overlearn' */
-	  if (abs((ps->score)+pi) < (ps->played*5))
+	  if ((unsigned long)labs((ps->score)+pi) < (ps->played*5))
 	  {
       
         printf("Learning opening %lu, played %lu, old score %ld, new score %ld\n",