Solved

Chess PGN notation

Posted on 2010-08-27
7
757 Views
Last Modified: 2012-05-10
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
Comment
Question by:jeffiepoo
  • 3
  • 3
7 Comments
 
LVL 6

Author Comment

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

Expert Comment

by:jimmyray7
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

by:
jimmyray7 earned 300 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Author Comment

by:jeffiepoo
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

by:jimmyray7
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 62

Assisted Solution

by:☠ MASQ ☠
☠ MASQ ☠ earned 200 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

by:jeffiepoo
ID: 33553336
Thanks guys
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

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 …
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now