From 735a1fdd70dff089cb05df0834d68386ab3c3fe7 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Thu, 23 Feb 2012 16:48:36 +0100 Subject: [PATCH] tools/kgslog2gtp.pl: Tool for converting kgsGtp log to extended GTP stream --- tools/kgslog2gtp.pl | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 tools/kgslog2gtp.pl diff --git a/tools/kgslog2gtp.pl b/tools/kgslog2gtp.pl new file mode 100755 index 0000000..428af4a --- /dev/null +++ b/tools/kgslog2gtp.pl @@ -0,0 +1,30 @@ +#!/usr/bin/perl -ln +# +# kgslog2gtp - Convert kgsGtp log file to GTP command stream +# +# The command stream contains two special GTP commands intended +# for further script processing (unrecognized by Pachi itself): +# +# pachi-mygame COLOR OPPONENT DATE TIME +# pachi-mymove COORD VALUE +# +# (You probably want to convert pachi-mymove to play.) + +chomp; + +# 19.1.2012 20:47:47 com.gokgs.client.gtp.a +if (s/^(\S+ \S+) com.gokgs.client.gtp.a $/$1/) { + $a = $1; + +# FINE: Starting game as white against Mateman +} elsif (s/^FINE:.*as (\S+) against (\w+)/$1 $2/) { + print "pachi-mygame $_ $a"; + +# IN: play b o3 +} elsif (s/^IN: // and not /genmove/ and not /kgs-chat/ and not /time/) { + print $_; + +# *** WINNER is C4 (3,4) with score 0.4333 (49243/93153:93153/93393 games), extra komi 0.000000 +} elsif (s/^\*\*\* WINNER is (\S+) .*score (\S+) .*komi 0\.0.*/$1 $2/) { + print "pachi-mymove $_"; +} -- 2.11.4.GIT