20ea851590e874881358c8b2a0a23b40312a5544
[xboard.git] / whats_new / rules / Betza.html
1 <html>
2 <header>
3 <title>(Extended) Betza notation</title>
4 </header>
5 <body>
6 <h1>Extended Betza notation</h1>
7 <p>
8 Ralph Betza invented a compact notation to encode moves of a piece,
9 which is now in wide-spread use for description of Chess variants.
10 This page describes a version of it that has been extended in several ways.
11 Some of these extensions were embraced from another proposed extension scheme,
12 '<span style="background: #00FFFF;">Bex notation</span>' by David Howe, others are entirely new.
13 These new extensions from the original Betza notation are <span style="background: yellow;">marked in yellow</span>.
14 </p><p>
15 Betza notation decomposes the piece into 'atoms',
16 which represent the set of all (8-fold-)symmetry-equivalent moves of a certain distance.
17 For example all eight Knight moves, or all diagonal moves of the King.
18 Each 'atom' is written as a single capital (e.g. N for the Knight moves),
19 which is very efficient when you are dealing with pieces that are maximally symmetric
20 (which most pieces indeed are).
21 Atoms refer to single unblockable leaps of a certain distance.
22 Pieces that can repeat the same leap again and again until they encounter an obstacle
23 (sliders or riders, such as Rook)
24 are very common.
25 Those moves are indicated by writing the number of steps the piece can maximally make behind the atom,
26 <span style="background: yellow;">where '0' can be used to indicate 'any number of steps'</span>.
27 </p>
28 <p>
29 The choice to treat moves as sets that go in all directions goes at the expense of the compactness when dealing with asymmetric pieces.
30 (This is a cheap price to pay, as asymmetric pieces are much less common than fully symmetric ones.)
31 To describe moves of asymmetric pieces Betza notation uses <i>lower-case prefixes</i> to identify which sub-set of the atom we mean.
32 Such as f (forward) or r (right), or combinarions of those like fr.
33 E.g. fR decribes a 'Rook' that only moves in the forward direction (i.e., the Shogi Lance).
34 Lower-case prefixes are also used to specify the move is not a general one
35 (i.e. valid as capture and non-capture, the normal situation in Chess-like games),
36 but can only be used in limited ways (e.g. capture only, non-jumping, capture after jumping).
37 </p>
38 <h3>The basic atoms</h3>
39 <table cellpadding="20"><tr><td>
40 <p>
41 The following table describes the most important atoms
42 </p>
43 <table border="1"><tr><th>
44 Atom
45 </th><th>
46 Vector
47 </th><th>
48 Piece
49 </th></tr><tr bgcolor="00FFFF"><td>
50 O
51 </td><td>
52 (0,0)
53 </td><td>
54 Null move (Taikyoku-Shogi Lion can do this)
55 </td></tr><tr><td>
56 W
57 </td><td>
58 (1,0)
59 </td><td>
60 Wazir (Courier Chess)
61 </td></tr><tr><td>
62 F
63 </td><td>
64 (1,1)
65 </td><td>
66 Ferz (Shatranj)
67 </td></tr><tr><td>
68 D
69 </td><td>
70 (2,0)
71 </td><td>
72 Dababba
73 </td></tr><tr><td>
74 A
75 </td><td>
76 (2,2)
77 </td><td>
78 Alfil (Shatranj)
79 </td></tr><tr><td>
80 I
81 </td><td>
82 (3,0)
83 </td><td>
84 Tripper
85 </td></tr><tr><td>
86 L
87 </td><td>
88 (3,1)
89 </td><td>
90 Long Knight (aka Camel)
91 </td></tr><tr><td>
92 J
93 </td><td>
94 (3,2)
95 </td><td>
96 Zebra
97 </td></tr><tr><td>
98 G
99 </td><td>
100 (3,3)
101 </td><td>
102
103 </td></tr></table>
104 </td><td>
105 <p>
106 Laid out on the board, (standing at O), <br>the move encoding is as follows:
107 <table border="1"><tr><td>
108 .</td><td>.</td><td>.</td><td>.</td><td>.</td><td>.</td><td>.</td><td>.</td><td>.
109 </td></tr><tr><td>
110 .</td><td>G</td><td>J</td><td>L</td><td>H</td><td>L</td><td>J</td><td>G</td><td>.
111 </td></tr><tr><td>
112 .</td><td>J</td><td>A</td><td>N</td><td>D</td><td>N</td><td>A</td><td>J</td><td>.
113 </td></tr><tr><td>
114 .</td><td>L</td><td>N</td><td>F</td><td>W</td><td>F</td><td>N</td><td>L</td><td>.
115 </td></tr><tr><td>
116 .</td><td>H</td><td>D</td><td>W</td><td>O</td><td>W</td><td>D</td><td>H</td><td>.
117 </td></tr><tr><td>
118 .</td><td>L</td><td>N</td><td>F</td><td>W</td><td>F</td><td>N</td><td>L</td><td>.
119 </td></tr><tr><td>
120 .</td><td>J</td><td>A</td><td>N</td><td>D</td><td>N</td><td>A</td><td>J</td><td>.
121 </td></tr><tr><td>
122 .</td><td>G</td><td>J</td><td>L</td><td>H</td><td>L</td><td>J</td><td>G</td><td>.
123 </td></tr><tr><td>
124 .</td><td>.</td><td>.</td><td>.</td><td>.</td><td>.</td><td>.</td><td>.</td><td>.
125 </td></tr></table>
126 </p>
127 </td></tr></table>
128 <p>
129 For longer-range atoms no letters are defined.
130 In the rare cases they occur, <span style="background: #00FFFF;">these can be written using the numeric coordinates of their leap vector</span>,
131 e.g. (4,1) for the Giraffe leap.
132 Note this still implies the move goes in all directions (i.e. (4,1) also means (4,-1), (-4,1), (1,4), ...),
133 and thus still does a lot for compactness.
134 A piece that only leaps 4 forward and 1 left or right would be an f(4,1).
135 </p>
136
137 <h3>Modifier prefixes</h3>
138 <p>
139 The following table lists possible prefixes to the atoms.
140 Prefixes can be combined, in which case the sub-sets of move types they correspond to are joined.
141 E.g. fb means forward <i>and</i> backward moves (but not sideways).
142 So even prefixes with opposite meaning are not really conflicting;
143 they could be superfluous, however.
144 (E.g. mc would mean both non-capture and capture, which is the default in absence of prefixes anyway.)
145 </p>
146 <table border="1"><tr><th>
147 prefix
148 </th><th>
149 short for
150 </th><th>
151 meaning
152 </th></tr><tr><th colspan="3">
153 Move modality
154 </th></tr><tr><td>
155 c
156 </td><td>
157 capture
158 </td><td>
159 Captures only
160 </td></tr><tr><td>
161 m
162 </td><td>
163 move
164 </td><td>
165 Move but not capture
166 </td></tr><tr><th colspan="3">
167 Move blocking
168 </th></tr><tr><td>
169 n
170 </td><td>
171 non-jumping
172 </td><td>
173 Cannot jump over occupied square
174 </td></tr><tr><td>
175 j
176 </td><td>
177 jump one
178 </td><td>
179 Must jump exactly one
180 </td></tr><tr bgcolor="FFFF00"><td>
181 jj
182 </td><td>
183 jump many
184 </td><td>
185 Can jump over any number of pieces
186 </td></tr><tr><th colspan="3">
187 Hopping
188 </th></tr><tr><td>
189 p
190 </td><td>
191 Pao (=Canon)
192 </td><td>
193 <span style="background: #FFFF00;">(Obsolete?)</span> Capture if move jumps over one obstacle, non-capture if it does not jump
194 </td></tr><tr><td>
195 g
196 </td><td>
197 Grasshopper
198 </td><td>
199 <span style="background: #FFFF00;">(Obsolete?)</span> Must land directly behind first obstacle
200 </td></tr><tr><td>
201 q
202 </td><td>
203 Circular
204 </td><td>
205 <span style="background: #FFFF00;">(Obsolete?)</span> Basic step repeated at an angle, until it closes on itself
206 </td></tr><tr><td>
207 z
208 </td><td>
209 Zig-zag
210 </td><td>
211 <span style="background: #FFFF00;">(Obsolete?)</span> Repeat step alternates angle between two values.
212 </td></tr><tr><td>
213 o
214 </td><td>
215
216 </td><td>
217 wraps around on cylinder board
218 </td></tr><tr><th colspan="3">
219 directional-subset and other geometry indicators
220 </th></tr><tr><td>
221 f
222 </td><td>
223 forward
224 </td><td>
225 most-forward single or pair of moves of symmetry-equivalent moves
226 </td></tr><tr><td>
227 b
228 </td><td>
229 backward
230 </td><td>
231 most-backward single or pair of moves of symmetry-equivalent moves
232 </td></tr><tr><td>
233 l
234 </td><td>
235 left
236 </td><td>
237 left-most single or pair of moves of symmetry-equivalent moves
238 </td></tr><tr><td>
239 r
240 </td><td>
241 right
242 </td><td>
243 right-most single or pair of moves of symmetry-equivalent moves
244 </td></tr><tr><td>
245 s
246 </td><td>
247 sideways
248 </td><td>
249 short for lr
250 </td></tr><tr><td>
251 v
252 </td><td>
253 vertical
254 </td><td>
255 short for fb
256 </td></tr><tr bgcolor="FFFF00"><td>
257 a
258 </td><td>
259 all
260 </td><td>
261 short for vs (default on atoms specifying complete move, but can be needed in chaining)
262 </td></tr><tr><td>
263 ff
264 </td><td>
265 forward
266 </td><td>
267 obsolete notation for forward-most two of 8 symmetry-equivalent moves
268 </td></tr><tr><td>
269 fh
270 </td><td>
271 forward half
272 </td><td>
273 forward-most four of 8 symmetry-equivalent moves
274 </td></tr><tr><td>
275 fs
276 </td><td>
277 sideway-forward
278 </td><td>
279 fh but not f
280 </td></tr><tr><td>
281 etc.
282 </td><td>
283
284 </td><td>
285 Similar for b (bb, bh, bs), l and r
286 </td></tr><tr bgcolor="00FFFF"><td>
287 i
288 </td><td>
289 initial
290 </td><td>
291 Initial move only (for pieces that have not moved yet)
292 </td></tr><tr bgcolor="FFFF00"><td>
293 e
294 </td><td>
295 equal
296 </td><td>
297 equal in length to previous step, measured in board steps (see section on chaining)
298 </td></tr></table>
299 <p>
300 For example, fmWfcF is a Pawn: non-captures forward to a W square, captures to the two forward F squares.
301 Pretty complicated, but the Pawn is a very complex piece (asymmetric, and divergent capture/non-capture).
302 Note that fr and rf are not the same on 'oblique' (= not orthogonal or diagonal) atoms, which have 8 moves,
303 and that they might not be what you intuitively think, as fs = fl + fr.
304 <h3>Grouping</h3>
305 <p>
306 <span style="background: #00FFFF;">Grouping of atoms, modifiers and exponents is possible with parentheses</span>.
307 This can be done for readability,
308 or for overruling operator priorities.
309 (fmW)(fcF) might read more easily than fmWfcF.
310 The parentheses do not have any meaning in themselves.
311 'Distributivity' also works for modifier prefixes:
312 m(AB) where m is a string of modifiers and A and B are atoms, (or expressions grouped in parentheses),
313 is defined to mean mAmB.
314 Some shortcuts for commonly used combinations of atoms exist;
315 these can be seen as implicit grouping of the involved atoms.
316 </p>
317 <table border="1"><tr><th>
318 shortcut
319 </th><th>
320 stands for
321 </th><th>
322 orthodox piece
323 </th></tr><tr><td>
324 K
325 </td><td>
326 WF
327 </td><td>
328 King
329 </td></tr><tr><td>
330 B
331 </td><td>
332 F0 (FF)
333 </td><td>
334 Bishop
335 </td></tr><tr><td>
336 R
337 </td><td>
338 W0 (WW)
339 </td><td>
340 Rook
341 </td></tr><tr><td>
342 Q
343 </td><td>
344 RB
345 </td><td>
346 Queen
347 </td></tr><tr bgcolor="FFFF00"><td>
348 C
349 </td><td>
350 L
351 </td><td>
352 Camel
353 </td></tr><tr bgcolor="FFFF00"><td>
354 Z
355 </td><td>
356 J
357 </td><td>
358 Zebra
359 </td></tr></table>
360
361 <h3>Chaining moves</h3>
362 <p>
363 When a number of atoms is concatenated, like WF, it joins their move sets.
364 So the piece described by WF moves either as W or as F, i.e. one step diagonal, or one step orthogonal.
365 That means it is the King of orthodox Chess!
366 (From the notation you cannot see whether it is royal yet;
367 the main purpose of the notation is to convey how it moves.
368 <span STYLE="background-color: yellow;">But a 'k' prefix could be used to indicate royalty</span>, when this is of relevance.)
369 </p>
370 <p>
371 It is also possible to specify that certain moves have to be performed sequentially, one after the other.
372 For instance because something of importance happens or should be noted on an intermediate square.
373 Such as for pieces that can be blocked on squares they cannot visit ('lame leapers'),
374 or that have to hop over other pieces in a specific pattern.
375 The simplest example of this, however, is repetition of the same step in the same direction,
376 as in sliding or riding pieces, such as a Rook.
377 The far moves of such a piece can indeed be blocked by an obstacle closer by on their path,
378 although it can then always reach that square itself as well.
379 Such moves are indicated by 'exponentiation': a number after the atom indicates how often the step may be repeated.
380 E.g. F3 would be a piece that slides diagonally (i.e. like a Bishop), upto a maximum of 3 steps.
381 To indicate an arbitrary number of steps can be taken, we use 0 (zero) for the exponent.
382 (This because infinity is not in the ASCII character set, and 0 would be pointless when taken at face value.)
383 So W0 would be the Rook, sliding arbitrarily far orthogonally, and F0 the Bishop.
384 (Old notation for this would be WW and FF, but in the extended context these would be troublesome.)
385 </p>
386 Not all multi-step moves are as regular as simple sliders, however.
387 Some 'bent' sliders can turn corners, for instance.
388 The 'Griffon' is an example that first moves one step diagonally, and <b>then</b> continues outward as a Rook.
389 It does not have to go beyond the corner, though; just like a normal Rook it can make the first step of its move only.
390 And if it encounters something on that first step, it is blocked, and never gets to the rooky part of its move.
391 To describe this trajectory we cannot use exponentiation, but have to explicitly write the chain: FtR.
392 Here the 't' is the chaining operator, that distinguishes this from FR,
393 which would mean a piece that steps one diagonally <b>or</b> moves like Rook (a Shogi Dragon Horse).
394 The 't' is because of 'and <b>t</b>hen', but also because the move could be <b>t</b>erminated at that point,
395 and there is no requirement to visit the later parts of the specified trajectory.
396 </p>
397 <p>
398 There are other forms of chaining, where the 'connecting square' can not be visited.
399 (I.e. no termination there.)
400 The Xiangqi Horse moves one orthogonal step, and then (without stopping) one step diagonally outward,
401 mimicking the move of a Knight, but blockable on the intermediate square.
402 This is written as the chain W-F.
403 The chaining operator '-' indicates the move cannot be terminated at that point (ending on the connection square),
404 but must continue.
405 If it cannot, because the square was occupied, the move described by the chain is considered blocked, and cannot be made.
406 </p>
407 <table border="1"><tr><th colspan="3">
408 Overview of chaining operators
409 </th></tr>
410 <tr><td>t</td><td>then</td><td>terminate on connection square (if empty or enemy) or continue (if empty).</td></tr>
411 <tr bgcolor="FFFF00"><td>-</td><td>block</td><td>must continue if connection square empty; otherwise entire path is considered blocked</td></tr>
412 <tr bgcolor="FFFF00"><td>+</td><td>hop</td><td>connection square must be occupied and remains untouched; move must go on from there</td></tr>
413 <tr bgcolor="FFFF00"><td>?</td><td>own</td><td>connection square must contain own piece and remains untouched; move must go on from there</td></tr>
414 <tr bgcolor="FFFF00"><td>!</td><td>foe</td><td>connection square must contain enemy and remains untouched; move must go on from there</td></tr>
415 <tr bgcolor="FFFF00"><td>x</td><td>capture</td><td>connection square must contain enemy, which is captured; move must go on from there</td></tr>
416 <tr bgcolor="FFFF00"><td>d</td><td>destroy</td><td>connection square must be occupied, friend or foe there is destroyed; must go on</td></tr>
417 <tr bgcolor="FFFF00"><td>y</td><td>split</td><td>connection square is one step before first obstacle; must continue from there</td></tr>
418 </table>
419 <p>
420 Chaining implies continuation in the most similar direction.
421 Should you need to deviate from that, e.g. because the trajectory doubles back on itself,
422 directional modifiers must be used.
423 The continuation steps are to be described in a coordinate system relative to the previous step, however.
424 So W-rW-lW makes one step, (say moving North), then turns right for another step (moving East), and then turns left compared to that second step,
425 meaning it is moving North again!
426 So in the end you arrive at (1,2), over (0,1) and (1,1).
427 This is a Knight move that can only be made if both the intermediate squares are empty,
428 even worse than the Xiangqi Horse (which at least did not care about (1,1))!
429 The latter would be described by W-F.
430 The F after '-' would by default mean fF, and in the orientation of the preceding orthogonal step
431 this would imply a pair of outward moves, fl + fr.
432 </p>
433 <p>
434 Some examples that use the other operators:
435 Q+K is the Grasshopper: it must move as Queen to an occupied square (the 'support'),
436 (the first one it encounters, as Queens do not jump!),
437 and then continue with a single K step in the same direction (leaving the occupant of the square alone),
438 to land on the square directly behind the support.
439 where it can capture or just move.
440 mRcR+R is the Xiangqi Cannon: the first mR specifies its non-capture move, which is that of a normal Rook.
441 The concatenated cR+R is the capturing alternative;
442 it moves as R to an occupied square, and then continues as R in the same direction for a capture.
443 Note that the 'c' prefix applies to the complete R+R path (a once jumping Rook);
444 the operator priorities are such that the binary operators t-+xdy couple more tightly than the prefix modifiers mc.
445 The latter are only allowed in front of a complete path, to specify what you can do at the end of it,
446 and not on individual steps of the path, where the chaining operators already specify this.
447 </p>
448 <h3>Weird captures</h3>
449 <p>
450 The x operator allows description of pieces with unconventional capture,
451 as it specifies moving away from the capture square.
452 Normal in Chess is of course that you only captured what was on the square you end on.
453 But even in orthodox Chess e.p. capture exists as an exception to that.
454 It could be written as frmWxlW, which, as we have seen, means frm(WxlW)
455 This expreses capture through a W step, and then turning left for a second W step,
456 so that overall you make an F step in an L form.
457 The frm prefix to this F step means that it can not capture <i>on the final square</i>
458 (the Pawn in e.p. capture always goes to an empty square),
459 to your forward right.
460 I.e. you started moving right, then turned left to move forward.
461 So the continuation square you pass over to remove the Pawn is to your right.
462 (There is no way to express that you can only do this to Pawns, however, let alone to Pawns that just made a double push.)
463 </p>
464 <p>
465 This shows the general encoding strategy: if you capture pieces not on your destination square, as 'side effect' to the move,
466 you lay out a path that tramples all the pieces that are captured, so that the sub-steps are all normal replacement captures.
467 E.g. a Checker would be fmFfmFxF. There the fmF part is the non-capture move,
468 but the interesting part is the capture:
469 one step diagonal (which must be to an occupied square, which we capture),
470 and then straight on (which is now 'forward' in the local frame of reference set up by the first step)
471 to the next square, for an overall A step.
472 This step must be fmA, i.e. in one of the forward diagonal directions, not capturing anything on the square where it lands.
473 'Rifle capture' by a Rook would be RxebR, i.e. first capture something in the normal way,
474 and then manditorily withdraw in the direction from which you came (b) by an R move of the same length.
475 No overall move, but the victim is gone!
476 A Ultima Withdrawer, which destroys the adjacent piece from which it moves away, would be written as
477 mQmKxbK-Q. The capture part, m(KxbK-Q) specifies capture to the adjacent piece, reversing that step (b) to your square of origin,
478 and then mandatorily continuing in that direction with a Queen non-capture move (the victim already in your pocket).
479 The hit-and-run or double capture of a Lion would be KxaK: capture the adjacent piece,
480 after which you must continue by another King step in any direction relative to the first, capturing a second victim or just moving.
481 ven the rifle capture (igui) is included in this.
482 Its turn-passing move would be K-bK.
483 Which is different from O, because it can only be done if the Lion is adacent to an empty square,
484 while a piece that has an O atom can pass uncondiionally.
485 For definiteness, when directional modifiers apply to a path that results in a return to the starting square,
486 they will be referenced to the direction of the first step of the path.
487 </p>
488 <h3>More about exponentiation</h3>
489 <p>
490 Exponentiation by default implies repeated application of the 't' operator.
491 But it can be used to indicate repeate application of other operators too.
492 <span style="background: #FFFF00;">We define AmN, with A an atom or a group within parentheses, m a string of modifiers, and N a number,
493 to mean AmAmAm...mA with N factors A and N-1 operators between them</span>.
494 If the modifier string m does not contain one of the chaining operators, it is prefixed with the default 't'.
495 If it does not include any directional modifiers, it is suffixed with 'f'.
496 So W3 means WtfWtfW, 1 to 3 orthogonal steps in the same direction (which is what the 'f' specifies).
497 But W-3 would mean W-fW-fW, which is exactly 3 such steps.
498 And Wx3 would be exactly 3 steps where the first 2 mandatorily capture.
499 </p>
500 <p>
501 By including directonal indicators, you can describe curved trajectories.
502 Nrf8 would mean NtrfNtrfN..., upto 8 Knight moves, each consecutive move bending ~45 degrees right from the previous one
503 (because that is what rf means; the first opportnity to the right that is not straight ahead).
504 This describes the Rose!
505 Circular riders fit into the system, and there is no need for a separate prefix to describe them.
506 With grouping you can do more: (FtlF)r0 expands to FtlFtrFtlFtrFtl..., an arbitrary number of diagonal steps,
507 that alternately turn 90 degrees left or right.
508 In other words, the Crooked Bishop.
509 There is also no real need for the z prefix in this extended Betza notation.
510 The exponentiation can describe it much more precisely,
511 specifying exactly how Crooked it is.
512 </p>
513 </body>
514 </html>