gnugo-devel
[Top][All Lists]
Advanced

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

[gnugo-devel] twogtp_1_28.1: crash handling in twogtp


From: Arend Bayer
Subject: [gnugo-devel] twogtp_1_28.1: crash handling in twogtp
Date: Thu, 7 Mar 2002 15:40:00 -0500 (EST)

 - twogtp writes sgffile when no response from engine

On Wed, 6 Mar 2002, Daniel Bump wrote:
> > Unfortunately, twogtp does not seem to
> > save the sgf-file if a crash occurs.
> > Maybe this should be considered a FIXME of twogtp?
>
> It's not just a fixme, it's an urgent fixme. During the preparations

The patch below does this. I am still not an expert with perl
(Btw, thanks to all who helped me with my problems with Trevor's
regression scripts! I will upgrade my perl soon.), but the patch seems
to work. It only covers the case where the engine does not give a response,
but that is probably the most relevant one.

Arend


Index: interface/gtp_examples/twogtp
===================================================================
RCS file: /cvsroot/gnugo/gnugo/interface/gtp_examples/twogtp,v
retrieving revision 1.3
diff -u -r1.3 twogtp
--- interface/gtp_examples/twogtp       6 Sep 2001 21:34:20 -0000       1.3
+++ interface/gtp_examples/twogtp       7 Mar 2002 20:27:35 -0000
@@ -44,7 +44,7 @@
     my $line;
     $line = <$hout>;
     print STDERR $line if ($debug);
-    die "No response!\n" unless (defined $line);
+    return "XXX" unless (defined $line);
     $line =~ s/\s*$//;
     my ($repchar, $result) = split(' ', $line, 2);
     if ($repchar eq '=') {
@@ -257,6 +257,7 @@
     $handle->close;
 }

+
 sub play {

     my $self = shift;
@@ -299,6 +300,10 @@
        if ($toplay eq 'B') {

            $move = $self->black->genmove("black");
+           if ($move eq "XXX") {
+               $self->writesgf($sgffile) if defined $sgffile;
+               die "No response!";
+           }
            push @{$self->moves}, $move;
            print "Black plays $move\n" if $verbose;
            $pass = ($move =~ /PASS/i) ? $pass + 1 : 0;
@@ -311,6 +316,10 @@
         } else {

            $move = $self->white->genmove("white");
+           if ($move eq "XXX") {
+               $self->writesgf($sgffile) if defined $sgffile;
+               die "No response!";
+           }
            push @{$self->moves}, $move;
            print "White plays $move\n" if $verbose;
            $pass = ($move =~ /PASS/i) ? $pass + 1 : 0;




reply via email to

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