ngf

Comments, questions, rants, etc, that are specifically about WBaduk go here.
Post Reply
LovroKlc
Lives with ko
Posts: 196
Joined: Thu Jun 03, 2010 4:29 am
Rank: tygem 5d
GD Posts: 259
Has thanked: 31 times
Been thanked: 12 times

ngf

Post by LovroKlc »

How can I change .ngf files to .sgf? I get the ngf's when I look at my wbaduk gibo.
Image
User avatar
SpongeBob
Lives in gote
Posts: 499
Joined: Sat Apr 24, 2010 3:18 pm
Rank: Fox 3D
GD Posts: 325
Location: Germany
Has thanked: 213 times
Been thanked: 96 times

Re: ngf

Post by SpongeBob »

Moyo Go Studio let's you open the files and save them as .SGF.

You can check other programs like Drago and MultiGo, maybe they are capable of that, too.
Stay out of my territory! (W. White, aka Heisenberg)
User avatar
Jordus
Site Admin
Posts: 1125
Joined: Fri Dec 04, 2009 6:06 pm
Rank: KGS 9k
GD Posts: 0
Universal go server handle: Jordus
Location: Allegan, MI, USA
Has thanked: 16 times
Been thanked: 116 times
Contact:

Re: ngf

Post by Jordus »

Multigo does for sure.... Not sure about drago...
I'm thinking...
LovroKlc
Lives with ko
Posts: 196
Joined: Thu Jun 03, 2010 4:29 am
Rank: tygem 5d
GD Posts: 259
Has thanked: 31 times
Been thanked: 12 times

Re: ngf

Post by LovroKlc »

thanks, I will try that programs.
Image
User avatar
toadwarble
Beginner
Posts: 11
Joined: Mon Jan 17, 2011 2:04 am
Rank: BGA 9K
GD Posts: 0
KGS: toadwarble
Been thanked: 1 time

Re: ngf

Post by toadwarble »

I did write a Perl NGF to SGF conversion program if anyone wants a copy please ask.

It needs to learn how to put down handicap stones, especially 3.
John Collins
parliament
Dies in gote
Posts: 49
Joined: Fri Apr 15, 2011 9:45 pm
GD Posts: 0
Has thanked: 1 time

Re: ngf

Post by parliament »

If it's just a short script you can attach it directly...or am I wrong?
User avatar
toadwarble
Beginner
Posts: 11
Joined: Mon Jan 17, 2011 2:04 am
Rank: BGA 9K
GD Posts: 0
KGS: toadwarble
Been thanked: 1 time

Re: ngf

Post by toadwarble »

#! /usr/bin/perl

sub readit {
$_ = <INF>;
s/\r?\n//;
}

$file = shift;
die "No source file given\n" unless $file;
die "Expecting NGF file\n" unless $file =~ /\.ngf/i;
die "Cannot open $file\n" unless open(INF, $file);

# Application and type

readit;

# Board size

readit;
die "Confused by board size $_\n" unless /\d+/;
$Boardsize = $_;

# White player and rank

readit;
($wp,$wr) = /^(.*\S)\s+(\d+[kd]\S*)/i;

# Black player and rank

readit;
($bp,$br) = /^(.*\S)\s+(\d+[kd]\S*)/i;

# Website name

readit;
$Website = $_;

# Handicap

readit;
$Hcap = $_;

# Unknown

readit;

# Komi (add 0.5)

readit;
$Komi = $_;
$Komi .= '.5';

# Date and time

readit;
($yr,$mn,$dy,$hr,$min) = /(\d\d\d\d)(\d\d)(\d\d)\s+\[(\d\d):(\d\d)\]/;
die "Confused by date $_\n" unless $yr;

$outfile = "Oro-$wp-v-$bp-$yr$mn$dy-$hr$min.sgf";
die "Cannot create output $outfile\n" unless open(OUTF, ">$outfile");
select OUTF;

# Unknown

readit;

# Result

readit;
$res = substr($_, 0, 1);
$res = $res eq "W"? "B": "W" if /loses/;
$res .= '+';
if (/resig/i) {
$res .= 'R';
}
elsif (/time/i) {
$res .= 'T';
}
elsif (/(\d+(\.5)?)/) {
$res .= $1;
}
else {
die "Confused by result format $_\n";
}

# Number of moves

readit;
$nmoves = $_;

$Aoff = ord('A');
$adj = ord('a') - $Aoff - 1;

print <<EOT;
(;GM[1]FF[4]AP[ngf2sgf]ST[1]
SZ[$Boardsize]HA[$Hcap]KM[$Komi]
PW[$wp]WR[$wr]PB[$bp]BR[$br]RE[$res]DT[$yr-$mn-$dy]PC[Oro]
EOT

while (<INF>) {
s/\r?\n//;
my ($m1,$m2,$pl,$c1,$c2) = /PM(.)(.)(.)(.)(.)/;
my $oc1 = ord($c1);
my $oc2 = ord($c2);
if ($oc1 <= $Aoff || $oc2 <= $Aoff) {
print ";${pl}[tt]\n";
}
else {
print ";$pl", "[", chr($oc1 + $adj), chr($oc2 + $adj), "]\n";
}
}
print ")\n";
John Collins
Post Reply