gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] Random seed


From: bump
Subject: [gnugo-devel] Random seed
Date: Mon, 8 Apr 2002 12:22:08 -0700

When you run twogtp the random seed never changes. I had
been under the impression that a new random seed was
generated for each game, but this is not the case.

You can confirm this with the following patch to twogtp.
--verbose 3 will show that the random seed is the same in
each game.

This being the case, shouldn't GNU Go make the same moves?

Dan

Index: interface/gtp_examples/twogtp
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/gtp_examples/twogtp,v
retrieving revision 1.4
diff -u -r1.4 twogtp
--- interface/gtp_examples/twogtp       8 Mar 2002 03:11:00 -0000       1.4
+++ interface/gtp_examples/twogtp       8 Apr 2002 19:20:02 -0000
@@ -49,9 +49,11 @@
     my ($repchar, $result) = split(' ', $line, 2);
     if ($repchar eq '=') {
     } elsif ($repchar eq '?') {
-       die "GTP error on executing $cmd:\n $line";
+       print "GTP error on executing $cmd:\n $line";
+       return "ERROR";
     } else {
-       die "Unexpected response on executing $cmd:\n $line";
+       print "Unexpected response on executing $cmd:\n $line";
+       return "ERROR";
     }
     $line = <$hout>;
     print STDERR $line if ($debug);
@@ -177,6 +179,14 @@
     GTP::exec_cmd(${$self->in}, ${$self->out}, "showboard");
 }
 
+sub get_random_seed {
+    my $self = shift;
+
+    my $ret = GTP::exec_cmd(${$self->in}, ${$self->out}, "get_random_seed");
+    my ($result, $rest) = split(' ', $ret, 2);
+    return $result;
+}
+
 sub score {
     my $self = shift;
 
@@ -258,6 +268,8 @@
 }
 
 
+
+
 sub play {
 
     my $self = shift;
@@ -308,9 +320,14 @@
            print "Black plays $move\n" if $verbose;
            $pass = ($move =~ /PASS/i) ? $pass + 1 : 0;
            $self->white->black($move) unless ($move =~ /PASS/);
-           if ($verbose > 1) {
+           if ($verbose == 3) {
+               my $black_seed = $self->black->get_random_seed;
+               printf "Black seed $black_seed\n";
+           }
+           if ($verbose == 2) {
                $self->white->showboard;
            }
+
            $toplay = 'W';
 
         } else {
@@ -324,7 +341,11 @@
            print "White plays $move\n" if $verbose;
            $pass = ($move =~ /PASS/i) ? $pass + 1 : 0;
            $self->black->white($move) unless ($move =~ /PASS/);
-           if ($verbose > 1) {
+           if ($verbose == 3) {
+               my $white_seed = $self->white->get_random_seed;
+               printf "White seed $white_seed\n";
+           }
+           if ($verbose == 2) {
                $self->black->showboard;
            }
            $toplay = 'B';
@@ -334,8 +355,13 @@
 
     my $resultw = $self->white->estimate_score;
     my $resultb = $self->black->estimate_score;
-    print "Result according to W: $resultw\n";
-    print "Result according to B: $resultb\n";
+    if ($resultb eq $resultw) {
+       print "Result: $resultw\n";
+    }
+    else {
+       print "Result according to W: $resultw\n";
+       print "****** according to B: $resultb\n";
+    }
     $self->result->resultw($resultw);
     $self->result->resultb($resultb);
     $self->writesgf($sgffile) if defined $sgffile;
@@ -453,7 +479,12 @@
 my $i=0;
 for my $r (@results) {
     $i++;
-    printf "Game $i: %s %s\n", $r->resultb, $r->resultw;
+    if ($r->resultb eq $r->resultw) {
+       printf "Game $i: %s\n", $r->resultw;    
+    }
+    else {
+       printf "Game $i: %s %s\n", $r->resultb, $r->resultw;
+    }
 }
 
 $white_pl->quit;



reply via email to

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