It is currently Thu Dec 12, 2019 2:02 am

All times are UTC - 8 hours [ DST ]




Post new topic Reply to topic  [ 7 posts ] 
Author Message
Offline
 Post subject: ngf
Post #1 Posted: Sun Feb 27, 2011 10:07 am 
Lives with ko

Posts: 196
Liked others: 31
Was liked: 12
Rank: tygem 5d
GD Posts: 259
KGS: LovroKlc
How can I change .ngf files to .sgf? I get the ngf's when I look at my wbaduk gibo.

_________________
Image

Top
 Profile  
 
Offline
 Post subject: Re: ngf
Post #2 Posted: Sun Feb 27, 2011 11:39 am 
Lives in gote
User avatar

Posts: 481
Location: Germany
Liked others: 191
Was liked: 90
Rank: Tygem 1D
GD Posts: 325
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)

Top
 Profile  
 
Offline
 Post subject: Re: ngf
Post #3 Posted: Sun Feb 27, 2011 12:46 pm 
Site Admin
User avatar

Posts: 1125
Location: Allegan, MI, USA
Liked others: 18
Was liked: 121
Rank: KGS 9k
Universal go server handle: Jordus
Multigo does for sure.... Not sure about drago...

_________________
I'm thinking...

Top
 Profile  
 
Offline
 Post subject: Re: ngf
Post #4 Posted: Mon Feb 28, 2011 2:34 pm 
Lives with ko

Posts: 196
Liked others: 31
Was liked: 12
Rank: tygem 5d
GD Posts: 259
KGS: LovroKlc
thanks, I will try that programs.

_________________
Image

Top
 Profile  
 
Offline
 Post subject: Re: ngf
Post #5 Posted: Sun May 22, 2011 1:55 am 
Beginner
User avatar

Posts: 11
Liked others: 0
Was liked: 1
Rank: BGA 9K
KGS: 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

Top
 Profile  
 
Offline
 Post subject: Re: ngf
Post #6 Posted: Sun May 22, 2011 2:06 am 
Dies in gote

Posts: 49
Liked others: 1
Was liked: 0
If it's just a short script you can attach it directly...or am I wrong?

Top
 Profile  
 
Offline
 Post subject: Re: ngf
Post #7 Posted: Mon May 23, 2011 5:51 am 
Beginner
User avatar

Posts: 11
Liked others: 0
Was liked: 1
Rank: BGA 9K
KGS: 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

Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC - 8 hours [ DST ]


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group