Game of Cabeza and its engine
Rules
Cabeza is a two player strategy game played on a 10x10 board. Each player has 5 different pieces in the game at all times. The pieces are:
- Mini 1 x 1 x 1 block
- Flaco 2 x 1 x 1 block
- Chato 2 x 2 x 1 block
- Opa 2 x 2 x 2 block
- Cabeza 1 x 1 disk
Except for the cabeza, the rest of the pieces consist of rectangular prisms which are always aligned to the board grid.
The players (red and blue) take turns, starting with red. In each turn a player has to choose a single piece and move it once or twice according to the rules. All block pieces move by rotating along one of its edges that touch the grid, effectively "rolling" from one position to another.
All pieces can be rotated once or twice per turn, except for the Opa (2x2x2) piece which can only be moved once per turn.
The Cabeza (meaning head in spanish) moves by sliding to a neighbouring square, including its four diagonal neighbours. (Similar to the king in chess). This piece can slide once or twice per turn. If a diagonal slide motion is blocked by the edge of a piece, it can pass through. But if a diagonal slide requires cutting through the edges of two pieces, then it cannot pass through.
Some example moves:
Null moves aren't allowed. Moves that result in a piece stepping outside the board are forbidden. Landing on a square occuped by another piece of either player are also not allowed. Except for a block piece landing on the opponent's Cabeza piece (see Winning). This rules apply even to intermediate moves of a turn.
The starting position is as follows: (M=Mini F=Flaco H=Chato O=Opa C=Cabeza)
A player wins by performing a move that either:
- Places a block piece on top of the opponent's Cabeza piece
- Places the player's cabeza to the oponents home row
Engine
An engine was developed for finding the best move given a position. It can be found in this repositoryNotation
A move is represented by a 2 to 5 letter string. The first letter represents the piece:
- c / C : Cabeza
- m / M : Mini
- f / F : Flaco
- h / H : Chato
- o / O : Opa
Uppercase letters represent red pieces and lowercase letters represent blue pieces.
This is followed by a combination of n, s, e, w,
representing the cardinal directions (north, south, east, west) of rolling or sliding moves.
Directions are defined assuming the board is oriented with red starting on the south
and blue starting on the north.
For a Cabeza piece, a diagonal move can be represented by a combination of North/South with East/West.
For Cabeza and Mini pieces where move order is irrelevant, north (n) and south (s)
are always written before east (e) and west (w).
For example:
Fne: Represents the red Flaco rolling north once and then rolling east.ms: Represents the blue Mini rolling south once.-
Cnne: Represents the red Cabeza sliding northeast once and north once (order is irrelevant for Cabeza). -
Fen: Represents the red Flaco rolling east once and then north. Note: this is not the same move asFne. ow: Represents the blue Opa rolling west once.
Commands
draw/d- Draws the board on screen using characters.
move/m[move]- Plays a move for the current active player and switches turn.
turn/t[player]-
Switches the turn. If no argument is passed, toggles the turn.
Use
red/rorblue/bto set explicitly. search/s- Performs a search to find the best move for the current player.
play/P- Same as search, but automatically plays the best move and switches turns.
fen[fen]- Prints a FEN-like string if no argument is passed. If a valid FEN string is provided, sets the current game state.
undo/u- Reverts the last performed move.
reset- Resets the game to the starting position.
timeout[time]- Sets the search time limit in milliseconds.
depth[depth]- Sets the maximum search depth.
quit- Exits the program.