Forums

PGN Format

Sort:
LisaGreen

Hi,

 

Is it possible that anyone can identify this format for me please? I suspect it may be the output of one of the many chess programs out there. Note that there are no dots after the move numbers, commas between white, black moves and semi colons between "complete" moves. Also there is (TN) between annotation move brackets and "Resigns" instead of 1-0 0-1 or 1/2-1/2.

1 e4, c5; 2 c4, d6; 3 Nc3, Nc6; 4 g3, g6; 5 Bg2, Bg7; 6 d3, Nd4; 7 Be3, e6; 8 Nge2, Ne7; 9 Qd2, Nec6; 10 O-O, a6; 11 Bh6, O-O; 12 Bxg7, Kxg7; 13 f4, Rb8; 14 Nxd4, Nxd4; 15 e5, Qc7; 16 Rae1, b5; 17 cxb5 (TN), axb5; 18 exd6, Qxd6; 19 Ne4, Qb6; 20 Qc3, c4; 21 dxc4, bxc4; 22 Rf2, Ba6; 23 Rd2, e5; 24 Nf2, Rfe8; 25 Rxe5, Rxe5; 26 fxe5, Rd8; 27 a4, Qc5; 28 e6, fxe6; 29 b4, Qe5; 30 Kf1, Bc8; 31 b5, Qc5; 32 Ne4, Qd5; 33 Qb4, e5; 34 Qe7+ Qf7+ 35 Qxf7+ Kxf7; 36 a5, Ke7; 37 Nc3, Kd6; 38 a6, Kc7; 39 Ra2, Kb6; 40 Nd5+ Kxb5; 41 a7, Bb7; 42 Nc7+ Kb6; 43 Bxb7, Kxb7; 44 a8Q+ Rxa8; 45 Nxa8, c3; 46 Ra3, c2; 47 Rc3, Kxa8; 48 Kf2, Kb7; 49 Ke3, Kb6; 50 Ke4, Kb5; 51 Kxe5, Nc6+ 52 Kd6, Nd4; 53 Kd5, Nf5; 54 Ke4, Nd6+ 55 Kd3, Kb6; 56 Rxc2, Nf5; 57 Rc8, Kb7; 58 Rh8, Kc6; 59 Rxh7, Kd5; 60 g4, Nd6; 61 Rd7, Ke6; 62 Rxd6+ Kxd6; 63 Ke4, Ke6; 64 h4, Kf6; 65 Kd5, Ke7; 66 Ke5, Resigns.

TIA

Lisa

EscherehcsE

I have no idea what program produced this, but remind me not to even consider using the program. Laughing

omega_supreme

Is Descriptive Notation sexier?

sujas

Chessmaster?

EscherehcsE
LisaGreen wrote:

Hi,

 

Is it possible that anyone can identify this format for me please?

So where did you find this horrendously formatted game?

nils78

It is not PGN, at least Scid can not import it.

But it is also no big problem to convert it to PGN with some Script or even a text editor which is capable of regular expressions.

Eg. if you search for ,|;|(?: \(TN\)) and replace it with the empty string and manually replace the resigns. with 1-0 (or 0-1 or 1/2-1/2 depending on game result) then you get ...

1 e4 c5 2 c4 d6 3 Nc3 Nc6 4 g3 g6 5 Bg2 Bg7 6 d3 Nd4 7 Be3 e6 8 Nge2 Ne7 9 Qd2 Nec6 10 O-O a6 11 Bh6 O-O 12 Bxg7 Kxg7 13 f4 Rb8 14 Nxd4 Nxd4 15 e5 Qc7 16 Rae1 b5 17 cxb5 axb5 18 exd6 Qxd6 19 Ne4 Qb6 20 Qc3 c4 21 dxc4 bxc4 22 Rf2 Ba6 23 Rd2 e5 24 Nf2 Rfe8 25 Rxe5 Rxe5 26 fxe5 Rd8 27 a4 Qc5 28 e6 fxe6 29 b4 Qe5 30 Kf1 Bc8 31 b5 Qc5 32 Ne4 Qd5 33 Qb4 e5 34 Qe7+ Qf7+ 35 Qxf7+ Kxf7 36 a5 Ke7 37 Nc3 Kd6 38 a6 Kc7 39 Ra2 Kb6 40 Nd5+ Kxb5 41 a7 Bb7 42 Nc7+ Kb6 43 Bxb7 Kxb7 44 a8Q+ Rxa8 45 Nxa8 c3 46 Ra3 c2 47 Rc3 Kxa8 48 Kf2 Kb7 49 Ke3 Kb6 50 Ke4 Kb5 51 Kxe5 Nc6+ 52 Kd6 Nd4 53 Kd5 Nf5 54 Ke4 Nd6+ 55 Kd3 Kb6 56 Rxc2 Nf5 57 Rc8 Kb7 58 Rh8 Kc6 59 Rxh7 Kd5 60 g4 Nd6 61 Rd7 Ke6 62 Rxd6+ Kxd6 63 Ke4 Ke6 64 h4 Kf6 65 Kd5 Ke7 66 Ke5 1-0

... which Chess software should be able to import.

LisaGreen

Yeah... I converted it with the following in excel...

Sub subReformatPGN01()

 

Dim slCompleteGame As String

Dim lnglN As Long

 

slCompleteGame = Range("a1").Value

slCompleteGame = " " & slCompleteGame

slCompleteGame = Replace(slCompleteGame, ";", " ")

slCompleteGame = Replace(slCompleteGame, ",", " ")

 

For lnglN = 1 To 200

  slCompleteGame = Replace(slCompleteGame, " " & CStr(lnglN) & " ", " " & CStr(lnglN) & ". ")

Next lnglN

 

For lnglN = 1 To 10

  slCompleteGame = Replace(slCompleteGame, "  ", " ")

Next lnglN

  

Range("a2").Value = Trim$(slCompleteGame)

 

 

MsgBox "Done."

' *********************************************************************

End Sub

... But I just wondered where it came from. Chicken Monster asked me if I had an idea why it wouldn't load in SCID.
 
CM said i came from a friend a while back.
 
Lisa
nils78

In Python thats a oneliner ^^:

print('1 e4, c5; 2 c4, d6; 3 Nc3, Nc6; 4 g3, g6; 5 Bg2, Bg7; 6 d3, Nd4; 7 Be3, e6; 8 Nge2, Ne7; 9 Qd2, Nec6; 10 O-O, a6; 11 Bh6, O-O; 12 Bxg7, Kxg7; 13 f4, Rb8; 14 Nxd4, Nxd4; 15 e5, Qc7; 16 Rae1, b5; 17 cxb5 (TN), axb5; 18 exd6, Qxd6; 19 Ne4, Qb6; 20 Qc3, c4; 21 dxc4, bxc4; 22 Rf2, Ba6; 23 Rd2, e5; 24 Nf2, Rfe8; 25 Rxe5, Rxe5; 26 fxe5, Rd8; 27 a4, Qc5; 28 e6, fxe6; 29 b4, Qe5; 30 Kf1, Bc8; 31 b5, Qc5; 32 Ne4, Qd5; 33 Qb4, e5; 34 Qe7+ Qf7+ 35 Qxf7+ Kxf7; 36 a5, Ke7; 37 Nc3, Kd6; 38 a6, Kc7; 39 Ra2, Kb6; 40 Nd5+ Kxb5; 41 a7, Bb7; 42 Nc7+ Kb6; 43 Bxb7, Kxb7; 44 a8Q+ Rxa8; 45 Nxa8, c3; 46 Ra3, c2; 47 Rc3, Kxa8; 48 Kf2, Kb7; 49 Ke3, Kb6; 50 Ke4, Kb5; 51 Kxe5, Nc6+ 52 Kd6, Nd4; 53 Kd5, Nf5; 54 Ke4, Nd6+ 55 Kd3, Kb6; 56 Rxc2, Nf5; 57 Rc8, Kb7; 58 Rh8, Kc6; 59 Rxh7, Kd5; 60 g4, Nd6; 61 Rd7, Ke6; 62 Rxd6+ Kxd6; 63 Ke4, Ke6; 64 h4, Kf6; 65 Kd5, Ke7; 66 Ke5, Resigns.'.replace(',','').replace(';','').replace(' (TN)','').replace('Resigns.','1-0'))

LisaGreen

I know... but VBA is part of and comes all office progs, is free and doesn't need extra proggies or anything... and I'm fairly profficient at it.

 

:-) Lisa

LisaGreen

Actually  now I look at it... I'm not sure that python code would work. Have you actually tried it?

 

Lisa

HGMuller

I am a bit shocked WinBoard could not understand this game, as it is supposed to read anything that remotely looks like Chess. But ';' in PGN is actually defined as the start of a comment, which the lasts until the end of the line. So PGN parsers MUST ignore all moves but the first two.

This doesn't look a problem from the way the notation is displayed in the forum posting, but this is actually misleading: the game really is in a single line, and that it seems spread out over many lines is just an artifact of the forum software, which apparently chokes on such a long line...

So to read it in PGN-expecting software, it is essential that you delete the all semicolons. (E.g. using NotePad and 'Replace All'.) After that WinBoard has no problem reading it.

LisaGreen

Yeah...

See the code above... It's pretty easy to read...

Replace ; with space

Replace , with space

Replace numbers up to 200 with number with a dot after it

Replace double spaces with single space

I ignored TN and Resign and SCID just marked them as errors but read the game in anyway. 

 

I don't know about winboard... I'll be googling later!!! :-) ... Interesting that you're "shocked"... After getting the game in does it Export "proper"  PGN? 

As I said earlier... the original Q was about loading it into SCID.

 

I'm having quite a good time "manipulating" all this PGN!!

 

Lisa

HGMuller

To have WinBoard understand it all that is needed is to delete the semicolons. After that you can of course save it as regular PGN, but you would of course have to supply the tag values yourself (through the Edit Tags menu item). WinBoard in general ignores any stuff that is not supposed to be there in regular PGN, and just dishes out the moves. But it cannot do that for the semicolons, as they have a specific meaning in PGN which is conflicting with the way it is used here. But WinBoard doesn't care about commas, numbers without a period etc. interspaced with the text.

LisaGreen

My first thought is that the format is meant to be "machine readable" because it separates thing into moves with the semi colon. then the moves can be split up with spacs and commas. That's where my original Q came from about anyone knowing the format. It's possible that there is a proggie out there that is designed to read this.

 

Lisa

bobbymac310

Not sure where it came from but it imports directly into ChessBase 12. 

nils78
LisaGreen hat geschrieben:

(...) VBA is part of and comes all office progs, is free and doesn't need extra proggies or anything (...)

Python is also free. Except running the installer on Windows once (on Linux it is preinstalled) it has no dependencies.

LisaGreen hat geschrieben:

Actually  now I look at it... I'm not sure that python code would work. Have you actually tried it?

It is Python 3 Code. on Python 2 it would not run (because print is a function in Python 3).

EDIT i use single quotes for strings: ', not "

LisaGreen

@nils78.... Hmmmm.... What about dots after the move numbers. SCID wouldn't import without them.

 

@bobbymac310... Interesting. Did you read that HGMuller was "shocked" that winboard couldn't import it? Does CB 12 give any comments? Does the export look the same as the import or different?

 

Lisa

nils78
LisaGreen hat geschrieben:

@nils78.... Hmmmm.... What about dots after the move numbers. SCID wouldn't import without them.

I tested it without the dots ('Edit' -> 'Paste Clipboard text as PGN game') and Scid imported it without errors.

But adding dots is not difficult, regular expressions are needed.

Code:

import re;print(re.sub('([0-9]+)(.+?)\s+(?=[0-9])', r'\1.\2 ', '1 e4, c5; 2 c4, d6; 3 Nc3, Nc6; 4 g3, g6; 5 Bg2, Bg7; 6 d3, Nd4; 7 Be3, e6; 8 Nge2, Ne7; 9 Qd2, Nec6; 10 O-O, a6; 11 Bh6, O-O; 12 Bxg7, Kxg7; 13 f4, Rb8; 14 Nxd4, Nxd4; 15 e5, Qc7; 16 Rae1, b5; 17 cxb5 (TN), axb5; 18 exd6, Qxd6; 19 Ne4, Qb6; 20 Qc3, c4; 21 dxc4, bxc4; 22 Rf2, Ba6; 23 Rd2, e5; 24 Nf2, Rfe8; 25 Rxe5, Rxe5; 26 fxe5, Rd8; 27 a4, Qc5; 28 e6, fxe6; 29 b4, Qe5; 30 Kf1, Bc8; 31 b5, Qc5; 32 Ne4, Qd5; 33 Qb4, e5; 34 Qe7+ Qf7+ 35 Qxf7+ Kxf7; 36 a5, Ke7; 37 Nc3, Kd6; 38 a6, Kc7; 39 Ra2, Kb6; 40 Nd5+ Kxb5; 41 a7, Bb7; 42 Nc7+ Kb6; 43 Bxb7, Kxb7; 44 a8Q+ Rxa8; 45 Nxa8, c3; 46 Ra3, c2; 47 Rc3, Kxa8; 48 Kf2, Kb7; 49 Ke3, Kb6; 50 Ke4, Kb5; 51 Kxe5, Nc6+ 52 Kd6, Nd4; 53 Kd5, Nf5; 54 Ke4, Nd6+ 55 Kd3, Kb6; 56 Rxc2, Nf5; 57 Rc8, Kb7; 58 Rh8, Kc6; 59 Rxh7, Kd5; 60 g4, Nd6; 61 Rd7, Ke6; 62 Rxd6+ Kxd6; 63 Ke4, Ke6; 64 h4, Kf6; 65 Kd5, Ke7; 66 Ke5, Resigns.'.replace(',','').replace(';','').replace(' (TN)','').replace('Resigns.','1-0')))

The regex finds <number> <smallest possible amount of something> <space> (followed by a number). Eg. '1 e4 c5 ' or '2 c4 d6 ' or '66 Ke5 ' ...

It remembers the first number and the something and then replaces it with <number><dot><something><space>

EDIT i should add that this is not a clean solution. A clean solution would parse everything which looks like a legal half move, throw away everything else and autogenerate move numbers. The 'Resigns.' at the end is not really fixable programmatically.

LisaGreen

hmmmm again! Why doesn't the reg expr "find" the 5 space in 1 e4, c5 after you've changed the ; to space?

Isn't programming "resigns" to 1-0 or 0-1 is a case of picking up how much of the last move has been played?

Lisa


nils78
LisaGreen hat geschrieben:

(...) Why doesn't the reg expr "find" the 5 space in 1 e4, c5 after you've changed the ; to space?

(...)

The '5' at position 6 is not preceded by a space and therefore part of the <something> which the first match finds. The first match ends later, at position 8 (the '2' which is preceded by a space).

indeed i first tried the regex '([0-9]+)\s+' and the replacement r'\1. ' which resulted in the unwanted '1. e4. c5. 2. c4. d6. (...)'.

LisaGreen hat geschrieben:

(...)

Isn't programming "resigns" to 1-0 or 0-1 is a case of picking up how much of the last move has been played?

(...)

Do you mean, if there is 'resigns', then the player making the last move won? But there are games where one player makes a move, sees that it loses and resigns without waiting for opp to move.