gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] use of LOSE in reading.c


From: Teun Burgers
Subject: [gnugo-devel] use of LOSE in reading.c
Date: Wed, 18 Sep 2002 21:37:40 +0200

This patch uses LOSE instead of 0 for acode
and dcode in reading.c. I think it is better
style to use LOSE than 0 since 0 can mean
just about everything.

- use LOSE instead of 0 in reading.c

Teun
Index: reading.c
===================================================================
RCS file: /cvsroot/gnugo/gnugo/engine/reading.c,v
retrieving revision 1.70
diff -u -r1.70 reading.c
--- reading.c   11 Sep 2002 15:33:17 -0000      1.70
+++ reading.c   18 Sep 2002 19:33:43 -0000
@@ -404,13 +404,13 @@
                  int *attack_code, int *attack_point,
                  int *defend_code, int *defense_point)
 {
-  int acode = 0;
+  int acode = LOSE;
   int apos = NO_MOVE;
-  int dcode = 0;
+  int dcode = LOSE;
   int dpos = NO_MOVE;
 
   acode = attack(str, &apos);
-  if (acode != 0) {
+  if (acode != LOSE) {
     dcode = find_defense(str, &dpos);
     
     /* If find_defense() says the string is safe as is, we believe
@@ -418,7 +418,7 @@
      * incorrect, but we can't easily find a defense point to return.
      */
     if (dcode == WIN && dpos == NO_MOVE) {
-      acode = 0;
+      acode = LOSE;
       apos = NO_MOVE;
     }
   }
@@ -432,7 +432,7 @@
   if (defense_point)
     *defense_point = dpos;
 
-  return acode != 0 && dcode != 0;
+  return acode != LOSE && dcode != LOSE;
 }
 
 
@@ -529,24 +529,24 @@
   int b_threatened = 0;
   int a_savepos;
   int b_savepos;
-  int acode = 0;
-  int dcode = 0;
+  int acode = LOSE;
+  int dcode = LOSE;
   
   int color = board[astr];
   ASSERT1(IS_STONE(color) , astr);
   ASSERT1(color == board[bstr], bstr);
 
   attack_and_defend(astr, &acode, NULL, &dcode, &a_savepos);
-  if (acode != 0) {
+  if (acode != LOSE) {
     a_threatened = 1;
-    if (dcode == 0)
+    if (dcode == LOSE)
       return 0; /* (astr) already lost */
   }
   
   attack_and_defend(bstr, &acode, NULL, &dcode, &b_savepos);
-  if (acode != 0) {
+  if (acode != LOSE) {
     b_threatened = 1;
-    if (dcode == 0)
+    if (dcode == LOSE)
       return 0; /* (bstr) already lost */
   }
 
@@ -937,7 +937,7 @@
       /* Try to threaten on the liberty. */
       if (trymove(aa, other, "attack_threats-A", str, EMPTY, NO_MOVE)) {
        int acode = attack(str, NULL);
-       if (acode != 0)
+       if (acode != LOSE)
         movelist_change_point(aa, acode, max_points, moves, codes);
        popgo();
       }
@@ -953,7 +953,7 @@
 
        if (trymove(bb, other, "attack_threats-B", str, EMPTY, NO_MOVE)) {
          int acode = attack(str, NULL);
-         if (acode != 0)
+         if (acode != LOSE)
           movelist_change_point(bb, acode, max_points, moves, codes);
          popgo();
        }
@@ -970,7 +970,7 @@
     int dcode;
 
     attack_and_defend(adjs[k], &acode, NULL, &dcode, &dd);
-    if (acode == 0 || dcode == 0)
+    if (acode == LOSE || dcode == LOSE)
       continue;
 
     /* The strange code using r == -1 below is only avoid duplication
@@ -999,7 +999,7 @@
          acode = WIN;
        else
          acode = attack(str, NULL);
-       if (acode != 0)
+       if (acode != LOSE)
          movelist_change_point(bb, acode, max_points, moves, codes);
        popgo();
       }
@@ -1030,7 +1030,7 @@
 do_find_defense(int str, int *move, int komaster, int kom_pos)
 {
   int xpos;
-  int dcode = 0;
+  int dcode = LOSE;
   int liberties;
   int found_read_result;
   Read_result *read_result = NULL;
@@ -1088,7 +1088,7 @@
   else if (liberties == 4)
     dcode = defend4(str, &xpos, komaster, kom_pos);
 
-  if (dcode) {
+  if (dcode != LOSE) {
     RTRACE("saving move for %1m found at %1m!\n", str, xpos);
     READ_RETURN(read_result, move, xpos, dcode);
   }
@@ -1953,7 +1953,7 @@
        if (trymove(fpos, color, "special_rescue3", str, komaster, kom_pos)) {
          int acode = do_attack(str, NULL, komaster, kom_pos);
          if (acode != WIN) {
-           if (acode == 0) {
+           if (acode == LOSE) {
              popgo();
              *move = fpos;
              return WIN;
@@ -2039,7 +2039,7 @@
        if (trymove(cpos, color, "special_rescue4", str, komaster, kom_pos)) {
          int acode = do_attack(str, NULL, komaster, kom_pos);
          if (acode != WIN) {
-           if (acode == 0) {
+           if (acode == LOSE) {
              popgo();
              *move = cpos;
              return WIN;
@@ -3047,7 +3047,7 @@
            && trymove(apos, other, "attack1-C", str, komaster, kom_pos)) {
          int dcode = do_find_defense(str, NULL, komaster, kom_pos);
          if (dcode != WIN && do_attack(str, NULL, komaster, kom_pos)) {
-           if (dcode == 0) {
+           if (dcode == LOSE) {
              popgo();
              SGFTRACE(apos, WIN, "backfilling");
              *move = apos;
@@ -3353,7 +3353,7 @@
   int liberties;
   int libs[3];
   int r;
-  int dcode = 0;
+  int dcode = LOSE;
   int k;
   struct reading_moves moves;
   int savemove = 0;
@@ -3588,7 +3588,7 @@
   int liberties;
   int libs[4];
   int adj, adjs[MAXCHAIN];
-  int dcode = 0;
+  int dcode = LOSE;
   struct reading_moves moves;
   int savemove = 0;
   int savecode = 0;
@@ -3737,7 +3737,7 @@
     int dcode = do_find_defense(str, NULL, komaster, kom_pos);
     popgo();
     switch (dcode) {
-    case 0:
+    case LOSE:
       RTRACE("cap2 succeeded!\n");
       return WIN;
       break;
@@ -3843,7 +3843,7 @@
          && trymove(xpos, other, "special_attack2", str, komaster, kom_pos)) {
        int dcode = do_find_defense(str, NULL, komaster, kom_pos);
        if (dcode != WIN && do_attack(str, NULL, komaster, kom_pos)) {
-         if (dcode == 0) {
+         if (dcode == LOSE) {
            popgo();
            *move = xpos;
            return WIN;
@@ -3930,7 +3930,7 @@
          && trymove(ypos, color, "special_attack3-B", str,
                     komaster, kom_pos)) {
        acode = do_attack(str, NULL, komaster, kom_pos);
-       if (acode == 0) {
+       if (acode == LOSE) {
          popgo();
          popgo();
          continue;
@@ -3942,7 +3942,7 @@
     
     dcode = do_find_defense(str, NULL, komaster, kom_pos);
     if (dcode != WIN && do_attack(str, NULL, komaster, kom_pos)) {
-      if (dcode == 0) {
+      if (dcode == LOSE) {
        popgo();
        *move = xpos;
        return WIN;
@@ -4056,7 +4056,7 @@
          dcode = do_find_defense(str, NULL, komaster, kom_pos);
 
          if (dcode != WIN && do_attack(str, NULL, komaster, kom_pos)) {
-           if (dcode == 0) {
+           if (dcode == LOSE) {
              popgo();
              *move = dpos;
              return WIN;
@@ -4115,7 +4115,7 @@
                    komaster, kom_pos)) {
          int dcode = do_find_defense(str, NULL, komaster, kom_pos);
          if (dcode != WIN && do_attack(str, NULL, komaster, kom_pos)) {
-           if (dcode == 0) {
+           if (dcode == LOSE) {
              popgo();
              *move = libs[k];
              return WIN;
@@ -4703,7 +4703,7 @@
     /* If we just filled our own liberty we back out now */
     if (countlib(str) >= liberties) {
       int acode = do_attack(str, NULL, komaster, kom_pos);
-      if (acode == 0) {
+      if (acode == LOSE) {
        *move = moves[v];
        popgo();
        SGFTRACE(moves[v], WIN, "attack defended");
@@ -4761,7 +4761,7 @@
                         &ko_move, savecode == 0 && stackp <= ko_depth)) {
       if (!ko_move) {
        int acode = do_attack(str, NULL, new_komaster, new_kom_pos);
-       if (acode == 0) {
+       if (acode == LOSE) {
          popgo();
          *move = apos;
          SGFTRACE(apos, WIN, "attack defended");
@@ -4929,7 +4929,7 @@
          acode = restricted_attack2(str, NULL, color, xpos,
                                     num_forbidden_moves, forbidden_moves);
        popgo();
-       if (acode == 0) {
+       if (acode == LOSE) {
          SGFTRACE(xpos, WIN, "defense effective");
          if (move)
            *move = xpos;
@@ -5489,10 +5489,10 @@
   /* Otherwise calculate the value... */
   if (trymove(move, color, "safe_move-A", 0, EMPTY, 0)) {
     int acode = attack(move, NULL);
-    if (acode == 0)
+    if (acode == LOSE)
       safe = WIN;
     else if (acode == WIN)
-      safe = 0;
+      safe = LOSE;
     else if (acode == KO_A)
       safe = KO_B;
     else if (acode == KO_B)
@@ -6146,7 +6146,7 @@
       if (!ko_move) {
        dcode = simple_ladder_defend(str, NULL, new_komaster, new_kom_pos);
        if (dcode != WIN) {
-         if (dcode == 0) {
+         if (dcode == LOSE) {
            popgo();
            SGFTRACE(apos, WIN, "attack effective");
            if (move)
@@ -6211,7 +6211,7 @@
       int acode;
       int new_libs = countlib(str);
       if (new_libs > 2)
-       acode = 0;
+       acode = LOSE;
       else if (new_libs < 2)
        acode = WIN;
       else

reply via email to

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