- Attackers: The King is captured, or the King and all his remaining defenders are encircled and cannot move.
- Defenders: The King reaches one of the 4 corner squares.
A higher resolution is required to access the IDE
Learning Opportunities
This puzzle can be solved using the following concepts. Practice using these concepts and improve your skills.
Statement
Brandubh
The Goal
Note: The Defenders control the King as well as the regular defending pieces.
Rules
For complete details, you can consult the official rules PDF. Note the following deviations for this CodinGame adaptation:
- The official rules use the terms "black" and "white" instead of "Attackers" and "Defenders".
- Point 10 (a full game is played in two sets) is irrelevant. Every CodinGame match is a single game.
- The concept of a turn limit doesn't exist in the official rules but is used here to prevent infinite games.
Board & Coordinates: The game is played on a 7x7 board. Every game starts from the standard opening position as described in the official rules. The board uses standard chess notation, where columns are
Movement: The Attackers always move first. All pieces move orthogonally (like a rook in chess) any number of empty squares. Pieces cannot jump over other pieces.
The Throne and Corners: The center square (3,3) is the Throne. The 4 corner squares are the escape zones. Only the King can stop on the Throne or the corners. Other pieces can pass over the Throne if it is empty, but cannot land on it.
Hostile Pieces: The opponent's pieces are considered hostile pieces. The Throne and the corners also act as hostile pieces for the purpose of capturing.
The Throne's Hostility: The Throne is always hostile to Attackers. However, it is only hostile to Defenders if the King is not currently standing on it. The Throne is never hostile to the King.
Capturing: A piece (attacker or defender) is captured if it is flanked on two opposite sides by hostile pieces.
Capturing the King: The King is captured like any other piece, except when he is on the Throne. If the King is on the Throne, he must be surrounded on all 4 sides to be captured.
Game End: The game ends immediately when a victory or defeat condition is met. If neither side wins after 200 turns (100 rounds), a draw is declared.
Source Code: The source code for this game (Referee) is available on GitHub.
- You have no valid moves available.
- You repeat the exact same board position 3 times (3-fold repetition rule).
- Your program provides an invalid move.
- Your program times out.
Game Input
Line 1: role - an integer representing your role (
Line 2: lastAction - a string representing the opponent's last move (e.g.,
Next 7 lines: A
. : Empty squareA : Attacker pieceD : Defender pieceK : The King
- start_square: The starting square of the piece you want to move (e.g.
d2 ). - end_square: The destination square for that piece (e.g.
d4 ).
A higher resolution is required to access the IDE