Formal Specification
The Mill (Ukrainian Nine Men's Morris) — Formal Specification
Ukraine · board-abstract · Confidence: medium
← Back to game pageImplementation Suitability
Suitability: engine-readyFidelity: directGap-fills: 0
# Mlyn (Млин) — AI-optimized specification
## General idea
The classic Ukrainian Nine Men's Morris alignment strategy board game (*Mlyn*, *Mlynok*, or *Kozatskyi mlyn*). Two players take turns placing and sliding nine tokens across a 24-vertex planar graph of three concentric squares. Aligning three friendly pieces along a grid line forms a "mill" (*млин*), which grinds away (captures) an opposing piece. A player reduced to two pieces or immobilized by blockade loses the match.
## Formal model
- **Board Graph:** Planar graph where vertices (Outer ring: , Middle ring: , Inner ring: ) connected by side midpoints (edges ).
- **Mill Set :** 16 triplets of collinear vertices (8 perimeter lines and 8 radial connector lines).
- **Player count:** 2 players (, ).
- **Turn model:** Strictly alternating sequential turns ().
## Formal rules
R1. Setup & Inventory:
- Board starts empty: `board[v] = EMPTY` for all .
- Reserves: `unplaced[P1] = 9`, `unplaced[P2] = 9`.
- Active pieces on board: `pieces_on_board[P1] = 0`, `pieces_on_board[P2] = 0`.
- Turn tracker: `active_player = P1`, `halfmove_clock = 0` (capture counter).
R2. Phase 1 — Placement (*Виставлення*):
- While `unplaced[active_player] > 0`:
- Active player submits `place_piece(v)` where `board[v] == EMPTY`.
- `board[v] = active_player`, `unplaced[active_player] -= 1`, `pieces_on_board[active_player] += 1`.
- If vertex completes a mill :
- Player immediately submits `capture_piece(u)` targeting an opponent piece.
- **Protected Mill Rule:** Target must satisfy `board[u] == opponent` and , UNLESS all opponent pieces on the board are currently in mills.
- `board[u] = EMPTY`, `pieces_on_board[opponent] -= 1`, `halfmove_clock = 0`.
- Turn passes to the opposing player.
R3. Phase 2 — Sliding Movement (*Пересування*):
- When both players have `unplaced == 0` and `pieces_on_board > 3`:
- Active player submits `slide_piece(src, dst)` where `board[src] == active_player`, `board[dst] == EMPTY`, and .
- `board[src] = EMPTY`, `board[dst] = active_player`, `halfmove_clock += 1`.
- If move completes a new mill (including opening and re-closing a mill, *перемикання млина*):
- Player executes `capture_piece(u)` subject to the Protected Mill Rule.
- `halfmove_clock = 0`.
R4. Phase 3 — Flying (*Стрибки / Вільний хід*):
- If `pieces_on_board[active_player] == 3` and `unplaced[active_player] == 0`:
- Active player's pieces gain the flying property.
- Player submits `fly_piece(src, dst)` where `board[src] == active_player` and `board[dst] == EMPTY` (ignoring edge adjacency ).
- Forming a mill triggers a capture as in Phase 2.
R5. Terminal Win Conditions:
- **Elimination:** A player reduced to `pieces_on_board < 3` after all reserve pieces are placed loses immediately.
- **Blockade (Stalemate):** A player who has `unplaced == 0`, `pieces_on_board > 3`, and has no legal slide moves on their turn loses immediately.
R6. Draw Conditions:
- **50-Move Rule:** If 50 consecutive half-moves elapse without a piece capture (`halfmove_clock >= 50`), the game is declared a draw (*нічия*).
- **Threefold Repetition:** If the exact same global board configuration (vertex occupancy and active player) occurs three times, a draw is declared.
## Edge cases
- Tie at the end condition: Standard combinatorial draw via 50-move rule or threefold repetition.
- A player with no legal move: Blockade results in an immediate loss for the immobilized player.
- Repetition / cycles: Threefold repetition rule prevents infinite cyclical shuffling.
- Simultaneous claims on the same position: Strictly sequential turn-based execution; vertices are mutually exclusive.
- Elimination mid-round: Evaluated immediately upon capture; reducing an opponent to 2 pieces triggers terminal victory.
- Resource exhaustion: Fixed graph of 24 vertices and 18 total pieces.
- Termination guarantee: The 50-move non-capture counter and 3-fold repetition rule provably guarantee finite game termination.
## State representation
- Persistent state:
- `board`: Array of 24 cells .
- `unplaced_white`: Integer .
- `unplaced_black`: Integer .
- `halfmove_clock`: Integer .
- `active_player`: Enum .
- `position_history`: Map of BoardHash integer frequency.
- Information set: Perfect information; fully observable deterministic board state.
## Action space
- `place_piece(dst)`: Drop piece during Phase 1 ().
- `slide_piece(src, dst)`: Move piece along connected edge during Phase 2.
- `fly_piece(src, dst)`: Jump piece to any empty vertex during Phase 3.
- `capture_piece(target)`: Remove eligible opponent token upon mill completion.
## Playability notes
- Single-player-vs-AI: Perfect candidate for alpha-beta minimax with bitboards or MCTS. Fast evaluation functions assess open mill threats, cross-mill pivots (*вилка* / double-mill setups), and mobility graphs.
- Group reduction: Strict 2-player abstract game.
- What is lost: The rustic charm of playing with charred hazel pegs on a carved wooden tavern board, and the traditional Cossack banter (*«млин меле — мука буде!»*).
## Implementation hints
Represent 24-vertex board as a 32-bit integer bitboard per player. Pre-calculate 16 bitmasks for mill triplets and 24 bitmasks for adjacent neighbor graphs. First milestone: implement bitwise mill detection and drop/slide validation before adding the 50-move draw counter and Minimax AI search.
Download as JSON
Download the full game corpus entry for this game as structured JSON.
Download JSONCite this page
The Mill (Ukrainian Nine Men's Morris) (Ukraine). (n.d.). Games of Countries. https://gamesofcountries.com/games/ua-ukraine/mlyn
@misc{gamesofcountries-ua-ukraine-mlyn,
title = {The Mill (Ukrainian Nine Men's Morris) (Ukraine)},
year = {n.d.},
publisher = {Games of Countries},
url = {https://gamesofcountries.com/games/ua-ukraine/mlyn}
}