Ticket #31: signed_char_7_7.3

File signed_char_7_7.3, 9.0 kB (added by arend, 3 years ago)

Convert breakin code + callers to use signed char

Line 
1diff -u engine/liberty.h engine/liberty.h
2--- engine/liberty.h    7 Oct 2005 06:49:15 -0000
3+++ engine/liberty.h    7 Oct 2005 07:03:05 -0000
4@@ -253,7 +253,7 @@
5                                    int result, int move,
6                                    int tactical_nodes,
7                                    int breakin_node_limit,
8-                                   char breakin_shadow[BOARDMAX]);
9+                                   signed char breakin_shadow[BOARDMAX]);
10 int search_persistent_owl_cache(enum routine_id routine,
11                                int apos, int bpos, int cpos,
12                                int *result, int *move, int *move2,
13@@ -283,8 +283,8 @@
14 int fast_disconnect(int str1, int str2, int *move);
15 int non_transitivity(int str1, int str2, int str3, int *move);
16 
17-int break_in(int str, const char goal[BOARDMAX], int *move);
18-int block_off(int str1, const char goal[BOARDMAX], int *move);
19+int break_in(int str, const signed char goal[BOARDMAX], int *move);
20+int block_off(int str1, const signed char goal[BOARDMAX], int *move);
21 
22 int obvious_false_eye(int pos, int color);
23 void estimate_lunch_eye_value(int lunch, int *min, int *probable, int *max,
24diff -u engine/owl.c engine/owl.c
25--- engine/owl.c        7 Oct 2005 06:49:18 -0000
26+++ engine/owl.c        7 Oct 2005 07:03:06 -0000
27@@ -4753,12 +4753,12 @@
28     memset(component_size, 0, sizeof(int) * num_components);
29     conn_data = malloc(sizeof(struct connection_data) * num_components);
30     for (c_id = 0; c_id < num_components; c_id++) {
31-      char this_goal[BOARDMAX];
32+      signed char this_goal[BOARDMAX];
33       memset(this_goal, 0, BOARDMAX);
34 
35       for (k = 0; k < num_cuts; k++)
36        if (component[k] == c_id) {
37-         mark_string(cuts[k], this_goal, 1);
38+         signed_mark_string(cuts[k], this_goal, 1);
39          signed_mark_string(cuts[k], component2, c_id);
40        }
41       init_connection_data(color, this_goal, NO_MOVE, FP(3.01),
42diff -u interface/play_gtp.c interface/play_gtp.c
43--- interface/play_gtp.c        7 Oct 2005 06:49:22 -0000
44+++ interface/play_gtp.c        7 Oct 2005 07:03:12 -0000
45@@ -2063,7 +2063,7 @@
46 {
47   int ai, aj;
48   int i, j;
49-  char goal[BOARDMAX];
50+  signed char goal[BOARDMAX];
51   int break_move = PASS_MOVE;
52   int result;
53   int n;
54@@ -2110,7 +2110,7 @@
55 {
56   int ai, aj;
57   int i, j;
58-  char goal[BOARDMAX];
59+  signed char goal[BOARDMAX];
60   int block_move = PASS_MOVE;
61   int result;
62   int n;
63only in patch2:
64unchanged:
65--- engine/readconnect.h        12 Jun 2005 09:34:14 -0000      1.8
66+++ engine/readconnect.h        7 Oct 2005 07:03:08 -0000
67@@ -73,7 +73,7 @@ struct connection_data {
68 void compute_connection_distances(int str, int target, int cutoff,
69                                  struct connection_data *conn,
70                                  int speculative);
71-void init_connection_data(int color, const char goal[BOARDMAX],
72+void init_connection_data(int color, const signed char goal[BOARDMAX],
73                          int target, int cutoff,
74                          struct connection_data *conn, int speculative);
75 void spread_connection_distances(int color, struct connection_data *conn);
76only in patch2:
77unchanged:
78--- engine/readconnect.c        12 Jun 2005 12:22:44 -0000      1.90
79+++ engine/readconnect.c        7 Oct 2005 07:03:08 -0000
80@@ -47,12 +47,10 @@ static int recursive_connect2(int str1,
81                                int has_passed);
82 static int recursive_disconnect2(int str1, int str2, int *move,
83                                   int has_passed);
84-static int recursive_break(int str, const char goal[BOARDMAX], int *move,
85-                            int has_passed,
86-                          Hash_data *goal_hash);
87-static int recursive_block(int str, const char goal[BOARDMAX], int *move,
88-                            int has_passed,
89-                          Hash_data *goal_hash);
90+static int recursive_break(int str, const signed char goal[BOARDMAX], int *move,
91+                          int has_passed, Hash_data *goal_hash);
92+static int recursive_block(int str, const signed char goal[BOARDMAX], int *move,
93+                          int has_passed, Hash_data *goal_hash);
94 
95 static int add_array(int *array, int elt);
96 static int element_array(int *array, int elt);
97@@ -92,8 +90,7 @@ static int nodes_connect = 0;
98 /* Used by alternate connections. */
99 static char connection_shadow[BOARDMAX];
100 
101-static char breakin_shadow[BOARDMAX];
102-
103+static signed char breakin_shadow[BOARDMAX];
104 
105 /* Statistics. */
106 static int global_connection_node_counter = 0;
107@@ -2695,7 +2692,7 @@ add_to_start_queue(int pos, int dist, st
108 
109 
110 void
111-init_connection_data(int color, const char goal[BOARDMAX],
112+init_connection_data(int color, const signed char goal[BOARDMAX],
113                     int target, int cutoff,
114                     struct connection_data *conn, int speculative)
115 {
116@@ -2727,7 +2724,7 @@ init_connection_data(int color, const ch
117 }
118 
119 static int
120-find_break_moves(int str, const char goal[BOARDMAX], int color_to_move,
121+find_break_moves(int str, const signed char goal[BOARDMAX], int color_to_move,
122                 int moves[MAX_MOVES], int *total_distance)
123 {
124   struct connection_data conn1;
125@@ -2759,7 +2756,7 @@ find_break_moves(int str, const char goa
126        if (goal[stones[i]]) {
127          str2 = find_origin(stones[i]);
128          TRACE("%oUsing %1m as secondary target.\n", str2);
129-         mark_string(str2, breakin_shadow, 1);
130+         signed_mark_string(str2, breakin_shadow, 1);
131          break;
132        }
133       }
134@@ -2826,7 +2823,7 @@ find_break_moves(int str, const char goa
135 
136 /* Can (str) connect to goal[] if the other color moves first? */
137 static int
138-recursive_break(int str, const char goal[BOARDMAX], int *move,
139+recursive_break(int str, const signed char goal[BOARDMAX], int *move,
140                  int has_passed,
141                Hash_data *goal_hash)
142 {
143@@ -2941,7 +2938,7 @@ recursive_break(int str, const char goal
144 
145 /* Can (str) connect to goal[] if the other color moves first? */
146 static int
147-recursive_block(int str, const char goal[BOARDMAX], int *move,
148+recursive_block(int str, const signed char goal[BOARDMAX], int *move,
149                int has_passed, Hash_data *goal_hash)
150 {
151   int color = board[str];
152@@ -3064,7 +3061,7 @@ recursive_block(int str, const char goal
153  * not contain stones), if he gets the first move.
154  */
155 int
156-break_in(int str, const char goal[BOARDMAX], int *move)
157+break_in(int str, const signed char goal[BOARDMAX], int *move)
158 {
159   int dummy_move;
160   int save_verbose;
161@@ -3127,7 +3124,7 @@ break_in(int str, const char goal[BOARDM
162  * not contain stones), if the other color moves first.
163  */
164 int
165-block_off(int str, const char goal[BOARDMAX], int *move)
166+block_off(int str, const signed char goal[BOARDMAX], int *move)
167 {
168   int dummy_move;
169   int result;
170only in patch2:
171unchanged:
172--- engine/persistent.c 12 Jun 2005 09:34:14 -0000      1.32
173+++ engine/persistent.c 7 Oct 2005 07:03:07 -0000
174@@ -971,7 +971,7 @@ store_persistent_breakin_cache(enum rout
175                               int str, Hash_data *goal_hash,
176                               int result, int move, int tactical_nodes,
177                               int breakin_node_limit,
178-                              char breakin_shadow[BOARDMAX])
179+                              signed char breakin_shadow[BOARDMAX])
180 {
181   store_persistent_cache(&breakin_cache, routine,
182                         str, NO_MOVE, NO_MOVE, EMPTY, goal_hash,
183only in patch2:
184unchanged:
185--- engine/breakin.c    12 Jun 2005 09:34:13 -0000      1.20
186+++ engine/breakin.c    7 Oct 2005 07:03:05 -0000
187@@ -64,7 +64,7 @@ static int num_break_ins;
188 
189 /* Adds all empty intersections that have two goal neighbors to the goal. */
190 static void
191-enlarge_goal(char goal[BOARDMAX])
192+enlarge_goal(signed char goal[BOARDMAX])
193 {
194   int pos;
195   for (pos = BOARDMIN; pos < BOARDMAX; pos++) {
196@@ -89,7 +89,8 @@ enlarge_goal(char goal[BOARDMAX])
197 static void
198 compute_smaller_goal(int owner, int color_to_move,
199                     const struct connection_data *conn,
200-                    const char goal[BOARDMAX], char smaller_goal[BOARDMAX])
201+                    const signed char goal[BOARDMAX],
202+                    signed char smaller_goal[BOARDMAX])
203 {
204   int k, j;
205   int own_stones_visited[BOARDMAX];
206@@ -160,9 +161,9 @@ compute_smaller_goal(int owner, int colo
207    * component.
208    */
209   if (owner == color_to_move) {
210-    char marked[BOARDMAX];
211+    signed char marked[BOARDMAX];
212     int sizes[BOARDMAX / 2];
213-    char mark = 0;
214+    signed char mark = 0;
215     int biggest_region = 1;
216     memset(marked, 0, BOARDMAX);
217     for (k = 0; k < conn->queue_end; k++) {
218@@ -216,13 +217,13 @@ compute_smaller_goal(int owner, int colo
219  * try again.
220  */
221 static int
222-break_in_goal_from_str(int str, char goal[BOARDMAX],
223+break_in_goal_from_str(int str, signed char goal[BOARDMAX],
224                      int *num_non_territory, int non_territory[BOARDMAX],
225                      int color_to_move, int info_pos)
226 {
227   int move = NO_MOVE;
228   int saved_move = NO_MOVE;
229-  char smaller_goal[BOARDMAX];
230+  signed char smaller_goal[BOARDMAX];
231   struct connection_data conn;
232 
233   /* When blocking off, we use a somewhat smaller goal area. */
234@@ -319,13 +320,13 @@ break_in_goal_from_str(int str, char goa
235 #define MAX_TRIES 10
236 
237 static void
238-break_in_goal(int color_to_move, int owner, char goal[BOARDMAX],
239+break_in_goal(int color_to_move, int owner, signed char goal[BOARDMAX],
240              struct influence_data *q, int store, int info_pos)
241 {
242   struct connection_data conn;
243   int k;
244   int intruder = OTHER_COLOR(owner);
245-  char used[BOARDMAX];
246+  signed char used[BOARDMAX];
247   int non_territory[BOARDMAX];
248   int num_non_territory = 0;
249   int candidate_strings[MAX_TRIES];
250@@ -415,7 +416,7 @@ break_territories(int color_to_move, str
251 
252   influence_get_territory_segmentation(q, &territories);
253   for (k = 1; k <= territories.number; k++) {
254-    char goal[BOARDMAX];
255+    signed char goal[BOARDMAX];
256     int pos;
257     int size = 0;
258