Solved

Chess PGN notation

Posted on 2010-08-27
7
759 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

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 …
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…

831 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