Difference between revisions of "Help:Hex"

From HexWiki
Jump to: navigation, search
(Examples: example by visualization)
m (fixed typo)
 
(8 intermediate revisions by 3 users not shown)
Line 1: Line 1:
This is the documentation for the MediaWiki plug-in for drawing Hex diagrams.
+
;<font color="red">''This page is outdated. It describes the old <tt>&lt;hex&gt;</tt> syntax for writing Hex diagrams, which is still used on some pages of this Wiki. New diagrams should be written using the more versatile <tt>&lt;hexboard&gt;</tt> syntax described at [[New board diagrams]].''</font>
  
 
== Syntax ==
 
== Syntax ==
Line 7: Line 7:
 
The first letter of each word is called the ''command'', and the remaining letters are its ''arguments''.
 
The first letter of each word is called the ''command'', and the remaining letters are its ''arguments''.
 
There are commands for specifying the board size and for putting stones on the board.
 
There are commands for specifying the board size and for putting stones on the board.
 +
 +
=== Examples ===
 +
 +
* <tt>&lt;hex> R5 C5 &lt;/hex></tt> draws an empty hex board with 5 rows and 5 columns.
  
 
== Setting up the board ==
 
== Setting up the board ==
Line 41: Line 45:
 
When you want to add move numbers, put a single digit (0-9) between the command and the coordinate,
 
When you want to add move numbers, put a single digit (0-9) between the command and the coordinate,
 
for example '''R5e4''' when Red puts his fifth move onto e4.
 
for example '''R5e4''' when Red puts his fifth move onto e4.
 
It is also possible to link stones to any other wiki page. For that, use the form '''<nowiki>[[</nowiki>''Link_target''|''Word'']]''', where ''Word'' is used to setup the stone and ''Link_target'' is where you want to arrive when you click the link.
 
  
 
=== Examples ===
 
=== Examples ===
Line 48: Line 50:
 
* '''Ba4''' puts a blue stone ('''B''') in the first column ('''a''') of the fourth row ('''4''').
 
* '''Ba4''' puts a blue stone ('''B''') in the first column ('''a''') of the fourth row ('''4''').
 
* '''R7b1''' puts a red stone ('''R''') in the second column ('''b''') of the first row ('''1''') and labels it with a seven ('''7''').
 
* '''R7b1''' puts a red stone ('''R''') in the second column ('''b''') of the first row ('''1''') and labels it with a seven ('''7''').
* '''<nowiki>[[</nowiki>#Setting_up_single_stones|Ba5]]''' puts a blue stone on the board and links it to the section called ''Setting up single stones'' on the same page. Note that you cannot use space characters in the link.
 
  
 
<hex>
 
<hex>
 
R5 C5 Q1
 
R5 C5 Q1
Ba4 R7b1 [[#Setting_up_single_stones|Ba5]]
+
Ba4 R7b1
 
</hex>
 
</hex>
  
Line 62: Line 63:
  
 
When you want to show a complete game, it can be annoying to replace the '''H'''... and '''V'''... commands with '''M'''. For this reason, there is another feature, which automatically numbers the following stones. It is switched on with '''N:on''' and off with (you guessed it) '''N:off'''.
 
When you want to show a complete game, it can be annoying to replace the '''H'''... and '''V'''... commands with '''M'''. For this reason, there is another feature, which automatically numbers the following stones. It is switched on with '''N:on''' and off with (you guessed it) '''N:off'''.
 
=== Limitations ===
 
Currently, the number of moves is restricted to 10, but this may be extended if there is the need for it. But before you request this change, please ask yourself whether you really need it. Ten moves is a lot, and especially when analyzing games, it would be easier for the reader if you split the moves into several diagrams.
 
  
 
=== Examples ===
 
=== Examples ===
 
* '''MR Ma1 Ma2 Ma3 Mb4''' is a sequence of four moves, starting with a red ''1''.
 
* '''MR Ma1 Ma2 Ma3 Mb4''' is a sequence of four moves, starting with a red ''1''.
* '''M5a1 Ma2 Ma3''' are three moves, starting with a red ''5''.
+
* '''M5c1 Mc2 Mc3''' are three moves, starting with a red ''5''.
* '''MB Ma1 Ma2 Ma3''' are three moves, starting with a blue ''1''.
+
* '''MB Me1 Me2 Me3''' are three moves, starting with a blue ''8''.
* '''N:on Ra1 Bd7 N:off Re5''' results in two numbered moves on a1 and d7, and one unnumbered move at e5.
+
* '''N:on Rg1 Bg7 N:off Rg4''' results in two numbered moves on g1 and g7, and one unnumbered move at g4.
 +
 
 +
<hex>
 +
R11 C11 Q1
 +
MR Ma1 Ma2 Ma3 Ma4
 +
M5c1 Mc2 Mc3
 +
MB Me1 Me2 Me3
 +
N:on Rg1 Bg7 N:off Rg4
 +
</hex>
 +
 
 +
== Setting up a certain position and some moves ==
 +
 
 +
When you set up a position there are two common cases: replaying a game, or setting up an isolated position. These cases can be written easily using the following ''setup modes'':
 +
 
 +
* <tt>play</tt> is used for playing mode. The color of the stones alternates between red and blue.
 +
* <tt>red</tt> is used for putting red stones on the board. When switching to <tt>play</tt> mode later, the first move will be red's.
 +
* <tt>blue</tt> is used for putting blue stones on the board. When switching to <tt>play</tt> mode later, the first move will be blue's.
 +
 
 +
All coordinates that follow the setup mode are processed according to that mode.
 +
The following diagram shows how the setup modes can be used.
 +
 
 +
<pre>
 +
&lt;hex>
 +
R5 C9 labels
 +
play a1 a2 a3 a4
 +
red numbered c1 c2 c3 c4 unnumbered
 +
blue e1 e2 e3 e4
 +
play numbered g1 g2 g3 g4 unnumbered
 +
red play i1 i2 i3 i4
 +
&lt;/hex>
 +
</pre>
 +
 
 +
<hex>
 +
R5 C9 labels
 +
play a1 a2 a3 a4
 +
red numbered c1 c2 c3 c4 unnumbered
 +
blue e1 e2 e3 e4
 +
play numbered g1 g2 g3 g4 unnumbered
 +
red play i1 i2 i3 i4
 +
</hex>
 +
 
 +
Note:
 +
* The <tt>play</tt> mode keeps the color from before. So when you write <tt>blue</tt> (as for e1, e2, e3, e4) and then <tt>play</tt> (as for g1), the first move is blue.
 +
* To change the color of the next move you can write <tt>red</tt> <tt>play</tt>, as shown for i1.
 +
* The setup modes can be mixed freely with <tt>numbered</tt> and <tt>unnumbered</tt>.
 +
* The setup modes are useful for setting up diagrams from game records since you don't need to write the color in front of every move. Just the coordinate is enough.
 +
* The setup modes <tt>red</tt> and <tt>blue</tt> are also useful for setting up individual positions.
  
 
== Setting up a whole line at once ==
 
== Setting up a whole line at once ==
Line 87: Line 131:
 
=== Examples ===
 
=== Examples ===
 
* '''3:__BBRRBBRR__*''' sets up the first 13 stones of the third row. The first two are empty, the next two are blue, and so on.
 
* '''3:__BBRRBBRR__*''' sets up the first 13 stones of the third row. The first two are empty, the next two are blue, and so on.
 +
 +
<hex>
 +
R3 C13 Q1
 +
3:__BBRRBBRR__*
 +
</hex>
  
 
== Formatting diagrams usefully ==
 
== Formatting diagrams usefully ==
Line 101: Line 150:
 
=== A simple board with stones in all four corners ===
 
=== A simple board with stones in all four corners ===
  
 +
<pre>
 
<hex>
 
<hex>
 
R5 C5 Q1
 
R5 C5 Q1
Line 106: Line 156:
 
Be1 Ba5
 
Be1 Ba5
 
</hex>
 
</hex>
 
+
</pre>
And the same with stones that are linked to other pages.
+
  
 
<hex>
 
<hex>
 
R5 C5 Q1
 
R5 C5 Q1
[[Red|Ra1]] [[Red|Re5]]
+
Ra1 Re5
[[Blue|Be1]] [[Blue|Ba5]]
+
Be1 Ba5
 
</hex>
 
</hex>
  
 
=== Numbered moves ===
 
=== Numbered moves ===
  
 +
<pre>
 
<hex>
 
<hex>
 
R5 C5 Q1
 
R5 C5 Q1
 
Mc3 Ma3 Me3 Mb2 Md4
 
Mc3 Ma3 Me3 Mb2 Md4
 
</hex>
 
</hex>
 
+
</pre>
=== Border ===
+
You can draw a colored border around the diagram by giving the command <tt>B:on</tt>.
+
  
 
<hex>
 
<hex>
R5 C5 Q1 B:on
+
R5 C5 Q1
Ma1 Mb2 Mc3 Md4 Me5
+
Mc3 Ma3 Me3 Mb2 Md4
 
</hex>
 
</hex>
  
 
=== All possible fields ===
 
=== All possible fields ===
  
 +
<pre>
 
<hex>
 
<hex>
 
Q1 C11 R4
 
Q1 C11 R4
Line 139: Line 188:
 
Ma4 Mb4 Mc4 Md4 Me4 Mf4 Mg4 Mh4 Mi4 Mj4 Mk4
 
Ma4 Mb4 Mc4 Md4 Me4 Mf4 Mg4 Mh4 Mi4 Mj4 Mk4
 
</hex>
 
</hex>
 +
</pre>
  
== Source code ==
+
<hex>
 
+
Q1 C11 R4
The full source code of the plug-in is available [http://www.hexwiki.org/mediawiki-common/extensions/hex2/ here].
+
Ra1 R1b1 R2c1 R3d1 R4e1 R5f1 R6g1 R7h1 R8i1 R9j1 R0k1
 +
Ba2 B1b2 B2c2 B3d2 B4e2 B5f2 B6g2 B7h2 B8i2 B9j2 B0k2
 +
Sa3 *b3 Pd3 +e3
 +
Ma4 Mb4 Mc4 Md4 Me4 Mf4 Mg4 Mh4 Mi4 Mj4 Mk4
 +
</hex>

Latest revision as of 21:47, 10 December 2020

This page is outdated. It describes the old <hex> syntax for writing Hex diagrams, which is still used on some pages of this Wiki. New diagrams should be written using the more versatile <hexboard> syntax described at New board diagrams.

Syntax

Hex diagrams are specified using the <hex>...</hex> tag. Inside this tag, a series of words describes the diagram itself. The first letter of each word is called the command, and the remaining letters are its arguments. There are commands for specifying the board size and for putting stones on the board.

Examples

  • <hex> R5 C5 </hex> draws an empty hex board with 5 rows and 5 columns.

Setting up the board

Before doing anything else, you have to say how large the board is. Each board has a number of rows (which go horizontally) and columns (which go vertically). In addition to that, you can say that you want the rows and colums labelled with their letters and numbers.

The commands for setting up the board all take a single numeric argument. The commands are:

  • R: Specifies the number of rows of the board.
  • C: Specifies the number of columns of the board.
  • Q: Specifies whether the coordinates should be printed next to the board. Zero means no, any other number means yes. By default, they are not shown.

Examples

  • R5 sets the number of rows to 5.
  • Q1 makes the coordinates appear next to the board.
  • Q0 explicitly makes the coordinates disappear.
  • <hex>R5 C5 Q1</hex> creates a board with five rows and five colums, which are all labelled.
abcde12345

Setting up single stones

The commands for setting up stones all take a coordinate as their argument. Coordinates are written in the form f7, where f is the column and 7 is the row.

The commands are:

  • B for a blue stone.
  • R for a red stone.
  • H for a horizontal stone (equivalent to B).
  • V for a vertical stone (equivalent to R).
  • S or * for a star.
  • P or + for a plus.

When you want to add move numbers, put a single digit (0-9) between the command and the coordinate, for example R5e4 when Red puts his fifth move onto e4.

Examples

  • Ba4 puts a blue stone (B) in the first column (a) of the fourth row (4).
  • R7b1 puts a red stone (R) in the second column (b) of the first row (1) and labels it with a seven (7).
abcde123457

Automatically numbered moves

There is a special command (M) for setting up numbered sequences of moves. The first of these moves is for Red and is labelled with a 1. After each M command, the color changes and the move number is increased automatically.

If you want to enter a sequence of moves that starts with a blue move, write MB. This changes the color without affecting the move number or the stones on the board.

When you want to show a complete game, it can be annoying to replace the H... and V... commands with M. For this reason, there is another feature, which automatically numbers the following stones. It is switched on with N:on and off with (you guessed it) N:off.

Examples

  • MR Ma1 Ma2 Ma3 Mb4 is a sequence of four moves, starting with a red 1.
  • M5c1 Mc2 Mc3 are three moves, starting with a red 5.
  • MB Me1 Me2 Me3 are three moves, starting with a blue 8.
  • N:on Rg1 Bg7 N:off Rg4 results in two numbered moves on g1 and g7, and one unnumbered move at g4.
abcdefghijk1234567891011158112693710412

Setting up a certain position and some moves

When you set up a position there are two common cases: replaying a game, or setting up an isolated position. These cases can be written easily using the following setup modes:

  • play is used for playing mode. The color of the stones alternates between red and blue.
  • red is used for putting red stones on the board. When switching to play mode later, the first move will be red's.
  • blue is used for putting blue stones on the board. When switching to play mode later, the first move will be blue's.

All coordinates that follow the setup mode are processed according to that mode. The following diagram shows how the setup modes can be used.

<hex>
R5 C9 labels
play a1 a2 a3 a4
red numbered c1 c2 c3 c4 unnumbered
blue e1 e2 e3 e4
play numbered g1 g2 g3 g4 unnumbered
red play i1 i2 i3 i4
</hex>
abcdefghi1234515263748

Note:

  • The play mode keeps the color from before. So when you write blue (as for e1, e2, e3, e4) and then play (as for g1), the first move is blue.
  • To change the color of the next move you can write red play, as shown for i1.
  • The setup modes can be mixed freely with numbered and unnumbered.
  • The setup modes are useful for setting up diagrams from game records since you don't need to write the color in front of every move. Just the coordinate is enough.
  • The setup modes red and blue are also useful for setting up individual positions.

Setting up a whole line at once

In many cases, there are many stones on the board, and it would be annoying to write one word for each stone. For this reason, there exists a short-cut for drawing a complete line. If a word starts with a number, followed by a colon (:) and a list of cell contents, the whole line can be drawn with only one command. The valid types of cell contents are:

  • R or V for red stones,
  • B or H for blue stones,
  • * or S for stars,
  • + or P for plus,
  • _ for an empty cell.

Limitations

  • Stones with numbers cannot be put using this command. Instead, use the commands for putting a single stone or for putting a series of moves.

Examples

  • 3:__BBRRBBRR__* sets up the first 13 stones of the third row. The first two are empty, the next two are blue, and so on.
abcdefghijklm123

Formatting diagrams usefully

Depending on the situation and the intent of a diagram, it may be formatted in different styles. Large diagrams should be distributed over several lines, to make editing and reading easier. The suggested format is:

  1. Board size and coordinates,
  2. Setup stones: One line per color,
  3. The moves in the order they are played.

See the diagrams below for examples.

Examples for Complete Diagrams

A simple board with stones in all four corners

<hex>
R5 C5 Q1
Ra1 Re5
Be1 Ba5
</hex>
abcde12345

Numbered moves

<hex>
R5 C5 Q1
Mc3 Ma3 Me3 Mb2 Md4
</hex>
abcde1234542135

All possible fields

<hex>
Q1 C11 R4
Ra1 R1b1 R2c1 R3d1 R4e1 R5f1 R6g1 R7h1 R8i1 R9j1 R0k1
Ba2 B1b2 B2c2 B3d2 B4e2 B5f2 B6g2 B7h2 B8i2 B9j2 B0k2
Sa3 *b3 Pd3 +e3
Ma4 Mb4 Mc4 Md4 Me4 Mf4 Mg4 Mh4 Mi4 Mj4 Mk4
</hex>
abcdefghijk12341234567891234567891234567891011