PGN File Format

Source: Internet
Author: User
I. Overview

PGN (portable game Notation) is the file format of the chess game process. Since chess uses this specification as the standard for recording chess scores, for Chinese chess, without a unified standard, PGN is undoubtedly a good choice. PGN files have the following features:

(1) The PGN file is in text format and can be created and modified using any text editing software;

(2) The PGN file is divided into the "tag part" and "method part". The two parts are standardized and tidy, which facilitates reading and reading, as well as generating and interpreting the chess and Music Editing software;

(3) a pgn file can contain multiple chess and board games to form a simple chess and board database;

(4) The format of the PGN file is public and is now accepted by the vast majority of chess and Music Editing Software (it only refers to chess, and currently there is no Chinese chess software that can generate the PGN file ).

Ii. Tag

The PGN tags are all represented by square brackets []. Each tag occupies one row, which reflects some basic information about the game. The PGN notation of Chinese chess is similar to that of chess. The basic labels are as follows:

(0) Game: Game type. Chess does not have this tag. In the PGN file of Chinese chess, this tag must be placed first and its value must be "Chinese chess ";

(1) Event: Competition name;

(2) Site: Competition location;

(3) Date: The date of the competition. The format is "YYYY. Mm. dd ";

(4) Round: Round of competition;

(5) Red: A red-square player, different from the white of chess;

(6) Black: Black players;

(7) Result: In the results of the game, "Red xiansheng" is represented by "1-0", "Black xiansheng" is represented by "0-1", and "1/2-1/2" is used for game games, and "*" is used for unknown games.

In addition, information with the characteristics of Chinese chess matches should be added:

(8) RedteamAnd Blackteam: This is the team (Club, Chess Association, province, or country) to which the players belong. They are usually written before the red and black labels;

(9) Opening, VariationAnd Ecco: Start name, variant, and Ecco number. All of these indicate start information. For details, refer to Chinese chess start number-description;

Here is an example:

[Game "Chinese chess"]

[Event "24th" Five goat Cup "National Championship Invitational competition"]

[Site "Guangzhou"]

[Date "2004.01.05"]

[Round "finals (contests)"]

[Redteam "Guangzhou"]

[Red "Lu Qin"]

[Blackteam "Guangzhou"]

[Black "Xu Yinchuan"]

[Result "1-0"]

[Opening "three steps to the left for cross-river artillery"]

[Ecco "B24"]

(10) Fen: This option is usually specified in the case of a situation such as the central bureau, the residual Bureau, and the layout;

(11) Format: Indicates the notation method, which can be Chinese(Chinese vertical line format ), Wxf(Wxf vertical line format) and ICCs(ICCs coordinate format). The default value is Chinese.

The following information can exist as a tag or be written in a comment:

(1) Information about players: Redtitle, Redelo, Redna(This is usually replaced by redteam ), RedtypeAnd others;

(2) Event-related information: Eventdate, Eventdocumsor, Section, Stage, Board, TimeAnd so on;

(3) time limit: TimecontrolMultiple types of tags.

(4) Conclusion: TerminationMultiple types of tags.

(5) Others, such Annotator, Mode, PlycountFor more information, see the Chinese chess translation court abstract-about the PGN and Fen notation specifications (I.

Iii. Chess and music

This part is the main content of PGN and records the methods, comments, and results of each round. The format of this part of content includes the following rules:

(1) The score part must be behind the tag part, and the score part cannot be inserted with tags;

(2) Each round is composed of three parts: "combination number", "Red Square method", and "black square method". "(period), separated by two delimiters (the period after the return union is no exception), and also separated by delimiters;

(3) the representation of the method must be consistent with the format tag. If there is no format tag, it will be represented in the Chinese vertical line format;

(4) The delimiter can only be a space, tab, or line break. There cannot be a delimiter in a method (the same number of returns );

(5) The comments are represented by curly brackets "{}". The comments may contain any character (including separators) other than curly brackets, which can be inserted after any method, it must be separated with a separator;

(6) the entire game must end with "1-0" (Red Square wins), "0-1" (black square wins), "1/2-1/2" (and chess games), or "*" (unknown) indicates the result. The result and the method must be separated by delimiters;

(7) There can only be comments in the future, and there cannot be a method. If a tag appears, it indicates that this is the next game.

For example, the following PGN file fragments are allowed:
51. Bing Wuping 6th

{Red Square is not enough to judge the negative,

But it will be negative next time .}

Divide 4 to 5

52. Bing liuping 5, Ping 5, Ping 4 53. Bing Wuping 6, 0-1 {the redhead will be negative}

For example, the following PGN file fragments are unreasonable:
51. binwuping 6: 4: 5 // a separator should be added to the end of the sentence

[Format "wxf"] 52. p6.5 k5.4 // The chess and music section cannot contain tags.

53. Bing Wu {another ping 6 will be judged negative} Ping 4 // The commentary cannot break up a method

Iv. Examples

The following is a classic example. This example can reflect the characteristics of the Chinese chess PGN format:

[Game "Chinese chess"]

[Event "Xu Yinchuan makes the 9 sub-game perfect"]

[Site "Guangzhou"]

[Date "maid"]

[Red "Xu Yinchuan"]

[Black "Nie Weiping"]

[Result "1-0"]

[Fen "rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/9/1c5c1/9/rn2k2nr R-0 1"]

{Comment: Xu Yinchuan

Playing chess makes jiuziyuan have fun after a meal. If I don't want to go to the competition table today, I am surprised that my opponent is a handsome player in Go chess. I didn't know the opponent's strength before the competition, but I believe that the extraordinary wisdom embodied in go will be able to communicate in chess. Therefore, I made some preparations before the competition, so I was cautious and did not dare to take it lightly.

Xu Yinchuan let go to five soldiers and two soldiers in two phases, holding the red first. As shown in the right figure. Of course, Images cannot be embedded in the PGN file .}
1. Eight-gun, five-gun, eight-gun, and five-gun

{The red party's first gun in the middle will go, and the chess holy party will fight against the sub-force in the middle, and the tactics will rival the enemy .}

2. Gun 5-in-5 elephant 7-in-5 3. Gun 2-in-5

{If you try again, the gun is still running. For example, if you try again, you may try again. If you try again, you may try again, it will be difficult to make a difference if you lose both of them .}

Ma 8 to 7 4. Ma 2 to 3 cars 9 to 8 5. Ma 8 to 7 Ma 2 to 1 6. Che 9 to 6 cars 1 to 2

{Yi Qisheng still uses the conventional tactics to dispatch the main force, but ignores the fierce eyes of the Red Square car. He should take the car 1 to 1 .}

7. Six-in-eight vehicles

{The eyes of the red car are sharp. This kind of confrontation cannot be inferred from common sense. The red party can only attack a round like the Three-board axe of Cheng Yaojin. If the black side is defended by a rule, the party will decide whether to win or lose .}

Gun 2 in 7

{But he said that he was very dignified when he saw me as a leader. After thinking about it, he fell down to attack and guard against it. If you change the gun to 2, 5, 6, 3, 5, 6, 5, 5, and 2, the black side is not easy to control .}

8. Four shots in the car, two shots at the same time, one shot at the same time, eight shots at the same time, one shot at the same time, four shots at the same time, and four shots at the same time.

{In fact, the black party can still go to the gun 1 to 4. If the red party continues to leave the gun 8 to 7, the gun 1 to 4 remains unchanged and, because the Black right car calls the red car 6 to 9, it is not a foul .}

12. Gun 5-plane 8-gun 1-4

{Poor, resulting in the loss of the child, should take the car 2 Ping 3, Red Square such as Ma ba into six, then the car 3 retreat 1, Red Square cannot start. However, it must be noted that hiding in the dark seems to be contrary to the chess theory. Therefore, it is justifiable to abandon the game in order to ease the situation .}

13. 8-in-five guns, 1-out 9 14. 8-in-One guns, 3-out vehicles, 8-in-One guns, 8-in-One vehicles, 2-16 horses, 8-in-6 guns, 9-in-5 guns

17. Guns, three planes, one person, six men, five men, six horses, four cars, eight horses, five horses, and six horses

{You can go straight to the next corner to step on the image .}

Cars 5, 6, 20, 4, 3, 5, 6, 21, 6, 4, 5, 1, 22, 6, 2, 5, 7

23. Move the horse forward, move the horse forward, move the car 6, move the car

27. Ma Jin's staff 5 to 6 28. Ma erjin's team 3 to 6 and 5 29. Ma Jin's Team 2

{The red party is a little procrastinating and should go straight to the three sides of the car to kill the game .}

5 In 1 30. Three cars, six men, five men, two men, two men, three men, six men, and three men

{Just pull another car. The following method is just to talk about all personnel .}

Car 6, plane 7, 33. Car 6, plane 3, stroke 6, plane 7, 34. Car 3, plane 5, plane 5, plane 6, handsome 6, plane 5, Move 6, Move 1

36. Cars 5-in-2 will be 6-out 1 37. Cars 5-in-1 will be 6-in-1 38. Cars 5-out 7

{At this point, you have been a serious negative player. At the same time, I was killed by another game of go, And I was no longer able to fight again, so I was happy .}

1-0

5. Changing

It is represented by parentheses "()", and the comment on the board is made in the form of a board chart. Therefore, the content in the brackets is also a board chart, and the comments can be nested in it (curly brackets) and (in parentheses ). The change is aimed at the method in front of the brackets. For example, in the following piece of chess, the change refers to "Gun 2 in 7" and then "Gun 2 in 3 ":

7. six-in-one, eight-gun, two-in-seven (7 .... gun 2, 3, 8. shuai Wuping six guns 3 to 5 9. six in One, five in one. option 5 retreat {difficult to control by the black party })

VI, PGN And XML

Nowadays, network technology is developing fast, and it is necessary to make it easy to be used by the Internet to publish games on the Internet. ProgramXML is undoubtedly a good choice for the formats recognized. Because the PGN label is similar to the XML container, the conversion between PGN and XML is very convenient. At present, the chess and Music Standards of XML have not yet been formed, but it is not difficult to form a recognized XML format as long as the content in PGN format is copied. For example, the text in XML format converted from the above instance can be in the following format:

<PGN>

<Game> Chinese chess </Game>

<Event> Xu Yinchuan allows the 9 sub-accounts to play the game. </event>

<Site> Guangzhou </site>

<Date> maid </date>

<Red> Xu Yinchuan </red>

<Black> Nie Weiping </Black>

<Result> 1-0 </result>

<Fen> rnbakabnr/9/1c5c1/p1p1p1p1p/9/9/9/1c5c1/9/rn2k2nr R-0 1 </Fen>

<Comment> comment: Xu Yinchuan

Playing chess makes jiuziyuan have fun after a meal. If I don't want to go to the competition table today, I am surprised that my opponent is a handsome player in Go chess. I didn't know the opponent's strength before the competition, but I believe that the extraordinary wisdom embodied in go will be able to communicate in chess. Therefore, I made some preparations before the competition, so I was cautious and did not dare to take it lightly.

Xu Yinchuan let go to five soldiers and two soldiers in two phases, holding the red first. In XML, images can be embedded as hyperlinks, for example, .

</Comment>

<Move> gunnov 8 </move>

<Move> gun 8-Level 5 </move>

<Comment> omitted later ...... </Comment>

<End> 1-0 </end>

</PGN>

From: http://www.xqbase.com/protocol/cchess_pgn.htm

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.