From: Benjamin Auder Date: Sat, 13 Jun 2026 00:13:10 +0000 (+0200) Subject: Finish Empire variant X-Git-Url: https://git.auder.net/css/doc/html/assets/scripts/DESCRIPTION?a=commitdiff_plain;ds=inline;p=xogo.git Finish Empire variant --- diff --git a/variants/Empire/class.js b/variants/Empire/class.js index df80d2e..64b2156 100644 --- a/variants/Empire/class.js +++ b/variants/Empire/class.js @@ -79,6 +79,25 @@ export default class EmpireRules extends ChessRules { } filterValid(moves) { + // Sub-function to check a path (between kings) + const scanPath = (start, end, justOne) => { + let s = [end[0] - start[0], end[1] - start[1]]; + for (const i in [0, 1]) { + if (s[i] != 0) + s[i] = s[i] / Math.abs(s[i]); + } + let onPath = {}; + let [i, j] = [start[0] + s[0], start[1] + s[1]]; + while (i != end[0] || j != end[1]) { + if (this.board[i][j] != "") { + onPath[i + "." + j] = true; + if (justOne) + return true; + } + [i, j] = [i + s[0], j + s[1]]; + } + return (justOne ? false : onPath); + }; const kp = { 'w': super.searchKingPos('w')[0], 'b': super.searchKingPos('b')[0] @@ -89,21 +108,39 @@ export default class EmpireRules extends ChessRules { // Filter out moves letting kings facing each other if ( !pf && - [m.start, m.end].every(xy => { - return ['w','b'].every(c => xy.x != kp[c][0] || xy.y != kp[c][1]); - }) + ['w','b'].every(c => m.start.x != kp[c][0] || m.start.y != kp[c][1]) ) { - // King don't face each other and don't move + // Kings don't face each other and don't move return true; } if (pf) { // Check that current move doesn't clear the path between kings - // TODO: apply vanish / appear on the path (horizontal or vertical) - return true; + const onPath = scanPath(kp['b'], kp['w']); + m.vanish.forEach(v => { + const key = v.x + "." + v.y; + if (onPath[key]) + onPath[key] = false; + }); + if (Object.values(onPath).some(z => z)) + return true; + for (const a of m.appear) { + const key = a.x + "." + a.y; + if (Object.keys(onPath).includes(key)) + return true; + } + return false; } - // Situation: a king moves. Does it lead to a forbidden configuration ? - // TODO: check alignment, then check path (same as above). - return true; + // A king moves. Does it lead to a forbidden configuration ? + const kc = + ['w','b'].filter(c => m.start.x == kp[c][0] && m.start.y == kp[c][1]); + const oppCol = C.GetOppTurn(kc); + if (kp[oppCol][0] != m.end.x && kp[oppCol][1] != m.end.y) + return true; + // Potentially yes: + this.playOnBoard(m); + const valid = scanPath(kp[oppCol], [m.end.x, m.end.y], true); + this.undoOnBoard(m); + return valid; }); } diff --git a/variants/Empire/complete_rules.html b/variants/Empire/complete_rules.html new file mode 100644 index 0000000..7fc2a1b --- /dev/null +++ b/variants/Empire/complete_rules.html @@ -0,0 +1,134 @@ + + + Empire Rules + + + + +
+

Empire Rules

+ +
+

+ The player in first has a different set of pieces, + moving generally like a queen but capturing (almost) as usual. +

+
+ +
Initial deterministic setup.
+
+

+ Empire Chess is a chess variant designed in 2020 by Couch Tomato, the + third asymmetric game. This game pits the army of the "Empire" (gold) + against the original chess army (the "Kingdom", black). The Empire's + unique feature is that its pieces move like queens but attack differently. +

+
+ +

General Rules

+
    +
  1. The Empire (gold) always moves first.
  2. +
  3. The Empire cannot castle.
  4. +
  5. + As the Empire's pawns start on the third rank, they do not have the + option to move two spaces or be captured by en passant. +
  6. +
  7. Pawns on either side can only promote to a queen.
  8. +
  9. + One can win by bringing the king into the final rank without being + check. This situation is called "campmate". +
  10. +
  11. Stalemate and repetition are both losses.
  12. +
  13. + The King and Kaiser (Imperial King) may not face + each other on a file or rank. +
  14. +
+ +

Imperial Pieces

+
+

+ There are five new units unique to the Empire: Siege Towers, Eagles, + Cardinals, Duke, and Soldiers. The bottom rank pieces are all stronger + than their Kingdom counterparts with the exception of the Duke. +

+
    +
  • + Kaiser (K) — The Imperial king is called the Kaiser and has a + different symbol, but the change is purely aesthetic and thematic: + it behave like an orthodox king. +
  • +
  • + Soldier (S) — The Soldiers are the two pawn-like pieces replacing + the two middle pawns. They can move one square orthogonally forward, + or lateraly. +
  • +
+

+ The remaining pieces are "divergent" pieces: they move differently + than they attack (such as pawns). Imperial pieces all move as queens, + but attack like their Kingdom counterpart except for the Duke. +

+
    +
  • + Siege Tower (T) — The Siege Tower, or Tower for short, + attacks like a Rook. +
  • +
  • Eagle (E) — The Eagle attacks like a Knight.
  • +
  • Cardinal (C) — The Cardinal attacks like a Bishop.
  • +
  • Duke (D) — The Duke attacks like a King.
  • +
+
+ +
Eagle's moves (green) & captures (red).
+
+
+ +

Pieces valuation

+
+

The following simplified values can be used:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Kingdom pieceValuesImperial piece
Pawn1 / 1Pawn
Queen9 / 4Duke
Bishop3 / 4Cardinal
Knight3 / 7Eagle
Rook5 / 7Siege Tower
- - / 2Soldier
+
+ +

More information

+

+ See + Empire Chess + on pychess.org, where you can also play this variant (among many others !). +

diff --git a/variants/Empire/rules.html b/variants/Empire/rules.html index c65158e..01f8682 100644 --- a/variants/Empire/rules.html +++ b/variants/Empire/rules.html @@ -1 +1,19 @@ -

TODO

+

+ Two different armies: yellow pieces ("kingdom") generally move and + capture in two different ways. Tower, Eagle, Cardinal and Duke, initially + from square a1 to d1, all move like a queen, but capture respectively + like a rook, knight, bishop and king. +

+

+ The two "big pawns" in the middle are soldiers, they move and capture in + the same way, forward one square or laterally. +

+

Win by checkmate or by crossing the board with your king.

+ +

+ + Full rules description. + +

+ +

Couch Tomato (2020).