gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] matcher_check enhancement


From: Arend Bayer
Subject: [gnugo-devel] matcher_check enhancement
Date: Sun, 5 Sep 2004 22:59:58 +0200 (CEST)


The --color option allows to replay a game only for one color. (Requires
--noilcheck and --loadsgf.) Additionally, --verbose 2 now means "print board
when engines disagree (in replay mode)".

I don't know perl so I hope I didnt write non-sense...

Arend


Index: interface/gtp_examples/matcher_check
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/gtp_examples/matcher_check,v
retrieving revision 1.22
diff -u -p -r1.22 matcher_check
--- interface/gtp_examples/matcher_check        24 Jan 2004 04:04:56 -0000      
1.22
+++ interface/gtp_examples/matcher_check        5 Sep 2004 20:58:01 -0000
@@ -83,12 +83,13 @@ my $stable;
 my $pids;
 my $stable_move = "";
 my $noilcheck;
+my $color;
 
 my $helpstring = "
 
 Run with:
 
-twogtp --program \'<path to program> --mode gtp [program options]\' \\
+matchercheck --program \'<path to program> --mode gtp [program options]\' \\
        [matcher_check options]
 
 Possible matcher_check options:
@@ -104,6 +105,8 @@ Possible matcher_check options:
   --randseed <number>                    (sets the random seed)
   --stable \'<path to stable version> --mode gtp [program options]\'
   --noilcheck                            (turns off illegal transition checks)
+  --color <color>                        (only replay for color; has no effect
+                                          without --noilcheck and --loadsgf)
   --help                                  (show this)
 
 
@@ -122,6 +125,7 @@ GetOptions(
           "randseed=i"             => \$randseed,
           "stable=s"               => \$stable,
           "noilcheck"              => \$noilcheck,
+          "color=s"                => \$color,
            "help"                   => \$wanthelp,
 );
 
@@ -136,6 +140,12 @@ if (!$program) {
     warn "Defaulting program to: $program\n";
 }
 
+if (!defined($color) ne "" and (!defined($noilcheck) or !defined($loadfile))) {
+    print "Error: --color requires --noilcheck and --loadsgf";
+    exit;
+}
+
+
 # create FileHandles
 my $prog_in  = new FileHandle;         # stdin of program
 my $prog_out = new FileHandle;         # stdout of program
@@ -191,17 +201,23 @@ specify the number of moves to check wit
             $toplay = eat_one_line($stable_out);
             $toplay =~ s/^=//smg;
             $toplay =~ s/ //smg;
-            print $prog_in "genmove_$toplay\n";
-            print $stable_in "genmove_$toplay\n";
-            $move = eat_move($prog_out);
-            $stable_move = eat_move($stable_out);
-            if ($move ne $stable_move and defined ($stable)) {
-                print "At move $movenum, $toplay\:\n";
-                print "Test version played   $move\n";
-                print "Stable version played $stable_move\n";
-            } else {
-                print "$toplay plays $move\n" if $verbose;
-            }
+           if (!defined($color) or ($color eq $toplay)) {
+               print $prog_in "genmove_$toplay\n";
+               print $stable_in "genmove_$toplay\n";
+               $move = eat_move($prog_out);
+               $stable_move = eat_move($stable_out);
+               if ($move ne $stable_move and defined ($stable)) {
+                   print "At move $movenum, $toplay\:\n";
+                   print "Test version played   $move\n";
+                   print "Stable version played $stable_move\n";
+                   if ($verbose eq 2) {
+                       print $prog_in "showboard\n";
+                       print eat_response($prog_out);
+                   }
+               } else {
+                   print "$toplay plays $move\n" if $verbose;
+               }
+           }
         }
     }
 
@@ -316,6 +332,10 @@ while ($games > 0) {
            print "At move $movenum, $toplay\:\n";
            print "Test version played   $move\n";
            print "Stable version played $stable_move\n";
+           if ($verbose eq 2) {
+               print $prog_in "showboard\n";
+               print eat_response($prog_out);
+           }
        } else {
            print "$toplay plays $move\n" if $verbose;
        }
@@ -446,9 +466,25 @@ sub eat_no_response {
     }
 }
 
-sub eat_one_line {
+sub eat_response {
     my $h = shift;
+    my $response = "";
+# ignore empty lines
+    my $line = "";
+    while ($line eq "") {
+       chop($line = <$h>) or die "No response!";
+        $line =~ s/(\s|\n)*$//smg;
+    }
+    while ($line ne "") {
+       $response = "$response$line\n";
+       chop($line = <$h>) or die "No response!";
+        $line =~ s/(\s|\n)*$//smg;
+    }
+    return $response;
+}
 
+sub eat_one_line {
+    my $h = shift;
 # ignore empty lines
     my $line = "";
     while ($line eq "") {




reply via email to

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