Template talk:Chess position

From Wikipedia, the free encyclopedia

Per discussion at the Meta project, this template has been replaced by Template:Chess diagram. Any references to this template should be updated.

On international wiki coordination about chessboard template we are voting for the best style of chess board at [1]

This template is used for the generation of diagrams of chess positions.

See Template:Chess image for the images used.

See also http://wikisophia.org/wiki/Wikitex_Chess , a possible future software extension.

See also: Discussion about Universal Template on Commons.

Contents

[edit] Explanation

The syntax is quite simple: each of the first 64 parameters is simply the piece in a given square, starting at the top left, and working across each row to the bottom right. The last parameter is the width in pixels of each square.

The names of the pieces are those given in algebraic notation:

k = king
q = queen
r = rook
b = bishop
n = knight
p = pawn

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.

Finally, an empty square is written either using underscores, spaces, or nothing at all. thus "", " ", and "_______" all produce and empty square.

[edit] Basic examples

To invoke a board, it is possible to write something like:

{{Chess position|rd|nd|bd|qd|kd|bd|nd|rd|pd|pd|pd|pd|pd|pd|pd|pd||||||||||
|||||||||||||||||||||||pl|pl|pl|pl|pl|pl|pl|pl|rl|nl|bl|ql|kl|bl|nl|rl|30}}

(Note that this was written as two lines because it wouldn't fit on one.) This is usually not very readable! So it is desirable to format code so that it looks like a chess board, like so:

{{Chess position|=

 |rd|nd|bd|qd|kd|bd|nd|rd|=
 |pd|pd|pd|pd|pd|pd|pd|pd|=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |pl|pl|pl|pl|pl|pl|pl|pl|=
 |rl|nl|bl|ql|kl|bl|nl|rl|=
 
|30}}

This version relies on mediawiki's interpretation of any parameter value containing an "=" sign as an explicitly named parameter (I believe Patrick deserves credit for figuring this out). Some templates take parameters like "myParameter=some random text". Because the parameters in this example begin with an "=" sign, they are interpreted by mediawiki as the named parameter "" -- i.e. a named parameter with no name! Thus, everything after the "=" sign, and before the next "|" character is ignored. Previously, most instances of this chess position template used html comments ( "<!-- newline -->") in order to achieve the same effect. This way produces more readable code. Note: as long as the = signs don't come after something recognized as a parameter name, they can really be anywhere. So it's even possible to write:

{{Chess position|                                       {{Chess position|

=  |rd|nd|bd|qd|kd|bd|nd|rd|                            =  |rd|nd|bd|qd|kd|bd|nd|rd|  =
=  |pd|pd|pd|pd|pd|pd|pd|pd|                            =  |pd|pd|pd|pd|pd|pd|pd|pd|  =
=  |  |  |  |  |  |  |  |  |                            =  |  |  |  |  |  |  |  |  |  =
=  |  |  |  |  |  |  |  |  |                            =  |  |  |  |  |  |  |  |  |  =
=  |  |  |  |  |  |  |  |  |            (OR)            =  |  |  |  |  |  |  |  |  |  =
=  |  |  |  |  |  |  |  |  |                            =  |  |  |  |  |  |  |  |  |  =
=  |pl|pl|pl|pl|pl|pl|pl|pl|                            =  |pl|pl|pl|pl|pl|pl|pl|pl|  =
=  |rl|nl|bl|ql|kl|bl|nl|rl|                            =  |rl|nl|bl|ql|kl|bl|nl|rl|  =

=|30}}                                                  |30}}

All of the preceding examples will produce the exact same output. Namely, something that looks like this:


8
7
6
5
4
3
2
1
a b c d e f g h

This should be like the next image, produced by Template:Chess position t, but if the browser has a problem with these transparent PNG images the backgrounds below are all the same light color.

8
7
6
5
4
3
2
1
a b c d e f g h

It is also possible to number the rows and columns in code. Because everything between "|=" and the next "|" is ignored, numbers and letters can be added without affecting output at all. So the following code will produce an identical board to the one shown above:

{{Chess position|=

 1 |rd|nd|bd|qd|kd|bd|nd|rd|=
 2 |pd|pd|pd|pd|pd|pd|pd|pd|=
 3 |  |  |  |  |  |  |  |  |=
 4 |  |  |  |  |  |  |  |  |=
 5 |  |  |  |  |  |  |  |  |=
 6 |  |  |  |  |  |  |  |  |=
 7 |pl|pl|pl|pl|pl|pl|pl|pl|=
 8 |rl|nl|bl|ql|kl|bl|nl|rl|=
    a  b  c  d  e  f  g  h

|30}}

This is especially useful in the middle of a wikichess game, as it facilitates the recording of the game in algebraic notation.

Sverdrup has been working on an alternate version, that avoids the need for the "=" signs altogether by using dummy variables instead. In this way, the last several code examples would be written in almost exactly the same way, but without the "=" signs, and they would produce the same output. Sverdup's template also uses a named parameter for pixel size, so size would be specified as "size=30px", and could be included anywhere in the list of parameters. His test template is at User:Sverdrup/test3, and an example of the output is at User:Sverdrup/test4.

[edit] Floating the board to the right...

8
7
6
5
4
3
2
1
a b c d e f g h

Wikipedia allows images to be floated to the right or left by putting a "right" or "left" parameter in the image link. Unfortunately, the chess template isn't "built in" to mediawiki in the same way, and so it is necessary to manually float the image to the right or left. The best way to do this, in my (jacobolus) opinion, is to use the same <div> wrapper that mediawiki uses. That is:

<div class="thumb tright">
{{Chess position|=

 |rd|nd|bd|qd|kd|bd|nd|rd|=
 |pd|pd|pd|pd|pd|pd|pd|pd|=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |pl|pl|pl|pl|pl|pl|pl|pl|=
 |rl|nl|bl|ql|kl|bl|nl|rl|=
 
|25}}
</div>

Will produce the chess board seen to the right of the last paragraph. Note that the size used here is 25, meaning that each square is 25 pixels on a side. I'm not exactly sure why, but many pages seem to use a size of 23 pixels. I suppose it doesn't really matter.

Sorry, but this doesn't work on firefox. On my computer it looks like this:

image:chessdiagramthumbfirefox.png

Arvindn 20:07, 20 December 2005 (UTC)

I am using firfox and do not have this problem. I did have similar problems with some of the sizes of Go template. I think it is more related to a combination of screren resolution, monitor and browser. Dalf | Talk 20:24, 20 December 2005 (UTC)

[edit] ...or to the left

8
7
6
5
4
3
2
1
a b c d e f g h

To float a board to the left (as with the board to the left of this paragraph), the syntax is similar:

<div class="thumb tleft">
{{Chess position|=

 |rd|nd|bd|qd|kd|bd|nd|rd|=
 |pd|pd|pd|pd|pd|pd|pd|pd|=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |pl|pl|pl|pl|pl|pl|pl|pl|=
 |rl|nl|bl|ql|kl|bl|nl|rl|=
 
|25}}
</div>

Both of these methods are better I think than specifying the layout directly, because the "thumb tright" and "thumb tleft" classes make sure that images don't overlap. On my (jacobolus) browser at least, sometimes two tables or divs which are floated to one side or the other will overlap, driving text into the center of the page. This looks ugly. In my experience, using these classes avoids this. One possible problem with this method is that if mediawiki software ever changes/removes the "thumb tright" class, every place that class is used could be messed up. Other wikipedians have used the syntax:

{| style="float: right; margin-right: 1em;"
| {{chess position|...}}
|}

Again, in my experience, this has occasionally rendered oddly.

[edit] A note about sizes

8
7
6
5
4
3
2
1
a b c d e f g h

At the point that the size used gets too small, the height of the text labels for each row will be bigger than the squares (especially on browsers set to display big font sizes), and so for example at size 10 the boards will be broken up, and look very odd (not that that board would be readable anyway!). See the example to the right, whose code is:

<div class="thumb tright">
{{Chess position|=

 |rd|nd|bd|qd|kd|bd|nd|rd|=
 |pd|pd|pd|pd|pd|pd|pd|pd|=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |  |  |  |  |  |  |  |  |=
 |pl|pl|pl|pl|pl|pl|pl|pl|=
 |rl|nl|bl|ql|kl|bl|nl|rl|=
 
|10}}
</div>

Also, the largest size board that is achievable right now is one with 40x40 pixel squares. This is the size of the images. Conceivably, these images could be replaced with larger ones, to make larger-sized boards, but then any use of the template which didn't explicitly specify a size would suddenly become huge.

[edit] Adding captions

It should be possible to make chess board diagrams, floated to the right or left, that look just like the image thumbnails used in wikipedia. I haven't really figured out what the best way to do this is, but look at the page The Game of the Century for an example. I think this works okay, but I'm still working on getting the output to look the same as that used for pictures.

[edit] Other symbols

For making diagrams which show more than the position after a specific move, some of the creators of this template are still trying to get the template to work with "X" symbols, highlighted pieces, possibly arrows, etc. This should be possible with the addition of images showing said "X" symbols and highlighted pieces. It hasn't been done yet, however. See the discussion below for more. If it isn't immediately obvious why such niceties would be useful, see the page Chess strategy and tactics.

[edit] Discussion

Most of this discussion was copied from User:Arvindn/Chess.

Note: For a version with dummy parameters for the newlines, see User:Sverdrup/test3. Since that improvement another improvement has been made to the old version. It may be good to combine them.--Patrick 14:43, 19 May 2005 (UTC)

[edit] Parameterised Template

How about:

{{chess board|
rl|nd|bl|qd|kl|bd|nl|rd|
pd|pl|pd|pl|pd|pl|pd|pl|
_l|_d|_l|_d|_l|_d|_l|_d|
_d|_l|_d|_l|_d|_l|_d|_l|
_l|_d|_l|_d|_l|_d|_l|_d|
_d|_l|_d|_l|_d|_l|_d|_l|
Pd|Pl|Pd|Pl|Pd|Pl|Pd|Pl|
Rd|Nd|Bl|Qd|Kl|Bd|Nl|Rd}}

(or some variation thereof)

and let Template:chess board generate the image names and the table markup?

Haven't read everything in this page. Just a thought from the days when MediaWiki was introduced and implenting template parameters was being discussed. -- Paddu 21:44, 10 Jun 2004 (UTC)

On second thoughts, the colour of the square could be shifted to Template:chess board, so this gives simpler syntax -- Paddu 21:44, 10 Jun 2004 (UTC)

I did a small test, and including images with parametes doesn't seem to work. The images are left as links to the image page rather than including the image itself. Seems like we have to wait for another sw upgrade. ✏ Sverdrup 13:43, 11 Jun 2004 (UTC)
From http://test.wikipedia.org/wiki/Template_talk:Images, it looked like the parameters are passed to a template after partial-HTMLification (or partial-dewikification, if you like), so I thought the trick in making this work would involve having two templates (one recursively calling the other), but all my trial & error involving User:Paddu/sandbox and User:Paddu/chess image (both acting as templates) was fruitless. -- Paddu 16:44, 13 Jun 2004 (UTC)
I like this idea a lot. It would allow for future flexibility, including using SVG in the future (or in derivative works) simply by changing the template. David Remahl 14:08, 12 Jun 2004 (UTC)

[edit] Parameterised Template (Now working)

Currently I am able to use templates to show the board:


Newlines in parameter values are not ignored, hence a comment has to be used to allow subsequent rows to be specified in subsequent lines (leading spaces and underscores are ignored, though). An empty square can be shown in any of the following ways:

||
|_|
| |
|____    ____  _ |

-- Paddu

The following syntax is possible:

{{chess board|                          {{chess board|
|rd|nd|bd|qd|kd|bd|nd|rd|               |rd|nd|bd|qd|kd|bd|nd|rd|
|pd|pd|pd|pd|pd|pd|pd|pd|               |pd|pd|pd|pd|pd|pd|pd|pd|
|__|__|__|__|__|__|__|__|               |  |  |  |  |  |  |  |  |
|__|__|__|__|__|__|__|__|       (or)    |  |  |  |  |  |  |  |  |
|__|__|__|__|__|__|__|__|               |  |  |  |  |  |  |  |  |
|__|__|__|__|__|__|__|__|               |  |  |  |  |  |  |  |  |
|pl|pl|pl|pl|pl|pl|pl|pl|               |pl|pl|pl|pl|pl|pl|pl|pl|
|rl|nl|bl|ql|kl|bl|nl|rl|               |rl|nl|bl|ql|kl|bl|nl|rl|
}}                                      }}

if the template uses parameters 2..9, 11..18, 20..27, 29..36, 38..45, 47..54, 56..63, 65..72 for the pieces and ignores the other parameters.

(I have made these changes and introduced a size parameter, at User:Sverdrup/test3. ✏ Sverdrup 14:53, 23 Oct 2004 (UTC))

If the images being used are moved to have appropriate names, this is also possible:

{{chess board|                  {{chess board|
|r|n|b|q|k|b|n|r|               |r|n|b|q|k|b|n|r|
|p|p|p|p|p|p|p|p|               |p|p|p|p|p|p|p|p|
|_|_|_|_|_|_|_|_|               | | | | | | | | |
|_|_|_|_|_|_|_|_|       (or)    | | | | | | | | |
|_|_|_|_|_|_|_|_|               | | | | | | | | |
|_|_|_|_|_|_|_|_|               | | | | | | | | |
|P|P|P|P|P|P|P|P|               |P|P|P|P|P|P|P|P|
|R|N|B|Q|K|B|N|R|               |R|N|B|Q|K|B|N|R|
}}                              }}

-- Paddu

I think this solution is ready to publicise -- put it in a template and start using it in articles. Only thing we should discuss is whether we should move the images first or not. Also, there is a number of extra parameters that we perhaps should include. I've included size in mine, and we could possibly use an alignment parameter also. These should be easy to add though, with the parameters for pieces as numbers from {2} to {72}, and the extra parameters like {size} and other as text labels. ✏ Sverdrup 15:02, 23 Oct 2004 (UTC)
Wow! This is great! That's all I wanted to say. I'll look closer at it later. — David Remahl 22:34, 23 Oct 2004 (UTC)
We could cut the number of images required in half, and reduce loading time, by using PNGs with transparency or Unicode. However, alpha in PNGs and to some extent Unicode is poorly supported by some user agents (i.e. IE ;-), so the current solution is probably more appropriate for the time being. The fantastic thing about this solution, is that it makes migration trivial! — David Remahl 00:24, 24 Oct 2004 (UTC)
Sometimes the chess board needs to be annotated in one way or another. For simple cases, such as Image:Cb rook move.png, adding custom cells is sufficient (let xl40.png and xd40.png be light and dark squares with an x). Anyway, here are some suggestions of special cells that we could allow (I think we should specify exactly what parameters are allowed by the chess board template. One should not use the chess board template with parameters that are not specified in the template talk.):
  • An X, as in the examples above.
  • Arrow dingbats pointing in all directions.
  • White / black cells.
  • Hilighted empty and filled cells (hilighted by, for example, a coloured outline).
One thing that we may want to consider adding is an overlay. In more complex cases, an overlay may be required. An overlay is a partially transparent image (PNG) that is composited on top of something else (in this case the chess diagram). I don't know if it is possible to implement an overlay using the limited html allowed by mediawiki, nor do I know wether it can be made to work OK with 'all' browsers. We should 'KISS' for the time being.

David Remahl 09:12, 24 Oct 2004 (UTC)

[edit] Script for Parameterised Template

Ok, I've been playing today...I created a 100-line Python script for generating chess cells with various appearances. And another script for assembling {{chess board|}} syntax into a single image (for testing purposes). I put a subset of the images I generated on my laptop web server, so you can look at them: images (there are 90 of them). That URL is to a directory listing. To see the cells at full-size in a browser, use [2]. The pieces were created by editing glyphs from Arial Unicode MS. I do not think that poses a copyright problem. In any case, it is very simple to generate a new set of cells if we want to use another set of pieces (re-uploading is a different thing entirely...perhaps pywikipediabot can help.).

I also assembled the following wiki syntax (to an image), using the images in the above directory:

{{chess board|
|r|n|b|q|k|b|n|r|
|p|p|p|p.hilight|p|x|p|_|
|_|_|x|_|_|p|x|_|
|_|_|_|_|N|_|_|p|
|_|_|x|_|_|_|x|_|
|_|_|_|x|_|x|_|_|
|P|P|P|P|P|P|P|P|
|R|N|B|Q|K.hilight|B|_|R|
}}

It looks like this. The images in the directory adhere to a naming convention of: Chess_cell-[theme]-[dark or light cell]_[Piece, cap for white, lower for black, _ for empty][.effect, if any, otherwise nothing].png.

Please note that the web server is on my portable computer, so it will not be available 24/7. — David Remahl 22:22, 24 Oct 2004 (UTC)

Oh, I forgot..The images aren't named completely right. Because my filesystem is case-insensitive, it is not possible to have k.png and K.png at the same time, so I had to name one of them k-.png, for now. — David Remahl 22:38, 24 Oct 2004 (UTC)
Now I've done an interactive JavaScript application which one can use to create / modify templates like the one above. CCD. When the system is in use, I can arrange for a more permanent location for the page. I've tested it in OmniWeb and Mozilla, and it is XHTML 1 Strict compliant. Tell me if it doesn't work in your browser. — David Remahl 09:59, 25 Oct 2004 (UTC)
I thought the idea was to not have to use a generator script :-) -- No, seriously, this is great work; you've put quite a lot of time into it. I have a couple of suggestions:
  1. To make the table look clean and simple at all time, why not use two-character strings to produce all pieces and highlights. A white rook would be r_ or r , while a highlighted rook would be rx</rr>, similar to a highlighted square which is _x. Seeing to that the columns are all aligned, the syntax will be much clearer.
  2. I actually was sincere -- I don't think we should need a script to generate this. Consistent syntax, with pieces r_ to p_ and R_ to P_ together with modifiers like _x is consistent to me. Also, we could introduce other modifiers than highlighting quite easily. (You mentioned arrows; these could also be coded into a letter each).
Your example would look like:
                {{chess board|
                |r_|n_|b_|q_|k_|b_|n_|r_|
                |p_|p_|p_|px|p_|_x|p_|__|
                |__|__|_x|__|__|p_|_x|__|
                |__|__|__|__|N_|__|__|p_|
                |__|__|_x|__|__|__|_x|__|
                |__|__|__|_x|__|_x|__|__|
                |P_|P_|P_|P_|P_|P_|P_|P_|
                |R_|N_|B_|Q_|Kx|B_|__|R_|
                }}
✏ Sverdrup 15:58, 25 Oct 2004 (UTC)
I very much agree that it should be very easy to edit the template inline with the source. However, people who want a graphical way of doing it and aren't comfortable with the type of "source code" this after all is, would probably appreciate an online generator. But I never intended for it to be anything but an alternative. Mandating (by use of complicated markup) the use of as script for generation – is unwiki.
Besides, I needed an excuse to polish my xhtml 1 strict and javascript skills ;-). — David Remahl 01:35, 26 Oct 2004 (UTC)
I now see your intention with the two-characters-wide layout. I agree, that is a nice and consistent solution, one which I support. — David Remahl 01:33, 26 Oct 2004 (UTC)
As I'd said earlier, leading spaces & underscores are ignored, at least for the images that I used. Hence one need not be restricted to two character width. Assume we want two modifiers, "x" and "hi" (highlight). The following is possible:
                        {{chess board|
                        |r|__n|_b|q_|_k|_b|___n|r|
                        |p|__p|_p|px|_p|_x|___p|_|
                        |_|___|_x|__|__|_p|_xhi|_|
                        |_|___|__|__|_N|__|____|p|
                        |_|___|_x|__|__|__|___x|_|
                        |_|___|__|_x|__|_x|____|_|
                        |P|__P|_P|_P|_P|_P|___P|P|
                        |R|Nhi|_B|_Q|Kx|_B|____|R|
                        }}
One need not use diff. widths for the same board. What I want to say is that |_B|, |B|, |__B| all refer to the same image. Hence the image name is not restricted. e.g., if later we also want another modifier, we need not change the image names all over again. We could just append that modifier: |Kxhi.new_modifier| & |K| can live together. No need to change Image:foobarKbaz.png to foobarK________________baz.png or foobar________________Kbaz.png or anything. BTW David, I think I saw images named foo__bar.png in your site. They must be foo_bar.png.
BTW we could obviously use this for other board games (e.g. Go) as well, perhaps standardise on this notation by adding to the user guide. Just wanted to mention so this didn't get overlooked with chess-centric excitement. -- Paddu 17:41, 26 Oct 2004 (UTC)
PS: Wow! Remembered to sign my comment this time ;^)
However, if you want to edit the board and for example highlight a piece in the a file, you'd either have to insert 14 other _'s or break the wikitext visually. ✏ Sverdrup 17:52, 26 Oct 2004 (UTC)
I agree that two characters is the cleanest and certainly enough. Considering we have the whole Unicode repertoire at our disposal for the second character, that should be plenty :-P. I didn't understand what you said about leading spaces being ignored...That would be a bug, then, wouldn't it? — David Remahl 18:00, 26 Oct 2004 (UTC)
Oh! That 14-characters thingy was just an exaggerated example. I wanted to make the point that the no. of characters is not fixed but flexible. e.g. with the existing images, we use 2 characters (e.g. |dr|lr| instead of |r|R|). |__|dr|. produces Image:Chess_l40.pngImage:Chess_drd40.png (Note that it's Chess_l40 and not Chess__l40. That's what I mean by leading _'s ignored. Rather than a bug, I consider it a feature, see below). Now we want to add a modifier `x'. We say |___|__x|drx|_dr|. This produces Image:Chess_l40.pngImage:Chess_xd40.pngImage:Chess_drxl40.pngImage:Chess_drd40.png. Note that we need not move Image:Chess_rd40.png to Image:Chess__rd40.png. Now assume we want another modifier 'hi'. Not only can we say |____|___x|drhi|__dr| (Image:Chess_l40.pngImage:Chess_xd40.pngImage:Chess_drhil40.pngImage:Chess_drd40.png), but we can also mix the 'x' and the 'hi'. e.g. |_____|____x|drhix| (Image:Chess_l40.pngImage:Chess_xd40.pngImage:Chess_drhixl40.png), without having to invent some unintuitive letter for 'x'+'hi'. That's why I say leading-underscores-ignored is a feature, it allows flexibility. This is not to say we should start with 14 characters. I'm just saying it can be seamlessly extended. Note that in a new page if someone wants to use N different modifiers and make the cell N+2 characters wide, the existing pages with N-wide templates need not be touched at all. -- Paddu 19:30, 26 Oct 2004 (UTC)
What I'd said in the comment just above is for the current case 2 chars. per piece (|dr|lr|), but the "flexible-width" stuff holds for 1 char. per piece (|r|R|) too, only N+2 has to be substituted with N+1.
Turns out the leading-underscores-ignored is because the current images have an underscore just before the piece-name, e.g. Chess_<2 char. for piece><1 char. for colour of square>40.png. If we were to use Chess_<piece>_<square>40.png, trailing underscores would also be ignored. As we can see from my comment above (look for the sentence with the word "move"), the software treats Image:Chess_rd40.png and Image:Chess__rd40.png (or for that matter Image:Chess_______________rd40.png) as pointing to the same image. Hence it would treat Image:Chess_r_d.png, Image:Chess__r_d.png and Image:Chess_r__d.png identically. And we can use the double-underscore version to align with Image:Chess_rx_d.png. Later in another page if we want Image:Chess_rxh_d.png, we could align that with a triple-underscore Image:Chess_r___d.png, without modifying the old pages which use the single- or double-underscore versions.
Hope I'm at least a wee little bit clearer this time. -- Paddu 19:42, 26 Oct 2004 (UTC)
BTW one can use spaces instead of underscores, e.g.
|     |    x|drhix|
. -- Paddu 20:41, 26 Oct 2004 (UTC)
I'd suggest naming the images as follows:
  • Image:Chess_<squarecolour>40.png (already exist)
  • Image:Chess_<piece>_<squarecolour>40.png (e.g. Image:Chess_r_d40.png, Image:Chess_P_l40.png, etc.)
  • Image:Chess_<piece><modifier1>_<squarecolour>40.png (e.g. Image:Chess_Qx_d40.png, Image:Chess_bx_l40.png, etc.)
  • Image:Chess_<piece><modifier2>_<squarecolour>40.png
  • Image:Chess_<piece><modifier1><modifier2>_<squarecolour>40.png
  • etc.
for max. flexibility with spaces around the piece+modifier-sequence in a cell. -- Paddu 21:35, 27 Oct 2004 (UTC)
(dropping indent). We should choose _one_ naming convention and stick with it. I don't think we should aim for maximum flexibility. It is better to be strict, since that makes it easier to migrate in the future, without having to take a lot of edge-cases into account.. — David Remahl 22:28, 27 Oct 2004 (UTC)



There's a lot of information here, and I am confused. Is there some easy and confirmed way for me to put in some codes like |r|n|b|q|k|b|n|r| to draw a chess board in an article?--Sonjaaa 11:34, Dec 13, 2004 (UTC)

Yes. See Fork (chess) for an example. dbenbenn | talk 15:15, 10 Mar 2005 (UTC)

[edit] Border around board

I think the diagrams would look better with a thin border around the board. This would match the appearance used in printed books, which in my experience always have a thin solid border around the board with a small amount of padding.

Without the border, the light squares seem to bleed into the page. Compare:

Current template, no border
8
7
6
5
4
3
2
1
a b c d e f g h
Möller Attack after 9. d5
"border: solid thin; padding: 2px;"
8
7
6
5
4
3
2
1
a b c d e f g h
Möller Attack after 9. d5

What do you think? --Quale 05:46, 30 Mar 2005 (UTC)

  • Support, it does look better with a border. Sjakkalle 08:23, 30 Mar 2005 (UTC)
Seems like there's not a whole lot of interest one way or the other, so I added the border. The examples I gave immediately above look odd now since the formerly borderless example has a border, and the bordered example has two. There are 7 boards in the Slav Defense article that show what it looks like now. Quale 22:28, 6 Apr 2005 (UTC)
Now it looks really odd, as it's got a border, numbers, and then another border. ;-) --jacobolus (t) 22:32, 19 May 2005 (UTC)

[edit] Coordinates

I added square coordinates around the board because I wanted to see how it would look. I think they will help beginners (and why not more advanced players too) grasp the moves quicker. I know it's not common in chess literature to have the coordinates visible, so feel free to revert my edits if you don't think it's a good idea. --ZeroOne 23:41, 8 Apr 2005 (UTC)

That's a wonderful idea! I always had to count A, B, C, .... The labels are small, and make it much easier to find d4, for example. dbenbenn | talk 23:59, 8 Apr 2005 (UTC)
The coordinates look great, thanks. I wondered if that could be done, and you just went ahead and did it. I wonder if we should create a second template, maybe "Template:Chess position no coords" for coordinate free diagrams. Look at Slav Defense -- the coords look great on the main diagram, but I think the smaller diagrams look better packed closer together without the coordinates. Quale 03:51, 9 Apr 2005 (UTC)
Nice ones ZeroOne. Thanks. Sjakkalle 10:02, 9 Apr 2005 (UTC)

[edit] Help on the Game of Go's Parameterised Template

Inspired by how you ingeniously found a solution to create a flexible template, I created one for the Game of Go, so I could easily represent games in Wikigames for Go. (Ie. Wikigames Chess is at Wikipedia:Sandbox/Chess which relies on this template. Currently I have a demonstration Template talk:Game of Go Position, but the last row won't align, apparently because of the newline the editor keeps forcing on me, because the need for both a bottom border and a left border PLUS the "342" parameter (chess only goes up to 64) seems to generate the problem. Is there anyway to resolve this? -- Natalinasmpf 00:45, 8 May 2005 (UTC)

Partially resolved the problem by removing the border (or later trying to put it on the exterior, but new problems concerning alignment, star points, etc. which I need help with. Can someone help me playtest this? -- Natalinasmpf 01:59, 8 May 2005 (UTC)

Okay, resolved most of the issues, but I still would like testing, suggestions, etc. Considering the font sizes, and more variable things in mind. Ie. for now, examples using smaller sizes will have to use Template talk:Game of Go Position NC, which has no coordinates. -- Natalinasmpf 02:55, 8 May 2005 (UTC)

[edit] No comment tags needed

I would use dummy parameters between rows, as Sverdrup suggested, demonstrated at User:Sverdrup/test4. It requires renumbering the parameters in the template. The template could get another name than Chess position, to avoid changing pages that use that.

Alternatively:

{{chess position|=

 |rd|nd|bd|qd|kd|bd|nd|rd|=8
 |pd|pd|pd|pd|pd|pd|pd|pd|=7
 |  |  |  |  |  |  |  |  |=6
 |  |  |  |  |  |  |  |  |=5
 |  |  |  |  |  |  |  |  |=4
 |  |  |  |  |  |  |  |  |=3
 |pl|pl|pl|pl|pl|pl|pl|pl|=2
 |rl|nl|bl|ql|kl|bl|nl|rl|=1

}}

gives


8
7
6
5
4
3
2
1
a b c d e f g h

(where the numbers 1-8 are just an example, not needed) because the "=" assigns a value to an unused parameter (its name is the empty string), which has no effect.--Patrick 15:32, 19 May 2005 (UTC)

If you want numbers, this:

{{chess position| =
    a  b  c  d  e  f  g  h
 8 |rd|nd|bd|qd|kd|bd|nd|rd|= 8
 7 |pd|pd|pd|pd|pd|pd|pd|pd|= 7
 6 |  |  |  |  |  |  |  |  |= 6
 5 |  |  |  |  |  |  |  |  |= 5
 4 |  |  |  |  |  |  |  |  |= 4
 3 |  |  |  |  |  |  |  |  |= 3
 2 |pl|pl|pl|pl|pl|pl|pl|pl|= 2
 1 |rl|nl|bl|ql|kl|bl|nl|rl|= 1
    a  b  c  d  e  f  g  h 

|30}}

gives this:

8
7
6
5
4
3
2
1
a b c d e f g h

Otherwise, I'd leave them off. --jacobolus (t) 20:30, 19 May 2005 (UTC)

Good idea.--Patrick 21:51, 19 May 2005 (UTC)
The use of dummy parameters was suggested by me, not Sverdrup, as can be seen above at #Parameterised Template (Now working). My original edit. Actually my discussion of such a template in User:Arvindn/Chess predates the creation of Template:Chess position. -- Paddu 11:05, 22 January 2006 (UTC)

[edit] colour

Is it possible to change the colour? I would like to have a board like this one: http://de.wikipedia.org/wiki/Zugzwang -- 192.77.114.102 10:23, 23 May 2005 (UTC) (user tsor from german WP)

It should be possible to alter the template to allow different styles of boards. But I think it'd generally be better to just pick a single style and stick with it. If someone wants to make different designs for the pieces, though, go ahead. Maybe we should get several versions and vote? --jacobolus (t) 03:54, 25 May 2005 (UTC)
I will made an "internationalization" section, there I will talk about colors and changes of styles.--GengisKanhg (my talk) 22:42, 14 Jun 2005 (UTC)

[edit] Chess position with caption

Is it possible to create a new template for chess diagram with caption, like in The Game of the Century? It could be used like chess position template, but with one additional argument - caption. Andreas Kaufmann 16:50, 11 Jun 2005 (UTC)

Actually, the need to adapt it to have an argument is unnecessary. There is a demonstration above and below.

Ie.

{| style="margin:1em;"
|+ top caption
| style="border: solid thin; padding: 2px;" |
{{chess position| =
    a  b  c  d  e  f  g  h
 8 |rd|nd|bd|qd|kd|bd|nd|rd|= 8
 7 |pd|pd|pd|pd|pd|pd|pd|pd|= 7
 6 |  |  |  |  |  |  |  |  |= 6
 5 |  |  |  |  |  |  |  |  |= 5
 4 |  |  |  |  |  |  |  |  |= 4
 3 |  |  |  |  |  |  |  |  |= 3
 2 |pl|pl|pl|pl|pl|pl|pl|pl|= 2
 1 |rl|nl|bl|ql|kl|bl|nl|rl|= 1
    a  b  c  d  e  f  g  h 

|30}}
|-
| style="text-align:center" | bottom caption
|}

-- Natalinasmpf 19:58, 11 Jun 2005 (UTC)

top caption
8
7
6
5
4
3
2
1
a b c d e f g h
bottom caption

[edit] Internationalization

In order template`s images had been copied to Commons:Category:Chess tiles and the templated now can be used wiki world wide.

I had openned this section for talks about the use of the template for many different wikipedist from many wikipedias or wikiprojects like wikibooks.

My propose are:

  • Lets use in this section non-advanced english so most wikipedist from other wikipedias can participated.
  • Lets put together the work, ideas and talks so we together can help to improve a powerfull template.

--GengisKanhg (my talk) 23:35, 14 Jun 2005 (UTC)

[edit] About board styles

Now we have three board styles to be choose (To associate styles with languages is only for reference porpose in the current propose):

  1. German board
  2. Italian board
  3. Danish board
  4. English board Now in Commons [3]

The Danish and English are in tiles images, only the English is in Commons, the German board is waiting for making tiles from it.

[edit] Propose to template modification

Due there are more than one possible chess board for near future, I propose a modification in the template for allow an easy choose of the board and pieces color with the use of one additional parameter. So wikimedians worldwide can choose the prefered one easily. This is valid to other wikimedia projects like wikibooks and other ones.

The proposal:

  1. Firstable. Put the tiles sets on commond in separated sub-chess categories, ej.
  • Category:Chess tiles for "english" ones. (To associate styles with languages is only for reference porpose in the current propose)
  • Category:Chess tiles1 for "danish" ones.
  • Category:Chess tiles2 for "german" ones.
  • Category:Chess tiles3 for "Italian" ones

I think 11 board style for to be used worldwide are enough.

The tile images file should be named according to generalization, Based in the "english" names. "chess_xyz40.png" See. [4]

  1. Adding one parameter to the template the images names can be change between the current ones and other sets only adding one character in their names.

For example:

  • chess_xyz40.png will continue being the green square english chess project use

and

  • chess#_xyz40.png, where "#" is one character STYLE CODE (#="" nothing to english current style) will be a new set of tile images, so wikipedist or wikibook-ist (kiwimedians) worldwide can choose from one particulary style.

Particulary image file names proposed to "german" and "danish" styles (according to the number assigned in the Commons category) (See. [5]):

  • chess1_xyz40.png for "danish" style.
  • chess2_xyz40.png for "german" style.
  • and so on with new styles to be added.

--GengisKanhg (my talk) 23:27, 15 Jun 2005 (UTC)

"Italian style" added. Sabbut 05:54, 16 Jun 2005 (UTC)
As you see in Template:Chess_tiles_brown the naming of the tiles in the "Danish" solution almost follows this guideline. So the names are in the following format:
  • chs2_xyz40.png
As described in the guidelines for use this makes it possible to use the Danish tiles together with the English template - after a modification that takes 10 seconds. Sir48 - Denmark

[edit] Transparent Template

And the use of transparent templates, what about naming for those? I'm going to split the current chess template into two templates, the one that uses transparent PNG's, and the ones that don't, since there have been reported problems lately about compatability. I might name the forked off template wrongly, so if you feel its that way, tell me. I've relocated it to Template: Chess position t, which I suppose, then Template:Chess Position1 t will have their own, etc. -- Natalinasmpf 17:09, 19 Jun 2005 (UTC)

This english wikipedia "Special characters" note [6] suggest something for us. Lets look at the i-explorer solution for transparent view capability.--Gengiskanhg 00:27, 24 Jun 2005 (UTC)

[edit] About order and discuss

  1. Please look at Multiple chess tiles for make chess diagrams in Wikimedia Commons.
  2. Lets notice than this is starting to become a chaos.
  3. I propose discuss order guidelines for templates, new boards, new colors and stubs like these.
  4. My proposals are above at #Propose to template modification
  5. #Universal alternative board

Thanks for your cooperation.--GengisKanhg (my talk) 18:37, 23 Jun 2005 (UTC)


Where should be the best place to discuss about the multiple chess board possibilities and coordinate all of them?--GengisKanhg (my talk) 18:40, 23 Jun 2005 (UTC)

[edit] About using lower and capital letters on image names of pieces

Maybe is time to discuss about changing the images files to the other propose for use capital (BQK) and lower (bqk) letters either than two character code for dark and light chess pieces. This propose is simpler but it allows rectangular template invocationn either than the "squared-like" current one.

--GengisKanhg (my talk) 23:27, 15 Jun 2005 (UTC)

[edit] TeX support

  • Do you think TeX is going to make the current template unuseful?
  • Do you think TeX is going to come soon?
  • Do you think wordlwide wikimedians should wait for TeX either work on the template?

--GengisKanhg (my talk) 23:35, 14 Jun 2005 (UTC)

Depends. I've noted TeX is black and white only, and doesn't have a WYSIWYG kind of editing style, which is crucial for ease of use. Currently, it seems to only support standard chess, as well, and not variants, which is crucical for showing examples, and even in tournaments. -- Natalinasmpf 15:30, 19 Jun 2005 (UTC)

[edit] Translate aid

Hello everybody I am working at first on es.wikipedia.org,

Can you help me with information about how to translate this template?

I affraid the little images with this is based are not in wikimedia:commons, either in en.wikipedia, then the traslation to other languages are hard. Is this correct?

Can other wikipedias use templates from other languages?

Thanks --Gengiskanhg 22:43, 7 Jun 2005 (UTC)

The images are not yet at the Commons. I volunteer to put them there on next Saturday, though if someone else does it first that's fine too. This is a good opportunity to increase the resolutions; apparently the originals were 129x129 pixels.
You can't use the template directly from here. You have to copy it somewhere locally at ES. dbenbenn | talk 23:20, 7 Jun 2005 (UTC)
I will help the move of images to wikicommons, but only I wish you to propose in what category are we going to put them. (Primary working in the spanish wikipedia) --GengisKanhg (my talk) 03:49, 13 Jun 2005 (UTC)
Oops, sorry, I totally forgot about it! I suggest Commons:Category:Chess tiles, as a subcategory of Commons:Category:Chess. dbenbenn |
Finally I was copied all tile image to commons in the category you suggest. Now every wikipedia is able to use the template with only explain its use in the discussion of they particulary template--GengisKanhg (my talk) 23:53, 13 Jun 2005 (UTC)

talk 21:32, 13 Jun 2005 (UTC)

[edit] Links to equivalence discussion

[edit] Universal alternative board

I think we can create a powerful template for universal use at wikimedia with the next characteristics:

  1. Background colors (to be choosed by invocation)
  2. Piece styles (to be choosed by invocation)
  3. Algebraic notacion at the board edges with some possibilities like: 1) none, 2) At Up and right, 3) At all edges.
  4. Possibility to add "transparent backgrounded-fixed oriented arrows" on the squares for give "arrows" capability to the chess diagrams. (Can we put and images on another one on templates, so they be added in the transparency case?)

Technical Questions:

  1. Should LaTeX support will be more powerfull than this possibilities suggested???
  2. Can we make a general template and invocate it from another template which define some (but not all) of its parameters???

--GengisKanhg (my talk) 19:24, 23 Jun 2005 (UTC)

Why isn't one board style enough? I bet everyone has their favorite style and color of chessboard but in my opinion they should be consistent along Wikipedias. This was partly why this template was ever created: it allows every board to look the same. Previously there were some five different styles of chessboard images, which doesn't look very professional. --ZeroOne 09:34, 25 Jun 2005 (UTC)

[edit] Guidelines discuss

In order to create an universal template lets write, discuss and modify the general guidelines.

  • General
  1. This guidelines are in order to improved colaborative work about chess board template and images tiles of pieces creation acroos all mediawiki projects.
  2. The goal is to coordinate our work and make a powerfull chess board template useful from every wikimedia project in every language. So Commons have to be used.
  • Image of pieces
  1. In order to a set of chess tile images can be used through all wikimedia projects they should be in Commons
  2. In order they can be used by one template they should be named with a chess pieces tiles name convention (A proposal is at: #Propose to template modification)
  • Template(s)

[edit] Danish chessboard

Since I was not so fond of the green colours, I have modified the chessboard in the Danish wiki. The board can be seen here: da:skak or here (including thumb): da:pat. In addition to having another colour scheme it has a surrounding border, and lines/rows have been "numbered" on all sides. The modified template can be found here: da:Skabelon:Skak_stilling and the corresponding pictures can be found here: [7] with sample wiki-code for insertion in your article. Positions are specified in the same way as described above. If anybody wants to use this scheme instead, I shall be happy to assist. I understand English, German, and French in addition to the Scandinavian languages. User Sir48, profile in English

The template for the new board has now been uploaded to Commons as well as the necessary tiles. The template (Chess-pos2) can be seen here and offers: Board in brown colours, resizing of board, frame, thumb, control over positioning af board and text in articles and so on. Guidelines for use can be found on the talk-page. User Sir48, profile in English

Examples:


User Sir48, profile in English


I've made transparent tiles. With transparency, you only need 12 tiles (6 black pieces, 6 white) instead of 24, and you can easily change the board color. It's being tested at Template talk:Chess position t. I'd appreciate any feedback there. dbenbenn | talk 18:54, 19 Jun 2005 (UTC)

[edit] Talk about universal board

I am on GNU/Linux, I hate microsoft too. I think most wikipedians too. If we are in the free knowledge cause, a simple reflection notice us than using MS and being wikipedist are contradictory. --Gengiskanhg 19:38, 23 Jun 2005 (UTC)

This english wikipedia template [8] suggest something for us. Lets look at the i-explorer solution for transparent view capability.--Gengiskanhg 00:27, 24 Jun 2005 (UTC)

[edit] Discussion on Commons

I think the discussion about a universal solution should take place on Commons. I have created an introduction here: Universal Chessboard. User Sir48, profile in English

[edit] new template

I've just seen the new template in use and I'd like to say (1) it looks nicer, and (2) it doen't have the problem of small diagrams having shite space between the ranks (depeding on settings). So - Good job! Bubba73 03:07, August 9, 2005 (UTC)

[edit] Program to generate chess diagram templates

I've written a program to generate chess diagrams for Wikipedia It runs on Windows. Select the piece or symbol you want to drop on the chessboard in the list on the left, then click on the square. There are also areas to enter a header and footer and buttons to clear, etc. Every time you click on the board, the template is updated. Changing the footer or header does not update the diagram, but there is a button to make it update. The diagram is shown in an area on the right and you can copy and paste it. However, there is an option to have it automatically put the diagram in your clipboard, so then all you have to do is paste. This option is on by default. It is called WikiChessDiagram.exe and you can download the program here. It is freeware. I started it last night (shortly after returning from my daughter's scholastic chess tournament) and finished it today. I'm also using a new ISP for hosting the file - I'll get a web page for downloading later. Let me know of any problems, suggestions, of comments. Bubba73 (talk), 00:18, 10 December 2007 (UTC)

[edit] HAs there been a change? Different formatting

Has there been a change to the template? All of a sudden, diagrams that have a blank before the header are treating it like regular text when there is a leading space - putting it in a box and using fix-spacing font. Bubba73 (talk), 04:27, 25 January 2008 (UTC)

[edit] An idea

I just thought of two different approaches to parametizing chess positions, that would be really helpful in different kinds of match write-ups (or strategy pages) at Wiki.

System 1. Pass moves as parameters. Hence {{Chess position by move|e4|e5|Nf3}} would return the position after these moves (in sequence) from the set-up position. Very user friendly, strings from prior positions would automatically be copied from early mark-up. Suitable for match reporting and early strategy. Programming is probably prohibitive though. :(

System 2. Pass pieces as parameters. Hence {{Chess position by piece|W|Ra1|Nb1|Bc1|...|Pa2|Pb2|...|B|Ra8|...}} for the set-up (very tedious) but this system is for end games or chess problems. I imagine it would be easier to program, since it's actually just an abbreviation of the systems above -- array elements default to empty unless specified.

Well, I guess the only reason I'm proposing these is I have absolutely no idea what's involved. I expect them to be shot down. But maybe, just maybe, someone will get a spare 100 hours or so to try to make them work. ;) Alastair Haines (talk) 07:04, 10 May 2008 (UTC)