Template talk:Chess position

From Meta, a Wikimedia project coordination wiki

Example:

{{chess position|=

 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

|30}}

which gives

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

subst:


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

Coloured or special pieces?[edit]

Are pieces in colours, such as red, or fairy chess pieces, available with this template?

You could create an alternate template with two additional parameters, that receive the initial part and last part of the names used to reference the images that contain the various white and black pieces on colored square backgrounds.
There are 6 models of pieces, each one in a dark or light piece color, and each one on a light or dark square, so you'll need to build a collection of 24 images with exactly the same square size (for correct alignment of cells of the chessboard). Additionally you need two images for the dark or light empty cells.
The variant part of the piece images is built after the initial of the english piece name, a letter "l" or "d" for denoting the color of the piece (light or dark), and a letter "l" or "d" that denotes the color (light or dark) of a cell on the chessboard (this last letter is not specified in the template arguments list, but statically added within this template code that builds the 8x8 chessboard layout).
Note that the template receives untrimmed spaces in values for empty cells, which are appended to the initial part of the image. These spaces are collapsed into a single one, including the space which is represented by the underscore at end of the initial invariant part of in the effective image names.
Similar layouts could be built for representing reversi boards, bridge and tarot decks, and so on...
Verdy P 23:56, 26 October 2005 (UTC)[reply]