模板:Chess diagram/sandbox
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
这是Template:Chess diagram(差异)的沙盒。 参见本模板的测试样例。 |
此模板使用Lua语言: |
使用方法
这里有几个国际象棋图表的模板:
- Template:Chess diagram(方格大小26x26 px)
- Template:Chess diagram small(方格大小22x22 px)
- Template:Chess diagram 4x4(方格大小26x26 px)
- Template:Chess diagram 5x5(方格大小26x26 px)
- Template:Chess diagram 8x10(卡帕布兰卡象棋,方格大小26x26 px)
- Template:Chess diagram 10x10(方格大小26x26 px)
- 如果想显示其它棋盘大小,就用{{#invoke:chessboard mxn|board|cols=|rows=
这里也有为国际象棋变体而设的模版:
- Template:Alice chess diagram(爱丽丝象棋,方格大小22x22 px)
- Template:Omega Chess diagram (欧梅加象棋,是一个有四个角落的10x10棋盘、方格大小22x22 px)
以上模板所使用的文法,基本上是相同的。
{{Chess diagram | <排列> (參數#1) | <標題> (#2) | size = | numbers = | letters = | <a8> | <b8> | ... | <h8> (#3 to ... | <a7> | <b7> | ... | <h7> ... | <a1> | <b1> | ... | <h1> ( ... #66) | <脚注> (#67) | reverse = }}
当棋盘大小为8x8,可以用另一种文法。(see #Alternative way to place the pieces: FEN below):
{{Chess diagram | fen = | align = | clear = | header = | footer = | size = | numbers = | letters = | reverse = }}
参数:
<排列>
– “tleft”会令模板泊向左方,而“tright”则会泊向右方<標題>
– 这是会出现在棋盘上方的文字(可以留空)size
- 用像素指明每个方格的大小,预设为26numbers
- 指明代表行的数字在哪里显示。可以填入:left、right、both(预设)或neither。letters
- 指明代表列的字母在哪里显示。可以填入:top、bottom、both(预设)或neither。<a8>, <b8>, ... <h1>
– 指明对应方格显示什么棋子。下面有详细说明。<脚注>
– 这是会出现在棋盘下方的文字(可以留空)
一个方格是由棋子的名称或空白的参数定义。棋子是由代数记谱法命名:
- a = 大主教(马+象的合体,可以代表公主)
- c = 首相(马+车的合体,可以代表皇帝)
- f = 倒转的王(可以代表丈夫)
- g = 倒转的后(可以代表蚱蜢)
- m = 倒转的车(可以代表洞屋、跳跃者、或者华西尔)
- j(e) = 大象(可以代表象或者维齐尔)
- N(s) = 倒转的马(可以代表骆驼、麒麟、梦魇、或者凤凰)
- h = 倒转的兵(可以代表贝罗利纳兵)
- z = 欧梅加象棋的勇
- w = 欧梅加象棋的巫
- t = 欧梅加象棋的傻
- M = 另外一个可以代表丈夫的符号
- C = 亚马逊
这些字母与“l”(代表白棋)和“d”(代表黑棋)组合来使用。所以“kl”是白王,而“nd”则是黑马。
一个空的方格可以用下划线、空格或者什么都不打来表达。建议使用两个空格。
你也可以用“xx”代表黑色交叉、“ox”代表白色交叉、“xo”代表黑色圆圈或者“oo”代表白色圆圈。
当你想表示棋子的移动方向,就可以用箭头:
数字也可以放入方格——“x0”代表0、“x1”代表1、“x2”代表2、⋯、“x9”代表9。
范例
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.
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
{{Chess diagram | tright | |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 | The King's Gambit }}
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
{{Chess diagram | tright | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 空板 }}
两行脚注
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
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 | | | | |kd| | |rd | | | | | | | | | | | | | |bl| |pl | | | |rl| |kl|pd|pl | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | '''Mate in two.''' <br> This problem uses ''partial retrograde analysis'' method. }}
无脚注
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
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 | | | | | | | | | | | | | | | | | | |xx|xo|xx| | | | | | |pl| | | | | | | | | | |xo| | | | | | |xx|xo|xx| | | | | | |pl| | | | | | | | | | }}
Movement example
This can be used to show how pieces move.
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
{{Chess diagram | tleft | | | |ua| | | | | | | |ua| | | | | |la|la|rd|ra|ra|ra|ra|ra | | |da| | | | | | | |da| |ul|ua|ur| | | |da| |la|kl|ra| | | |da| |dl|da|dr| | | |da| | | | | |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. }}
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
{{Chess diagram | tright | | |ul| |ua| |ur| | | | |ul|ua|ur| | | |la|la|la|ql|ra|ra|ra|ra | | |dl|da|dr| | | | |dl| |da| |dr| | |dl| | |da| | |dr| | | | |da| | | |dr | | | |da| | | | }}
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:
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
{{Chess diagram | tleft | | | | | | | | | | | |ud| | | | | | |lr|rd|lr| | | | | | |ud| | | | | | | | | |ul|ua|ur| | | | | |la|kl|ra| | | | | |dl|da|dr| | | | | | | | | }}
小图
This one may be useful in articles with many diagrams. It uses another template named {{Chess diagram small}}.
The small diagrams can have header, too.
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
{{Chess diagram small | tright | |rd| | |qd| |rd|kd| |pd|pd| | |pd|pd|bd|pd | |nd|pd| | |nd|pd| | | |ql| | | |bl| | | | |pl|pl| |bd| | | |nl| | |nl| | |pl|pl| | | |pl|pl|pl | | | |rl|kl|bl| |rl | Position after 11.Bg5 }}
不同板子尺寸
Chess boards of non-standard dimensions need special templates. There are templates for the following boards:
{{Chess diagram 5x5 | tright | |kd|qd|bd|nd|rd |pd|pd|pd|pd|pd | | | | | |pl|pl|pl|pl|pl |kl|ql|bl|nl|rl | Gardner minichess }} |
{{Chess diagram 8x10 | tright | |rd|nd|ad|bd|qd|kd|bd|cd|nd|rd |pd|pd|pd|pd|pd|pd|pd|pd|pd|pd | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |pl|pl|pl|pl|pl|pl|pl|pl|pl|pl |rl|nl|al|bl|ql|kl|bl|cl|nl|rl | Capablanca Chess }} |
{{Chess diagram 10x10 | tright | |rd| | | | | | | | |rd | |nd|bd|qd|kd|cd|ad|bd|nd| |pd|pd|pd|pd|pd|pd|pd|pd|pd|pd | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |pl|pl|pl|pl|pl|pl|pl|pl|pl|pl | |nl|bl|ql|kl|cl|al|bl|nl| |rl| | | | | | | | |rl | Grand Chess }} |
{{alice chess diagram | tright | |rd|nd|bd|qd|kd| |nd|rd |pd|pd|pd|pd| |pd|pd|pd | | | | | | | | | | | | |nl| | | | | | | | | | | | | | | | | | | |pl|pl|pl|pl|pl|pl|pl|pl |rl|nl|bl|ql|kl|bl| |rl | | | | | | | | | | | | | | | | | | | | |pd| | | | | |bd| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Position after '''1. Nf3 e6 2. Ne5 Bc5''' }} |
Different shaped board
{{Omega Chess diagram
|
| [[Omega Chess]] (10×10 + 4 corners)
|wd |wd
|zd|rd|nd|bd|qd|kd|bd|nd|rd|zd
|pd|pd|pd|pd|pd|pd|pd|pd|pd|pd
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
| | | | | | | | | |
|pl|pl|pl|pl|pl|pl|pl|pl|pl|pl
|zl|rl|nl|bl|ql|kl|bl|nl|rl|zl
|wl |wl
| '''Omega Chess''' starting position
}}
|
Omega Chess (10x10 + 4 corners)
|
Alternative way to place the pieces: FEN
{{Chess diagram|fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR|align=tleft}}
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
It is possible to populate the board 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}}
a | b | c | d | e | f | g | h | ||
8 | 8 | ||||||||
7 | 7 | ||||||||
6 | 6 | ||||||||
5 | 5 | ||||||||
4 | 4 | ||||||||
3 | 3 | ||||||||
2 | 2 | ||||||||
1 | 1 | ||||||||
a | b | c | d | e | f | g | h |
It is also possible to show "fairy" pieces using the FEN notation. However, because the FEN notation uses uppercase and lowercase to denote the color of the piece, it is not possible to display the inverted 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 boards, positional parameters should be used.
Displaying the board from the Black's point of view
{{Chess diagram|fen=rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR|align=tleft|reverse=true}}
h | g | f | e | d | c | b | a | ||
1 | 1 | ||||||||
2 | 2 | ||||||||
3 | 3 | ||||||||
4 | 4 | ||||||||
5 | 5 | ||||||||
6 | 6 | ||||||||
7 | 7 | ||||||||
8 | 8 | ||||||||
h | g | f | e | d | c | b | a |
The "reverse=true" parameter causes the board to be shown from Black's point of view, that is, with the h8 square at lower-left corner, and a1 at the upper-right. This works for all sizes of the normal chessboard template, but not for the Alice, Bughouse, Omega, or Raumschach templates. Here, the same FEN notation as in the previous example produces a board with Black's starting position at the bottom.
参见
- {{Xiangqi diagram}}