Difference between revisions of "Template:Chess diagram/doc"
(typo) |
(new sections: FEN and "reverse") |
||
Line 836: | Line 836: | ||
|} | |} | ||
+ | ==Alternative way to place the pieces: FEN== | ||
+ | <pre> | ||
+ | {{Chess diagram|fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR|align=tleft}} | ||
+ | </pre> | ||
+ | {{Chess diagram|fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR|align=tleft}} | ||
+ | It is possible to populate the boardd using [[Forsyth–Edwards Notation]], instead of positional parameters. | ||
+ | |||
+ | To do this, the "fen" parameter is used. For instance, this is the opening board of a chess game, defined using the "fen" parameter "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR": | ||
+ | {{-}} | ||
+ | <pre> | ||
+ | {{Chess diagram|fen=rnbqkbnr/acfghzwt/8/8/8/8/ACFGHZWT/RNBQKBNR|align=tleft}} | ||
+ | </pre> | ||
+ | {{Chess diagram|fen=rnbqkbnr/acfghzwt/8/8/8/8/ACFGHZWT/RNBQKBNR|align=tleft}} | ||
+ | It is also possible to show "fairy" pieces usign the FEN notation. However, because the FEN notation uses upercase and lowercase to denote the color of the piece, it is not possible to display the upside-down knight fairy piece (denoted by "N") using the fen parameter. Here is a board where the pawns are replaced by fairy pieces: | ||
+ | {{-}} | ||
+ | Only 8x8 boards can use the "fen" parameter. for other size board, positional paramters should be used. | ||
+ | == Displaying the board from the black's point of view == | ||
+ | <pre> | ||
+ | {{Chess diagram|reverse=true}} | ||
+ | </pre> | ||
+ | {{Chess diagram|reverse=true}} | ||
+ | 8x8 boards can be shown from black's point of view, i.e., with h8 square at lower left corner and a1 at the upper right. This is done by using "reverse=true" parameter. | ||
+ | {{-}} | ||
==See also== | ==See also== | ||
*[[Template:Chess position]], alternative template no longer in use | *[[Template:Chess position]], alternative template no longer in use |
Revision as of 04:09, 28 May 2013
{{#ifeq:chess diagram/doc |doc
|
{{#ifeq:show |show
| Template:Mbox }}{{#if: | | {{#ifexist:Template:Chess diagram/doc | [[Category:{{#switch:Template |Template=Template |Module=Module |User=User |#default=Wikipedia}} documentation pages]] | }} }} | }}
Contents
Syntax
There are several standard chess diagram templates:
- Template:Chess diagram (square size 26x26 px)
- Template:Chess diagram small (square size 22x22 px)
- Template:Chess diagram 4x4 (square size 26x26 px)
- Template:Chess diagram 4x5 (square size 26x26 px)
- Template:Chess diagram 5x5 (square size 26x26 px)
- Template:Chess diagram 5x6 (square size 26x26 px)
- Template:Chess diagram 6x6 (square size 26x26 px)
- Template:Chess diagram 8x10 (Capablanca chess square size 26x26 px)
- Template:Chess diagram 8x12 (square size 26x26 px)
- Template:Chess diagram 9x9 (square size 26x26 px)
- Template:Chess diagram 10x10 (square size 26x26 px)
There are also templates for chess variants:
- Template:Alice chess diagram (Alice chess, square size 22x22 px)
- Template:Bughouse chess diagram (Bughouse chess, square size 22x22 px)
- Template:Omega Chess diagram (Omega Chess with 10x10 board + 4 corners, 22x22 px)
- Template:Raumschach diagram (5x5x5 board for Three-dimensional chess, 22x22 px)
The syntax is basically the same for all of them.
{{Chess diagram | <alignment> (param #1) | <header> (#2) | size = | numbers = | letters = | <a8> | <b8> | ... | <h8> (#3 to ... | <a7> | <b7> | ... | <h7> ... | <a1> | <b1> | ... | <h1> ( ... #66) | <footer> (#67) }}
Parameters:
-
<alignment>
– defines horizontal alignment (floating) of the whole table, must betright
ortleft
(or nothing) -
<header>
– the text which appears above the diagram, may be empty; -
size
- specifies the size of each square in pixels, the default is 26. -
numbers
- specifies whether the rows are numbered. Options are: left, right, both (default) or neither. -
letters
- specifies whether the columns are lettered. Options are: top, bottom, both (default) or neither. -
<a8>, <b8>, ... <h1>
– define corresponding squares of the chessboard, see below; -
<footer>
– the text which appears beneath the diagram, may be empty; optional – can be left out (currently not in the other templates)
A square is defined by the name of piece or empty parameter. The names of the pieces are those given in algebraic notation:
- 26px 26px 26px 26px k = king
- 26px 26px 26px 26px q = queen
- 26px 26px 26px 26px r = rook
- 26px 26px 26px 26px b = bishop
- 26px 26px 26px 26px n = knight
- 26px 26px 26px 26px p = pawn
There are also some fairy chess pieces available:
- 26px 26px 26px 26px a = archbishop (knight + bishop compound)
- 26px 26px 26px 26px c = chancellor (knight + rook compound)
- 26px 26px 26px 26px f = upside-down king
- 26px 26px 26px 26px g = upside-down queen
- 26px 26px 26px 26px m = upside-down rook
- 26px 26px 26px 26px e = upside-down bishop
- 26px 26px 26px 26px N = upside-down knight
- 26px 26px 26px 26px h = upside-down pawn
- 26px 26px 26px 26px z = champion (for Omega Chess)
- 26px 26px 26px 26px w = wizard (for Omega Chess)
- 26px 26px 26px 26px t = fool (for Omega Chess)
These letters are combined with either "l" for Light=White, or "d" for Dark=Black. So "kl" is White's king, and "nd" is Black's knight.
An empty square is written either using underscores, spaces, or nothing at all. Two spaces are recommended.
You can also use "xx" for a black cross, "ox" for a white cross, "xo" for a black circle on an empty square or "oo" for a white one.
- 26px26px xx = black cross/x
- 26px26px ox = white cross/x
- 26px26px xo = black circle
- 26px26px oo = white circle
When showing movement directions on the board, arrows are available
- 26px26px ul = up & left
- 26px26px ua = up
- 26px26px ur = up & right
- 26px26px la = left
- 26px26px lr = left & right
- 26px26px ud = up & down
- 26px26px ra = right
- 26px26px dl = down & left
- 26px26px da = down
- 26px26px dr = down & right
Numbers can also be added to squares by using "x0" for 0, "x1" for 1, "x2" for 2, ..., "x9" for 9.
- 26px26px x0
- 26px26px x1
- 26px26px x2
- 26px26px x3
- 26px26px x4
- 26px26px x5
- 26px26px x6
- 26px26px x7
- 26px26px x8
- 26px26px x9
Examples
In the following examples the rows and columns are numbered. Because any text between "|=" and the next "|" is ignored, numbers and letters can be added without affecting output.
Standard diagram
This diagram is recommended for common use as a main diagram in the articles on chess openings, endings, games, positions etc. See the corresponding code below.
{{#invoke:Chessboard|board}}
{{Chess diagram | tright | |= 8 |rd|nd|bd|qd|kd|bd|nd|rd|= 7 |pd|pd|pd|pd| |pd|pd|pd|= 6 | | | | | | | | |= 5 | | | | |pd| | | |= 4 | | | | |pl|pl| | |= 3 | | | | | | | | |= 2 |pl|pl|pl|pl| | |pl|pl|= 1 |rl|nl|bl|ql|kl|bl|nl|rl|= a b c d e f g h | The King's Gambit }}
Diagram with both captions
{{#invoke:Chessboard|board}}
It may be convenient to use this in the articles on chess problems. Please note that in the header and footer you can use bolds or italics. You can also use <br>
to break the lines.
{{Chess diagram | tright | '''W. Langstaff''', ''Chess Amateur'' 1922 |= 8 | | | | |kd| | |rd|= 7 | | | | | | | | |= 6 | | | | | |bl| |pl|= 5 | | | |rl| |kl|pd|pl|= 4 | | | | | | | | |= 3 | | | | | | | | |= 2 | | | | | | | | |= 1 | | | | | | | | |= a b c d e f g h | '''Mate in two.''' <br> This problem uses ''partial retrograde analysis'' method. }}
Diagram without captions
{{#invoke:Chessboard|board}}
See the corresponding code below. If you don't want the captions, just remove them, but don't delete the second "|" pipe character for the caption above; it is possible to delete the last pipe for the longer caption below.
The diagram floats to the left to illustrate the use of the first parameter.
{{Chess diagram | tleft | |= 8 | | | | | | | | |= 7 | | | | | | | | |= 6 | |xx|xo|xx| | | | |= 5 | | |pl| | | | | |= 4 | | | | | |xo| | |= 3 | | | | |xx|xo|xx| |= 2 | | | | | |pl| | |= 1 | | | | | | | | |= a b c d e f g h }}
Movement Example
This can be used to show how pieces move. {{#invoke:Chessboard|board}}
{{Chess diagram | tleft | |= 8 | | |ua| | | | | |= 7 | | |ua| | | | | |= 6 |la|la|rd|ra|ra|ra|ra|ra|= 5 | | |da| | | | | |= 4 | | |da| |ul|ua|ur| |= 3 | | |da| |la|kl|ra| |= 2 | | |da| |dl|da|dr| |= 1 | | |da| | | | | |= a b c d e f g h |Example showing how white king can move any direction, but only one square, while black rook can move any number of squares but only up and down, and right and left. }}
{{#invoke:Chessboard|board}}
{{Chess diagram | tright | |= 8 | |ul| |ua| |ur| | |= 7 | | |ul|ua|ur| | | |= 6 |la|la|la|ql|ra|ra|ra|ra|= 5 | | |dl|da|dr| | | |= 4 | |dl| |da| |dr| | |= 3 |dl| | |da| | |dr| |= 2 | | | |da| | | |dr|= 1 | | | |da| | | | |= a b c d e f g h }}
In the board on the right, it is shown that the white queen can go any distance in any of these directions.
Another method for the rook example: {{#invoke:Chessboard|board}}
{{Chess diagram | tleft | |= 8 | | | | | | | | |= 7 | | |ud| | | | | |= 6 | |lr|rd|lr| | | | |= 5 | | |ud| | | | | |= 4 | | | | |ul|ua|ur| |= 3 | | | | |la|kl|ra| |= 2 | | | | |dl|da|dr| |= 1 | | | | | | | | |= a b c d e f g h }}
Small diagram
This one may be useful in articles with many diagrams. It uses another template named Template:Tl.
The small diagrams can have header, too.
{{#invoke:Chessboard|board|size=22}}
{{Chess diagram small | tright | |= 8 |rd| | |qd| |rd|kd| |= 7 |pd|pd| | |pd|pd|bd|pd|= 6 | |nd|pd| | |nd|pd| |= 5 | | |ql| | | |bl| |= 4 | | | |pl|pl| |bd| |= 3 | | |nl| | |nl| | |= 2 |pl|pl| | | |pl|pl|pl|= 1 | | | |rl|kl|bl| |rl|= a b c d e f g h | Position after 11.Bg5 }}
Different board size
Chess boards of non-standard dimensions need special templates. There are templates for the following boards:
{{Chess diagram 5x5 | tright | |= 5 |kd|qd|bd|nd|rd|= 4 |pd|pd|pd|pd|pd|= 3 | | | | | |= 2 |pl|pl|pl|pl|pl|= 1 |kl|ql|bl|nl|rl|= a b c d e | Gardner minichess }} |
{{#invoke:Chessboard_mxn|board|cols=5|rows=5|letters=none|numbers=none}} |
{{Chess diagram 6x6 | tright | |= 6 |rd|nd|qd|kd|nd|rd|= 5 |pd|pd|pd|pd|pd|pd|= 4 | | | | | | |= 3 | | | | | | |= 2 |pl|pl|pl|pl|pl|pl|= 1 |rl|nl|ql|kl|nl|rl|= a b c d e f | Los Alamos chess }} |
{{#invoke:Chessboard_mxn|board|cols=6|rows=6|letters=both|numbers=both}} |
{{Chess diagram 8x10 | tright | |= 8 |rd|nd|ad|bd|qd|kd|bd|cd|nd|rd|= 7 |pd|pd|pd|pd|pd|pd|pd|pd|pd|pd|= 6 | | | | | | | | | | |= 5 | | | | | | | | | | |= 4 | | | | | | | | | | |= 3 | | | | | | | | | | |= 2 |pl|pl|pl|pl|pl|pl|pl|pl|pl|pl|= 1 |rl|nl|al|bl|ql|kl|bl|cl|nl|rl|= a b c d e f g h i j | Capablanca chess }} |
{{#invoke:Chessboard_mxn|board|cols=10|rows=8|letters=both|numbers=both}} |
{{Chess diagram 10x10 | tright | |= 10 |rd| | | | | | | | |rd|= 9 | |nd|bd|qd|kd|cd|ad|bd|nd| |= 8 |pd|pd|pd|pd|pd|pd|pd|pd|pd|pd|= 7 | | | | | | | | | | |= 6 | | | | | | | | | | |= 5 | | | | | | | | | | |= 4 | | | | | | | | | | |= 3 |pl|pl|pl|pl|pl|pl|pl|pl|pl|pl|= 2 | |nl|bl|ql|kl|cl|al|bl|nl| |= 1 |rl| | | | | | | | |rl|= a b c d e f g h i j | Grand Chess }} |
board|cols=10|rows=10|letters=both|numbers=both}} |
Double boards
{{bughouse chess diagram | A1=Team 1, Board A | A2=Team 2, Board A | B1=Team 1, Board B | B2=Team 2, Board B | tright | |= 8 |rd|nd|bd|qd|kd|bd|nd|rd|= 7 |pd|pd|pd|pd|pd|pd|pd|pd|= 6 | | | | | | | | |= 5 | | | | | | | | |= 4 | | | | | | | | |= 3 | | | | | | | | |= 2 |pl|pl|pl|pl|pl|pl|pl|pl|= 1 |rl|nl|bl|ql|kl|bl|nl|rl|= a b c d e f g h 8 |rl|nl|bl|kl|ql|bl|nl|rl|= 7 |pl|pl|pl|pl|pl|pl|pl|pl|= 6 | | | | | | | | |= 5 | | | | | | | | |= 4 | | | | | | | | |= 3 | | | | | | | | |= 2 |pd|pd|pd|pd|pd|pd|pd|pd|= 1 |rd|nd|bd|kd|qd|bd|nd|rd|= a b c d e f g h | '''Bughouse''' setup and starting position }} |
|
{{alice chess diagram | tright | |= 8 |rd|nd|bd|qd|kd| |nd|rd|= 7 |pd|pd|pd|pd| |pd|pd|pd|= 6 | | | | | | | | |= 5 | | | | |nl| | | |= 4 | | | | | | | | |= 3 | | | | | | | | |= 2 |pl|pl|pl|pl|pl|pl|pl|pl|= 1 |rl|nl|bl|ql|kl|bl| |rl|= a b c d e f g h Board A 8 | | | | | | | | |= 7 | | | | | | | | |= 6 | | | | |pd| | | |= 5 | | |bd| | | | | |= 4 | | | | | | | | |= 3 | | | | | | | | |= 2 | | | | | | | | |= 1 | | | | | | | | |= a b c d e f g h Board B | Position after '''1. Nf3 e6 2. Ne5 Bc5''' }} |
|
Different shaped board
{{Raumschach diagram | tright | |= 5 |rd|nd|kd|nd|rd|= 4 |pd|pd|pd|pd|pd|= 3 | | | | | |= 2 | | | | | |= 1 | | | | | |= Ea Eb Ec Ed Ee 5 |Nd|bd|qd|Nd|bd|= 4 |pd|pd|pd|pd|pd|= 3 | | | | | |= 2 | | | | | |= 1 | | | | | |= Da Db Dc Dd De 5 | | | | | |= 4 | | | | | |= 3 | | | | | |= 2 | | | | | |= 1 | | | | | |= Ca Cb Cc Cd Ce 5 | | | | | |= 4 | | | | | |= 3 | | | | | |= 2 |pl|pl|pl|pl|pl|= 1 |bl|Nl|ql|bl|Nl|= Ba Bb Bc Bd Be 5 | | | | | |= 4 | | | | | |= 3 | | | | | |= 2 |pl|pl|pl|pl|pl|= 1 |rl|nl|kl|nl|rl|= Aa Ab Ac Ad Ae | '''Raumschach''' starting position }} |
{{Omega Chess diagram | | [[Omega Chess]] (10x10 + 4 corners) |= w4 w3 |wd|= |wd|= 9 |zd|rd|nd|bd|qd|kd|bd|nd|rd|zd|= 8 |pd|pd|pd|pd|pd|pd|pd|pd|pd|pd|= 7 | | | | | | | | | | |= 6 | | | | | | | | | | |= 5 | | | | | | | | | | |= 4 | | | | | | | | | | |= 3 | | | | | | | | | | |= 2 | | | | | | | | | | |= 1 |pl|pl|pl|pl|pl|pl|pl|pl|pl|pl|= 0 |zl|rl|nl|bl|ql|kl|bl|nl|rl|zl|= |wl|= |wl|= w1 a b c d e f g h i j w2 | '''Omega Chess''' starting position }} |
Omega Chess (10x10 + 4 corners)
Omega Chess starting position
|
Alternative way to place the pieces: FEN
{{Chess diagram|fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR|align=tleft}}
{{#invoke:Chessboard|board}} It is possible to populate the boardd using Forsyth–Edwards Notation, instead of positional parameters.
To do this, the "fen" parameter is used. For instance, this is the opening board of a chess game, defined using the "fen" parameter "rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR":
{{Chess diagram|fen=rnbqkbnr/acfghzwt/8/8/8/8/ACFGHZWT/RNBQKBNR|align=tleft}}
{{#invoke:Chessboard|board}}
It is also possible to show "fairy" pieces usign the FEN notation. However, because the FEN notation uses upercase and lowercase to denote the color of the piece, it is not possible to display the upside-down knight fairy piece (denoted by "N") using the fen parameter. Here is a board where the pawns are replaced by fairy pieces:
Only 8x8 boards can use the "fen" parameter. for other size board, positional paramters should be used.
Displaying the board from the black's point of view
{{Chess diagram|reverse=true}}
{{#invoke:Chessboard|board}}
8x8 boards can be shown from black's point of view, i.e., with h8 square at lower left corner and a1 at the upper right. This is done by using "reverse=true" parameter.
See also
- Template:Chess position, alternative template no longer in use