Jump to content

Template:Chess from pgn/doc

From Wikipedia, the free encyclopedia

This template takes Portable Game Notation, aka "pgn", or, optionally, just the Algebraic notation part of the pgn, and a list of positions, and generates a series of {{Chess diagram}}s.

Parameters

[edit]
  • pgn = - Mandatory parameter, containing the pgn or the algebraic notation of the game. In-notation comments are not supported. If original pgn contains comments, they should be removed for the template to work correctly. PGN headers are allowed, for convenience, but ignored by the template, except when parameter display notation is set to "yes", in which case the tags will be shown as part of the notation.
  • Series of move = parameters, determining which positions will be displayed, using the {{Chess diagram}} template. The value of this parameter will be passed to the diagram as "footer". Each move is in the form of <number>l or <number>d, for position after white move or after black move, e.g.
    • 12l = position after 12. Nxg6 : white captures with Knight
    • 12d = position after 12... fxg6: black captures Knight with pawn

An alternative way to display positions, showing a series of consecutive positions, is:

  1. from1 =
  2. to1 =
  3. comments1 = {text} {text} {text} ...

and optionally

  1. from2 =
  2. to2 =
  3. comments2 = {text} {text} {text}...

etc. (i.e., from3/to3/comments3, from4/to4/comments4 and so on)

Where "from1" is the first position to display, and "to1" is the last, (again, using "17l" or "13d" notation), and "comments1" is the series of footer text, each enclosed in { ... }, to be displayed as footer to each position in the series. If the number of comments do not match the number of positions between from and to, the excess comments will be ignored, or the excess positions will be displayed with no footer text.

Multiple series of positions can be requested, using "from2/to2/comments2" and so on. Note that requesting the same position multiple times, i.e., requesting it both as individual position and as part of a series, or using 2 series with some overlap, will result in displaying the same position more than once.

Regardless of the order and method the positions were requested, they will be displayed in the game's order - 12d always before 13l.

  • display notation = optional parameter, tells the template to display the parameter passed as "pgn", below the diagrams.

Example

[edit]
{{Chess from pgn
| 12l = position after 12. Nxg6 : white captures with Knight
| 12d = position after 12... fxg6:  black captures Knight with pawn
| 27d = position after 27... Bxa4 
| display notation = yes
| pgn = 
[Black "player a"]
[White "player b"]
[AnyTag "any other tag, such as event, date, elo etc. is allowed"]
1. d4 Nf6 2. c4 e6 3. Nc3 Bb4 4. Nf3 c5 5. e3 Nc6 6. Bd3 Bxc3+ 7. bxc3 d6 8. e4
e5 9. d5 Ne7 10. Nh4 h6 11. f4 Ng6 12. Nxg6 fxg6 13. fxe5 dxe5 14. Be3 b6 15.
O-O O-O 16. a4 a5 17. Rb1 Bd7 18. Rb2 Rb8 19. Rbf2 Qe7 20. Bc2 g5 21. Bd2 Qe8
22. Be1 Qg6 23. Qd3 Nh5 24. Rxf8+ Rxf8 25. Rxf8+ Kxf8 26. Bd1 Nf4 27. Qc2 Bxa4
}}

will display:

abcdefgh
8
a8 black rook
c8 black bishop
d8 black queen
e8 black king
h8 black rook
a7 black pawn
b7 black pawn
f7 black pawn
g7 black pawn
d6 black pawn
f6 black knight
g6 white knight
h6 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
c4 white pawn
e4 white pawn
f4 white pawn
c3 white pawn
d3 white bishop
a2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
c1 white bishop
d1 white queen
e1 white king
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
position after 12. Nxg6 : white captures with Knight
abcdefgh
8
a8 black rook
c8 black bishop
d8 black queen
e8 black king
h8 black rook
a7 black pawn
b7 black pawn
g7 black pawn
d6 black pawn
f6 black knight
g6 black pawn
h6 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
c4 white pawn
e4 white pawn
f4 white pawn
c3 white pawn
d3 white bishop
a2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
c1 white bishop
d1 white queen
e1 white king
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
position after 12... fxg6: black captures Knight with pawn
abcdefgh
8
f8 black king
g7 black pawn
b6 black pawn
g6 black queen
h6 black pawn
a5 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
g5 black pawn
a4 black bishop
c4 white pawn
e4 white pawn
f4 black knight
c3 white pawn
c2 white queen
g2 white pawn
h2 white pawn
d1 white bishop
e1 white bishop
g1 white king
8
77
66
55
44
33
22
11
abcdefgh
position after 27... Bxa4

[Black "player a"] [White "player b"] [AnyTag "any other tag, such as event, date, elo etc. is allowed"] 1. d4 Nf6 2. c4 e6 3. Nc3 Bb4 4. Nf3 c5 5. e3 Nc6 6. Bd3 Bxc3+ 7. bxc3 d6 8. e4 e5 9. d5 Ne7 10. Nh4 h6 11. f4 Ng6 12. Nxg6 fxg6 13. fxe5 dxe5 14. Be3 b6 15. O-O O-O 16. a4 a5 17. Rb1 Bd7 18. Rb2 Rb8 19. Rbf2 Qe7 20. Bc2 g5 21. Bd2 Qe8 22. Be1 Qg6 23. Qd3 Nh5 24. Rxf8+ Rxf8 25. Rxf8+ Kxf8 26. Bd1 Nf4 27. Qc2 Bxa4


Same game. Using from...to syntax (12l to 14d, plus disjoint position 27d), not defining "display notation"
{{Chess from pgn
| from1 = 12l 
| to1 = 14d
| comments1 = { position after 12. Nxg6 } { position after 12... fxg6 } { position after 13. fxe5 } { position after 13... dxe5 } { position after 14. Be3 } { position after 14... b6 }
| 27d = position after 27... Bxa4
| pgn = 
1. d4 Nf6 2. c4 e6 3. Nc3 Bb4 4. Nf3 c5 5. e3 Nc6 6. Bd3 Bxc3+ 7. bxc3 d6 8. e4
e5 9. d5 Ne7 10. Nh4 h6 11. f4 Ng6 12. Nxg6 fxg6 13. fxe5 dxe5 14. Be3 b6 15.
O-O O-O 16. a4 a5 17. Rb1 Bd7 18. Rb2 Rb8 19. Rbf2 Qe7 20. Bc2 g5 21. Bd2 Qe8
22. Be1 Qg6 23. Qd3 Nh5 24. Rxf8+ Rxf8 25. Rxf8+ Kxf8 26. Bd1 Nf4 27. Qc2 Bxa4
}}

will display:

abcdefgh
8
a8 black rook
c8 black bishop
d8 black queen
e8 black king
h8 black rook
a7 black pawn
b7 black pawn
f7 black pawn
g7 black pawn
d6 black pawn
f6 black knight
g6 white knight
h6 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
c4 white pawn
e4 white pawn
f4 white pawn
c3 white pawn
d3 white bishop
a2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
c1 white bishop
d1 white queen
e1 white king
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
position after 12. Nxg6
abcdefgh
8
a8 black rook
c8 black bishop
d8 black queen
e8 black king
h8 black rook
a7 black pawn
b7 black pawn
g7 black pawn
d6 black pawn
f6 black knight
g6 black pawn
h6 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
c4 white pawn
e4 white pawn
f4 white pawn
c3 white pawn
d3 white bishop
a2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
c1 white bishop
d1 white queen
e1 white king
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
position after 12... fxg6
abcdefgh
8
a8 black rook
c8 black bishop
d8 black queen
e8 black king
h8 black rook
a7 black pawn
b7 black pawn
g7 black pawn
d6 black pawn
f6 black knight
g6 black pawn
h6 black pawn
c5 black pawn
d5 white pawn
e5 white pawn
c4 white pawn
e4 white pawn
c3 white pawn
d3 white bishop
a2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
c1 white bishop
d1 white queen
e1 white king
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
position after 13. fxe5
abcdefgh
8
a8 black rook
c8 black bishop
d8 black queen
e8 black king
h8 black rook
a7 black pawn
b7 black pawn
g7 black pawn
f6 black knight
g6 black pawn
h6 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
c4 white pawn
e4 white pawn
c3 white pawn
d3 white bishop
a2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
c1 white bishop
d1 white queen
e1 white king
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
position after 13... dxe5
abcdefgh
8
a8 black rook
c8 black bishop
d8 black queen
e8 black king
h8 black rook
a7 black pawn
b7 black pawn
g7 black pawn
f6 black knight
g6 black pawn
h6 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
c4 white pawn
e4 white pawn
c3 white pawn
d3 white bishop
e3 white bishop
a2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
d1 white queen
e1 white king
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
position after 14. Be3
abcdefgh
8
a8 black rook
c8 black bishop
d8 black queen
e8 black king
h8 black rook
a7 black pawn
g7 black pawn
b6 black pawn
f6 black knight
g6 black pawn
h6 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
c4 white pawn
e4 white pawn
c3 white pawn
d3 white bishop
e3 white bishop
a2 white pawn
g2 white pawn
h2 white pawn
a1 white rook
d1 white queen
e1 white king
h1 white rook
8
77
66
55
44
33
22
11
abcdefgh
position after 14... b6
abcdefgh
8
f8 black king
g7 black pawn
b6 black pawn
g6 black queen
h6 black pawn
a5 black pawn
c5 black pawn
d5 white pawn
e5 black pawn
g5 black pawn
a4 black bishop
c4 white pawn
e4 white pawn
f4 black knight
c3 white pawn
c2 white queen
g2 white pawn
h2 white pawn
d1 white bishop
e1 white bishop
g1 white king
8
77
66
55
44
33
22
11
abcdefgh
position after 27... Bxa4

Test

[edit]
abcdefgh
8
e8 black rook
g8 black king
a7 black pawn
b7 black pawn
c7 black queen
g7 black bishop
h7 black pawn
c6 black knight
e6 black rook
f6 black knight
g6 black pawn
f5 black pawn
c4 white pawn
f4 white pawn
e3 white bishop
g3 white knight
a2 white pawn
b2 white pawn
e2 white bishop
f2 white king
h2 white pawn
a1 white rook
b1 white queen
e1 white rook
8
77
66
55
44
33
22
11
abcdefgh
Position after 20... Rae8
abcdefgh
8
e8 black rook
g8 black king
a7 black pawn
b7 black pawn
c7 black queen
g7 black bishop
h7 black pawn
c6 black knight
e6 black rook
f6 black knight
g6 black pawn
f5 black pawn
c4 white pawn
f4 white pawn
e3 white bishop
f3 white bishop
g3 white knight
a2 white pawn
b2 white pawn
f2 white king
h2 white pawn
a1 white rook
b1 white queen
e1 white rook
8
77
66
55
44
33
22
11
abcdefgh
Position after 21. Bf3
abcdefgh
8
e8 black rook
g8 black king
a7 black pawn
b7 black pawn
c7 black queen
g7 black bishop
h7 black pawn
c6 black knight
f6 black knight
g6 black pawn
f5 black pawn
c4 white pawn
f4 white pawn
e3 black rook
f3 white bishop
g3 white knight
a2 white pawn
b2 white pawn
f2 white king
h2 white pawn
a1 white rook
b1 white queen
e1 white rook
8
77
66
55
44
33
22
11
abcdefgh
Position after 21... Rxe3
abcdefgh
8
e8 black rook
g8 black king
a7 black pawn
b7 black pawn
c7 black queen
g7 black bishop
h7 black pawn
c6 black knight
f6 black knight
g6 black pawn
f5 black pawn
c4 white pawn
f4 white pawn
e3 white rook
f3 white bishop
g3 white knight
a2 white pawn
b2 white pawn
f2 white king
h2 white pawn
a1 white rook
b1 white queen
8
77
66
55
44
33
22
11
abcdefgh
Position after 22. Rxe3
abcdefgh
8
g8 black king
a7 black pawn
b7 black pawn
c7 black queen
g7 black bishop
h7 black pawn
c6 black knight
f6 black knight
g6 black pawn
f5 black pawn
c4 white pawn
f4 white pawn
e3 black rook
f3 white bishop
g3 white knight
a2 white pawn
b2 white pawn
f2 white king
h2 white pawn
a1 white rook
b1 white queen
8
77
66
55
44
33
22
11
abcdefgh
Position after 22... Rxe3
abcdefgh
8
g8 black king
a7 black pawn
b7 black pawn
c7 black queen
g7 black bishop
h7 black pawn
c6 black knight
f6 black knight
g6 black pawn
f5 black pawn
c4 white pawn
f4 white pawn
e3 white king
f3 white bishop
g3 white knight
a2 white pawn
b2 white pawn
h2 white pawn
a1 white rook
b1 white queen
8
77
66
55
44
33
22
11
abcdefgh
Position after 23. Kxe3
abcdefgh
8
g8 black king
a7 black pawn
b7 black pawn
g7 black bishop
h7 black pawn
c6 black knight
f6 black knight
g6 black pawn
f5 black pawn
c4 white pawn
f4 black queen
e3 white king
f3 white bishop
g3 white knight
a2 white pawn
b2 white pawn
h2 white pawn
a1 white rook
b1 white queen
8
77
66
55
44
33
22
11
abcdefgh
Position after 23... Qxf4+. White resigns