hi

hemm, i have a fix for my fix <:o)
now it writes  valid sgf file, not broken at one handi.
(i checked with http://www.red-bean.com/sgf/ tools, and read the spec).

Alain
--- ./interface/gtp_examples/twogtp.pike.orig	2006-01-27 16:49:24.000000000 +0100
+++ ./interface/gtp_examples/twogtp.pike	2006-02-12 12:08:20.000000000 +0100
@@ -293,7 +293,7 @@
   set_handicap(int handicap, string handicap_mode,
 	       GtpServer opponent, GtpServer arbiter)
   {
-    if (handicap == 0)
+    if (handicap <= 1)
       return ({});
 
     if (handicap_mode == "free") {
@@ -700,10 +700,10 @@
     if (arbiter)
       arbiter->set_komi(komi);
 
-    black_to_play = (handicap == 0);
+    black_to_play = (handicap <= 1);
     sgf_header = sprintf("(;\nGM[1]FF[4]\nSZ[%d]HA[%d]KM[%.1f]\n",
 			 board_size, handicap, komi);
-    if (handicap)
+    if (handicap>=2)
       sgf_header += "AB" + arrange_values_nicely(stones, "");
   }
 
@@ -996,10 +996,13 @@
   int disagreed_games = 0;
   int last_streak = 0;
   int last_to_win = '0';
+  float km = komi;
   array(array(string)) results = ({});
 
   for (int k = skip_games; k < skip_games + num_games; k++) {
-    game->start_new_game(board_size, handicap, handicap_mode, komi);
+    km = handicap ? 0.5 : komi;
+
+    game->start_new_game(board_size, handicap, handicap_mode, km);
     array(string) result
       = game->play(sgf_base ? sprintf("%s%03d.sgf", sgf_base, k + 1) : 0);
 
@@ -1040,25 +1043,18 @@
       if (result[0][0] == 'W') {
 	if (handicap_mode == "free"
 	    || handicap < maximal_fixed_handicap(board_size)) {
-	  if (++handicap == 1)
-	    handicap = 2;
+	  ++handicap;
 	  write("White wins too often. Increasing handicap to %d.\n", handicap);
 	}
       }
       else {
 	if (handicap == 0) {
-	  handicap = 2;
-	  if (handicap_mode == "fixed")
-	    handicap = min(maximal_fixed_handicap(board_size), 2);
 	  game->swap_engines();
-	  write("Black looks stronger than white. Swapping colors and setting handicap to %d.\n",
-		handicap);
+	  write("Black looks stronger than white. Swapping colors.\n");
 	}
 	else {
-	  if (--handicap == 1)
-	    handicap = 0;
-	  write("Black wins too often. Decreasing handicap to %d.\n",
-		handicap);
+	  --handicap;
+	  write("Black wins too often. Decreasing handicap to %d.\n", handicap);
 	}
       }
 
@@ -1159,7 +1155,8 @@
   "`--white' and `--black' options are mandatory.\n\n"
   "Options:\n"
   "  -w, --white=COMMAND_LINE\n"
-  "  -b, --black=COMMAND_LINE      command lines to run the two engines with.\n\n"
+  "  -b, --black=COMMAND_LINE      command lines to run the two engines with.\n"
+  "		eg: --black=\"gnugo --mode gtp --large-scale\" \n\n"
   "  -A, --arbiter=COMMAND_LINE    command line to run arbiter--program that will\n"
   "                                score disputed games--with.\n"
   "      --help                    display this help and exit.\n"
@@ -1372,11 +1369,6 @@
       handicap_mode = "free";
     }
 
-    if (handicap == 1) {
-      werror("Warning: handicap 1 is not allowed, falling back on handicap 0.\n");
-      handicap = 0;
-    }
-
     int adjust_handicap = (int) Getopt.find_option(argv, "a", "adjust-handicap",
 						   UNDEFINED, "0");
     adjust_handicap = max(adjust_handicap, 0);
_______________________________________________
gnugo-devel mailing list
gnugo-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/gnugo-devel

Reply via email to