Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
Solved

# Chess PGN notation

Posted on 2010-08-27
Medium Priority
770 Views
Hey everybody, I'm making a chess AI. I have most of the internals working, but now I need to get it to recognize PGN notation and store move combinations.

I had a question that I still cannot figure out about PGN (Portable Game Notation).

For instance, a move: Nxd6

With these moves, say you have both of your Knights, and they could both capture the piece on d6. How would you specify this?

This could also be an issue with Rooks.

Also, for extra credit, what does the + mean? And is there a special notation for au pasaunt?

Thanks guys!

-Jeff
0
Question by:jeffiepoo
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 3
• 3

LVL 6

Author Comment

ID: 33546642
** how would you specify which Knight took the piece on d6?
0

LVL 8

Expert Comment

ID: 33546821
+ means the move put the opponent in check.  No notation for en passant, the move is just noted.
0

LVL 8

Accepted Solution

jimmyray7 earned 900 total points
ID: 33546838
regarding the Knight issue:
------------------------------------------
Disambiguating moves

If two (or more) identical pieces can move to the same square, the piece's initial is followed by (in descending order of preference):

1. the file of departure if they differ;
2. the rank of departure if the files are the same but the ranks differ;
3. Both the rank and file if neither alone uniquely defines the piece (after a pawn promotion, if three or more of the same piece are able to reach the square).

For example, with two knights on g1 and d2, either of which might move to f3, the move is indicated as Ngf3 or Ndf3, as appropriate. With two knights on g5 and g1, the moves are N5f3 or N1f3. As above, an x may be used to indicate a capture: for example, N5xf3.
0

LVL 6

Author Comment

ID: 33547046
Excellent, this may be interesting to parse, but it is doable. Will pawns have a similar story?

This is my understanding of pawns.

A capture is not explicity illustrated by an x, the PGN representation like c5 just means a pawn moved to this position or captured a piece at this position. Say, if two pawns could both move to the same square, i.e. - can capture the same piece, it would be represented as:

cge5   ???

also from what you described, it seems that the longest move string could be 6 characters long. Ex: "Ng5xe4"  correct?
0

LVL 8

Expert Comment

ID: 33547127
I'm not 100% sure that my second comment is strict PGN.  It's "normal" chess notation, but I couldn't find anything specifically stating it was valid PGN.

Pawns should work the same.  I hope that helps!
0

LVL 63

Assisted Solution

☠ MASQ ☠ earned 600 total points
ID: 33549009
For disambiguation usually PGN defaults to the originating square in SAN (i.e. Nc4xd6) SAN in PGN allows up to seven characters so you could simply code using origin by default.
en passant is indicated as a capture but the destination SAN is the actual square the pawn moves to & not the reference to the actual captured piece's location. Although algebraic notation uses "ep" to record this "ep" is not used in PGN.
I guess you already have this http://www.saremba.de/chessgml/standards/pgn/pgn-complete.htm

0

LVL 6

Author Closing Comment

ID: 33553336
Thanks guys
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is RenderMan: RenderMan is a not any particular piece of software. RenderMan is an industry standard, defining set of rules that any rendering software should use, to be RenderMan-compliant. Pixar's RenderMan is a flagship implementation of …
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
###### Suggested Courses
Course of the Month5 days, 13 hours left to enroll