gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] arend_3_3.3: 1st step reading.c cleanup


From: Arend Bayer
Subject: [gnugo-devel] arend_3_3.3: 1st step reading.c cleanup
Date: Fri, 17 May 2002 15:21:24 +0200 (CEST)

 - function naming consistency in reading.c

In reading.c with its load of helper function, almost all helper function
that just add candidate moves to the moves array are called .._moves.
This wasn't the case with edge_block and double_atari_chain2, and I suggest
to make this consistent.
Note that the first step in Gunnar's suggested reorganization of reading.c
would be to turn all helper functions into .._moves functions.

Arend


Index: engine/reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.61
diff -u -r1.61 reading.c
--- engine/reading.c    11 May 2002 15:40:11 -0000      1.61
+++ engine/reading.c    17 May 2002 08:49:35 -0000
@@ -126,8 +126,8 @@
                           int komaster, int kom_pos);
 static int draw_back(int str, int *move, int komaster, int kom_pos);
 static int edge_closing_backfill(int str, int apos, int *move);
-static void edge_block(int str, int apos, int moves[MAX_MOVES],
-                      int scores[MAX_MOVES], int *num_moves);
+static void edge_block_moves(int str, int apos, int moves[MAX_MOVES],
+                            int scores[MAX_MOVES], int *num_moves);
 static void propose_edge_moves(int str, int *libs, int liberties,
                               int moves[MAX_MOVES], int scores[MAX_MOVES],
                               int *num_moves, int color);
@@ -144,8 +144,8 @@
 static int superstring_breakchain(int str, int *move,
                                  int komaster, int kom_pos,
                                  int liberty_cap);
-static void double_atari_chain2(int str, int moves[MAX_MOVES],
-                               int scores[MAX_MOVES], int *num_moves);
+static void double_atari_chain2_moves(int str, int moves[MAX_MOVES],
+                                     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 simple_ladder_attack(int str, int *move, int komaster, int kom_pos);
@@ -2380,7 +2380,7 @@
        }

        /* Defend against double atari in the surrounding chain early. */
-       double_atari_chain2(bpos, moves, scores, num_moves);
+       double_atari_chain2_moves(bpos, moves, scores, num_moves);
       }
     }
   }
@@ -3151,8 +3151,12 @@
      string at (str) has. */
   if (libs == 1)
     result = attack1(str, &xpos, komaster, kom_pos);
-  else if (libs == 2)
-    result = attack2(str, &xpos, komaster, kom_pos);
+  else if (libs == 2) {
+    if (stackp > depth + 5)
+      result = simple_ladder_attack(str, &xpos, komaster, kom_pos);
+    else
+      result = attack2(str, &xpos, komaster, kom_pos);
+  }
   else if (libs == 3)
     result = attack3(str, &xpos, komaster, kom_pos);
   else if (libs == 4)
@@ -3460,7 +3464,7 @@
   /* If we can't make a direct atari, look for edge blocking moves. */
   if (!atari_possible)
     for (k = 0; k < 2; k++)
-      edge_block(str, libs[k], moves, scores, &num_moves);
+      edge_block_moves(str, libs[k], moves, scores, &num_moves);


   /* If one of the surrounding chains have only two liberties, which
@@ -3685,7 +3689,7 @@
   }

   /* Defend against double atari in the surrounding chain early. */
-  double_atari_chain2(str, moves, scores, &num_moves);
+  double_atari_chain2_moves(str, moves, scores, &num_moves);

   /* Get the three liberties of (str). */
   liberties = findlib(str, 3, libs);
@@ -3722,7 +3726,7 @@
 #endif

     /* Look for edge blocking moves. */
-    edge_block(str, apos, moves, scores, &num_moves);
+    edge_block_moves(str, apos, moves, scores, &num_moves);
   }

   /* Pick up some edge moves. */
@@ -3944,7 +3948,7 @@


   /* Defend against double atari in the surrounding chain early. */
-  double_atari_chain2(str, moves, scores, &num_moves);
+  double_atari_chain2_moves(str, moves, scores, &num_moves);

   /* Give a score bonus to the chain preserving moves. */
   for (k = 0; k < num_moves; k++)
@@ -3974,7 +3978,7 @@
       ADD_CANDIDATE_MOVE(xpos, 10, moves, scores, num_moves);

     /* Look for edge blocking moves. */
-    edge_block(str, apos, moves, scores, &num_moves);
+    edge_block_moves(str, apos, moves, scores, &num_moves);
   }

   /* Pick up some edge moves. */
@@ -4588,8 +4592,8 @@
  */

 static void
-edge_block(int str, int apos, int moves[MAX_MOVES], int scores[MAX_MOVES],
-          int *num_moves)
+edge_block_moves(int str, int apos, int moves[MAX_MOVES], int 
scores[MAX_MOVES],
+                int *num_moves)
 {
   int color = board[str];
   int other = OTHER_COLOR(color);
@@ -4687,8 +4691,8 @@
  */

 static void
-edge_block(int str, int apos, int moves[MAX_MOVES], int scores[MAX_MOVES],
-          int *num_moves)
+edge_block_moves(int str, int apos, int moves[MAX_MOVES], int 
scores[MAX_MOVES],
+                int *num_moves)
 {
   int color = board[str];
   int other = OTHER_COLOR(color);
@@ -5235,14 +5239,14 @@
 }

 /*
- * If str points to a group, double_atari_chain2() adds all moves
+ * If str points to a group, double_atari_chain2_moves() adds all moves
  * which make a double atari on some strings in the surrounding chain
  * to the (movei[], movej[]) arrays.
  */

 static void
-double_atari_chain2(int str, int moves[MAX_MOVES], int scores[MAX_MOVES],
-                   int *num_moves)
+double_atari_chain2_moves(int str, int moves[MAX_MOVES], int scores[MAX_MOVES],
+                         int *num_moves)
 {
   int r, k;
   int apos;
@@ -6559,6 +6563,14 @@
   str = find_origin(str);
   ASSERT1(IS_STONE(board[str]), str);
   ASSERT1(countlib(str) == 2, str);
+
+  /* Give up if we attacked depending on ko for too long. */
+  if (stackp > depth + 20 && komaster == OTHER_COLOR(board[str])) {
+    SGFTRACE(0, 0, NULL);
+    if (move)
+      *move = PASS_MOVE;
+    return 0;
+  }

   /* Get the two liberties of (str). */
   findlib(str, 2, libs);




reply via email to

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