gnugo-devel
[Top][All Lists]
Advanced

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

Re: [gnugo-devel] Inge's patch (fix)


From: Inge Wallin
Subject: Re: [gnugo-devel] Inge's patch (fix)
Date: Mon, 12 Nov 2001 11:46:32 +0100 (MET)

Dan wrote:
> Inge's patch is now in the CVS. For the record, the two
> spurious filllib results are:
> 
> 7 unexpected FAIL: Correct 'PASS', got 'T17'
> 15 unexpected FAIL: Correct 'P19', got 'R19'

There was indeed a bug. Filllib test 7 is fine on my machine after the
following patch.

The reason for the other failure, filllib 15, is that P19 and R19 both
are moves that according to value_move_reasons() does the following: 
"carry out threat or defend against threat".  They are both pure
threat moves and get exactly the same valuation except for a small
random contribution.  This random term decides wether P19 or R19 is
played and thus if the test succeeds or fails.

I suspect that one of Gunnars late changes may be responsible for this
so I will let him attack it first. If he plays the ball back to me I
will give it a try.

During the debugging of this I found it convenient if I could generate
moves for both colors from a given position so I implemented a
--genmove option with a color argument.

Summary:
 - bugfix in genmove_conservative()
 - bugfix in genmove()
 - new option --genmove <color>

        -Inge


diff -ur gnugo-iw/engine/genmove.c gnugo-iw2/engine/genmove.c
--- gnugo-iw/engine/genmove.c   Mon Nov 12 11:21:00 2001
+++ gnugo-iw2/engine/genmove.c  Mon Nov 12 12:30:17 2001
@@ -242,7 +242,7 @@
   int move;
   int retval;
 
-  retval = do_genmove(&move, color, 0.4);
+  retval = do_genmove(&move, color, 0.0);
 
   if (i) *i = I(move);
   if (j) *j = J(move);
@@ -407,7 +407,7 @@
   if (val < 0.0 
       && fill_liberty(move, color)) {
     val = 1.0;
-    TRACE("Filling a liberty at %1m\n", move);
+    TRACE("Filling a liberty at %1m\n", *move);
     move_considered(I(*move), J(*move), val);
     time_report(1, "fill liberty", -1, -1, 1.0);
   }
diff -ur gnugo-iw/interface/interface.h gnugo-iw2/interface/interface.h
--- gnugo-iw/interface/interface.h      Sat Nov 10 15:40:31 2001
+++ gnugo-iw2/interface/interface.h     Mon Nov 12 11:49:19 2001
@@ -45,7 +45,8 @@
 void play_replay(SGFNode *sgf_head, int color_to_test);
 
 void load_and_analyze_sgf_file(SGFNode *head, Gameinfo *gameinfo,
-                              const char *untilstr, int benchmark);
+                              const char *untilstr, int benchmark, 
+                              int to_move);
 void load_and_score_sgf_file(SGFTree *tree, Gameinfo *gameinfo,
                             const char *untilstr);
 
diff -ur gnugo-iw/interface/main.c gnugo-iw2/interface/main.c
--- gnugo-iw/interface/main.c   Sat Nov 10 15:40:31 2001
+++ gnugo-iw2/interface/main.c  Mon Nov 12 11:49:33 2001
@@ -87,6 +87,7 @@
       OPT_DECIDE_SEMEAI,
       OPT_DECIDE_POSITION,
       OPT_DECIDE_EYE,
+      OPT_GENMOVE,
       OPT_BRANCH_DEPTH,
       OPT_BACKFILL2_DEPTH,
       OPT_SUPERSTRING_DEPTH,
@@ -204,6 +205,7 @@
   {"decide-semeai",  required_argument, 0, OPT_DECIDE_SEMEAI},
   {"decide-position", no_argument,       0, OPT_DECIDE_POSITION},
   {"decide-eye",     required_argument, 0, OPT_DECIDE_EYE},
+  {"genmove",        required_argument, 0, OPT_GENMOVE},
   {"life",           no_argument,       0, OPT_LIFE},
   {"life-eyesize",   required_argument, 0, OPT_LIFE_EYESIZE},
   {"nofusekidb",     no_argument,       0, OPT_NOFUSEKIDB},
@@ -249,6 +251,7 @@
   float komi = 0.0;
   FILE *gtp_input_FILE;
   int orientation = 0;
+  int to_move = EMPTY;
   
   int seed = 0;      /* If seed is zero, GNU Go will play a different game 
                        each time. If it is set using -r, GNU Go will play the
@@ -502,6 +505,20 @@
        playmode = MODE_DECIDE_EYE;
        break;
        
+      case OPT_GENMOVE:
+       if (strcmp(gg_optarg, "white") == 0) 
+         to_move = WHITE;
+       else if (strcmp(gg_optarg, "black") == 0)
+         to_move = BLACK;
+       else {
+         fprintf(stderr, "Invalid color for genmove: %s\n", gg_optarg);
+         fprintf(stderr, "Try `gnugo --help' for more information.\n");
+         
+         exit(EXIT_FAILURE);
+       }
+       playmode = MODE_LOAD_AND_ANALYZE;
+       break;
+       
       case OPT_BRANCH_DEPTH:
        mandated_branch_depth = atoi(gg_optarg);
        break;
@@ -754,7 +771,7 @@
       exit(EXIT_FAILURE);
     }
     load_and_analyze_sgf_file(sgftree.root, &gameinfo, untilstring,
-                             benchmark);
+                             benchmark, to_move);
     break;
     
   case MODE_LOAD_AND_SCORE:
@@ -1137,6 +1154,7 @@
        --decide-dragon <dragon>  can this dragon live? (try with -o or -t)\n\
        --decide-position         evaluate all dragons (try with -o or -t)\n\
        --decide-eye <string>     evaluate the eye\n\
+       --genmove <color>         generate a move for color\n\
        --life <eyesize>          use eye reading code\n\
        --nofusekidb              turn off fuseki database\n\
        --nofuseki                turn off fuseki moves entirely\n\
diff -ur gnugo-iw/interface/play_solo.c gnugo-iw2/interface/play_solo.c
--- gnugo-iw/interface/play_solo.c      Sat Nov 10 15:40:32 2001
+++ gnugo-iw2/interface/play_solo.c     Mon Nov 12 12:05:34 2001
@@ -137,7 +137,7 @@
 
 void 
 load_and_analyze_sgf_file(SGFNode *head, Gameinfo *gameinfo, 
-                         const char *untilstr, int benchmark)
+                         const char *untilstr, int benchmark, int to_move)
 {
   int i, j;
   int next;
@@ -149,7 +149,9 @@
   gameinfo_load_sgfheader(gameinfo, head); 
   sgffile_write_gameinfo(gameinfo, "load and analyze");
   next = gameinfo_play_sgftree(gameinfo, head, untilstr);
-  
+  if (to_move != EMPTY)
+    next = to_move;
+
   if (benchmark) {
     for (r = 0; r < benchmark; ++r) {
       genmove(&i, &j, next);



reply via email to

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