gnugo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gnugo-devel] Tristan's patch


From: Gunnar Farneback
Subject: Re: [gnugo-devel] Tristan's patch
Date: Sat, 06 Oct 2001 21:27:57 +0200
User-agent: EMH/1.14.1 SEMI/1.14.3 (Ushinoya) FLIM/1.14.2 (Yagi-Nishiguchi) APEL/10.3 Emacs/20.7 (sparc-sun-solaris2.7) (with unibyte mode)

Dan wrote:
> I've added Tristan's new file to the CVS. I renamed it
> engine/readconnect.c. I took the liberty of changing
> depth to connect_depth throughout the file in order
> to avoid a conflict with global with the same name.
> 
> The file compiles and link.

But it doesn't link in any meaningful way. Since no function in it is
called from outside it's most likely that it's in fact not linked into
the GNU Go binary at all. Also there are some significant warnings
indicating that it wouldn't link if it was called from outside itself.
This patch, which I've already checked in to the CVS, improves the
situation by

* making most functions in readconnect.c static
* moving the declarations of recursive_connect() and
  recursive_disconnect() to liberty.h
* making naive_ladder() in reading.c non-static
* fixing most of the warnings in readconnect.c

Notice that I've added a dummy intersection_array() function since
this was called but not defined.

I'll try to add gtp functions to test the code next.

/Gunnar

Index: ChangeLog
===================================================================
RCS file: /cvsroot/gnugo/gnugo/ChangeLog,v
retrieving revision 1.36
diff -u -r1.36 ChangeLog
--- ChangeLog   2001/10/06 00:42:39     1.36
+++ ChangeLog   2001/10/06 19:14:35
@@ -2,6 +2,9 @@
 -- ChangeLog
 -------------------------------------------------------------------------
 
+- naive_ladder() made global
+- warnings eliminated from readconnect.c
+- most functions in readconnect.c made static
 - add point reorientation functions
 - add some comments to dfa.c
 - bugfix and cleanup in naive_ladder()
Index: engine/liberty.h
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/liberty.h,v
retrieving revision 1.25
diff -u -r1.25 liberty.h
--- engine/liberty.h    2001/10/06 02:12:20     1.25
+++ engine/liberty.h    2001/10/06 19:14:36
@@ -245,11 +245,17 @@
 int attack_either(int astr, int bstr);
 int defend_both(int astr, int bstr);
 int break_through(int apos, int bpos, int cpos);
+int naive_ladder(int str, int *move);
 #define MOVE_ORDERING_PARAMETERS 67
 void tune_move_ordering(int params[MOVE_ORDERING_PARAMETERS]);
 void draw_reading_shadow(void);
 void purge_persistent_reading_cache(void);
 void reading_hotspots(float values[MAX_BOARD][MAX_BOARD]);
+
+/* readconnect.c */
+int recursive_connect(int str1, int str2, int connect_depth);
+int recursive_disconnect(int str1, int str2, int connect_depth);
+
 
 int liberty_of_string(int pos, int str);
 int neighbor_of_string(int pos, int str);
Index: engine/readconnect.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/readconnect.c,v
retrieving revision 1.1
diff -u -r1.1 readconnect.c
--- engine/readconnect.c        2001/10/06 02:12:20     1.1
+++ engine/readconnect.c        2001/10/06 19:14:36
@@ -31,28 +31,31 @@
 /* Size of array where candidate moves are stored. */
 #define MAX_MOVES 362
 
-int add_array(int *array, int elt);
-int intersection_array(int *array1, int *array2);
-int snapback(int str);
-int connection_one_move(int str1, int str2);
-int prevent_connection_one_move(int *moves, int str1, int str2);
-int connected_one_move(int str1, int str2);
-int moves_to_connect_in_two_moves(int *moves, int str1, int str2);
-int connection_two_moves(int str1, int str2);
-int prevent_connection_two_moves(int *moves, int str1, int str2);
-int connected_two_moves(int str1, int str2);
-int moves_to_connect_in_three_moves(int *moves, int str1, int str2);
-int simple_connection_three_moves(int str1, int str2);
-int prevent_simple_connection_three_moves(int *moves, int str1, int str2);
-int quiescence_connect(int str1, int str2);
-int recursive_connect(int str1,int str2, int connect_depth);
-int recursive_disconnect(int str1,int str2, int connect_depth);
-int capture_one_move(int str);
-int prevent_capture_one_move(int *moves, int str1);
+static int add_array(int *array, int elt);
+static int intersection_array(int *array1, int *array2);
+static int snapback(int str);
+static int connection_one_move(int str1, int str2);
+static int prevent_connection_one_move(int *moves, int str1, int str2);
+static int connected_one_move(int str1, int str2);
+static int moves_to_connect_in_two_moves(int *moves, int str1, int str2);
+static int connection_two_moves(int str1, int str2);
+static int prevent_connection_two_moves(int *moves, int str1, int str2);
+#if 0
+static int connected_two_moves(int str1, int str2);
+#endif
+static int moves_to_connect_in_three_moves(int *moves, int str1, int str2);
+#if 0
+static int simple_connection_three_moves(int str1, int str2);
+static int prevent_simple_connection_three_moves(int *moves,
+                                                int str1, int str2);
+#endif
+static int quiescence_connect(int str1, int str2);
+static int capture_one_move(int str);
+static int prevent_capture_one_move(int *moves, int str1);
 
 int nodes_connect=0,max_nodes_connect=500,max_connect_depth=64;
 
-int add_array (int *array, int elt) {
+static int add_array (int *array, int elt) {
   int r, add = 1;
   
   for (r = 1; ((r < array[0] + 1) && add); r++)
@@ -65,9 +68,20 @@
   return add;
 }
 
+/* FIXME: Added this function to avoid compiler warning. Obviously it
+ * needs to do something also. /gunnar
+ */
+static int
+intersection_array(int *array1, int *array2)
+{
+  UNUSED(array1);
+  UNUSED(array2);
+  return 0;
+}
+
 /* verifies that capturing the stone at str is not a snapback */
 
-int snapback (int str) {
+static int snapback (int str) {
   int stones, liberties, libs[MAXLIBS];
 
   /* if more than one stone captured, not a snapback */
@@ -91,7 +105,7 @@
   return 0;
 }
 
-int connection_one_move(int str1, int str2) {
+static int connection_one_move(int str1, int str2) {
   int r;
   int liberties, libs[MAXLIBS];
   int adj, adjs[MAXCHAIN];
@@ -112,7 +126,7 @@
   return 0;
 }
 
-int prevent_connection_one_move (int *moves, int str1, int str2) {
+static int prevent_connection_one_move (int *moves, int str1, int str2) {
   int r, s, res=0;
   int liberties, libs[MAXLIBS];
   int adj, adjs[MAXCHAIN];
@@ -145,12 +159,12 @@
   return 0;
 }
 
-int connected_one_move (int str1, int str2) {
+static int connected_one_move (int str1, int str2) {
   int r, res=0;
   int moves[MAX_MOVES];
   
   moves[0] = 0;
-  if (prevent_connection_in_one_move(moves, str1, str2)) {
+  if (prevent_connection_one_move(moves, str1, str2)) {
     res = 1;
     for (r = 1; ((r < moves[0] + 1) && res); r++) {
       if (trymove(moves[r], OTHER_COLOR(board[str1]), NULL, 0, EMPTY, 0)) {
@@ -163,8 +177,8 @@
   return res;
 }
 
-int moves_to_connect_in_two_moves (int *moves, int str1, int str2) {
-  int r, s, res=0, common_adj_liberty;
+static int moves_to_connect_in_two_moves (int *moves, int str1, int str2) {
+  int r, s, common_adj_liberty;
   int liberties, libs[MAXLIBS];
   int adj, adjs[MAXCHAIN];
   int adjadj, adjadjs[MAXCHAIN];
@@ -229,7 +243,7 @@
   return 0;
 }
   
-int connection_two_moves (int str1, int str2) {
+static int connection_two_moves (int str1, int str2) {
   int r, res = 0, moves[MAX_MOVES];
   
   if (moves_to_connect_in_two_moves(moves, str1, str2))
@@ -244,17 +258,18 @@
   return res;
 }
 
-int moves_to_prevent_connection_in_two_moves (int *moves, int str1, int str2) {
+static int moves_to_prevent_connection_in_two_moves (int *moves,
+                                                    int str1, int str2) {
   if (moves_to_connect_in_two_moves(moves, str1, str2))
     return 1;
   return 0;
 }
 
-int prevent_connection_two_moves (int *moves, int str1, int str2) {
+static int prevent_connection_two_moves (int *moves, int str1, int str2) {
   int r, res=0;
   int possible_moves[MAX_MOVES];
   
-  if (connection_in_two_moves(str1, str2)) {
+  if (connection_two_moves(str1, str2)) {
     res=1;
     moves_to_prevent_connection_in_two_moves(possible_moves, str1, str2);
     for (r = 1; r < possible_moves[0] + 1; r++) {
@@ -270,13 +285,13 @@
   return res;
 }
 
-int moves_to_connect_in_three_moves (int *moves, int str1, int str2) {
+static int moves_to_connect_in_three_moves (int *moves, int str1, int str2) {
   if (moves_to_connect_in_two_moves(moves, str1, str2))
     return 1;
   return 0;
 }
 
-int quiescence_connect(int str1, int str2) {
+static int quiescence_connect(int str1, int str2) {
   int r;
   int liberties, libs[MAXLIBS];
   int adj, adjs[MAXCHAIN];
@@ -391,13 +406,13 @@
   return res;
 }
  
-int capture_one_move (int str) {
+static int capture_one_move (int str) {
   if (countlib(str) == 1)
     return 1;
   return 0;
 }
 
-int prevent_capture_one_move(int *moves, int str1) {
+static int prevent_capture_one_move(int *moves, int str1) {
   int r, res=0;
   int liberties, libs[MAXLIBS];
   int adj, adjs[MAXCHAIN];
Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.18
diff -u -r1.18 reading.c
--- engine/reading.c    2001/10/05 19:55:41     1.18
+++ engine/reading.c    2001/10/06 19:14:39
@@ -131,7 +131,6 @@
                                int scores[MAX_MOVES], int *num_moves);
 static void order_moves(int str, int num_moves, int *moves,
                        int *scores, int color, const char *funcname);
-static int naive_ladder(int str, int *move);
 static int naive_ladder_defense(int str, int apos, int bpos,
                                int color, int other);
 static int naive_ladder_break_through(int str, int apos, int color, int other);
@@ -6260,7 +6259,7 @@
  *        return codes.
  */
 
-static int
+int
 naive_ladder(int str, int *move)
 {
   int color = board[str];



reply via email to

[Prev in Thread] Current Thread [Next in Thread]