The Mathematics & Logic Behind Chir Bhir (Minimax, AI Algorithms & Game Tree)

The Mathematics & Logic Behind Chir Bhir (Minimax, AI Algorithms & Game Tree)

A Deep Computational Dive into How Artificial Intelligence Solves the Ancient Nine & Twelve Men's Morris Strategy Board Game

For centuries, Chir Bhir (historically known as Nine Men’s Morris, Navakankari, or Daudi) has been celebrated across rural India and classical civilizations as a test of spatial awareness, foresight, and tactical patience. On the surface, the rules appear remarkably simple: two players take turns placing and moving nine or twelve pieces on a geometric grid to form lines of three, known as a "Bhar" or "Mill", allowing them to remove an opponent’s piece.

However, beneath this intuitive board design lies a complex mathematical structure driven by combinatorial game theory, discrete graph topologies, and algorithmic Decision Trees. Today, when you play Chir Bhir on a digital screen against a computer bot, you are not merely competing against code; you are playing against high-speed mathematical evaluations powered by Minimax Search Algorithms, Alpha-Beta Pruning, and Heuristic State Scoring.

In this comprehensive guide, we will break down the complete computer science, discrete mathematics, and artificial intelligence mechanics that govern the logic of Chir Bhir.


1. Graph Theory Foundations: The Topology of Chir Bhir

To write an AI or even mathematically analyze Chir Bhir, a computer cannot view the game board as an aesthetic drawing. Instead, discrete mathematics translates the board into an undirected finite Graph Architecture $G = (V, E)$.

  • Vertices ($V$): Represents the discrete positions (intersections or nodes) where a piece (goti) can land. In 9-Men Chir Bhir, $|V| = 24$. In 12-Men Chir Bhir (with diagonal lines), $|V| = 24$ with an increased edge count.
  • Edges ($E$): Represents the valid movement pathways connecting adjacent vertices. Two nodes $u, v \in V$ share an edge $(u,v) \in E$ if a piece can move directly between them in a single turn during the movement phase.

In code, this graph is stored as an Adjacency List. For instance, node $0$ (the top-left outer corner) is directly connected only to node $1$ (top-middle) and node $9$ (left-middle). When a player attempts a move from node $A$ to node $B$, the engine performs an $O(1)$ adjacency lookup to verify if $(A, B) \in E$ and if $B$ is currently empty ($State[B] == 0$).

Furthermore, predefined Mill Sets are programmed as static arrays of triplets. For example, $M_1 = \{0, 1, 2\}$ represents the top horizontal mill. Check operations for a formed "Bhar" execute instantaneously by evaluating whether all three indices in any mill array contain identical non-zero ownership values.


2. Combinatorial Game Theory & State Space Complexity

In game theory, Chir Bhir falls strictly into the category of 2-Player Zero-Sum, Deterministic, Perfect Information Board Games:

  • Zero-Sum: A gain for Player 1 is an equal loss for Player 2. There are no shared rewards.
  • Deterministic: No randomness, dice rolls, or luck are involved. Outcome relies entirely on decision sequences.
  • Perfect Information: Both players can see the entire board state at every millisecond. No hidden cards or fog of war exist.

To understand the computational difficulty of solving Chir Bhir, mathematicians calculate its Game-Tree Complexity and State-Space Complexity:

Metric Parameter Tic-Tac-Toe Chir Bhir (9 Men's Morris) Chess
Board Intersections / Squares 9 24 Nodes 64 Squares
Legal State-Space Complexity ~$10^3$ ~$10^{10}$ (~10 Billion States) ~$10^{47}$
Game Tree Complexity ~$10^5$ ~$10^{50}$ Nodes ~$10^{123}$

Because $10^{10}$ legal states exist, a modern CPU cannot brute-force calculate every single possible outcome from turn 1 down to the final turn instantly without intelligent search optimization algorithms.


3. The Minimax Algorithm: How Computer AI Thinks

The primary core driving an artificial intelligence in Chir Bhir is the Minimax Decision Rule. The algorithm operates under a fundamental assumption: The AI (Max) wants to maximize its final score, while the Human Opponent (Min) will make the best possible moves to minimize the AI's score.

The Mathematical Principle:

Value(Node) = Max(Value(Child_1), Value(Child_2), ...)

(When it is AI's turn to pick the optimal path)


Value(Node) = Min(Value(Child_1), Value(Child_2), ...)

(When predicting the human opponent's response)

The AI creates a recursive tree structure where every level of depth represents a half-turn (ply). It calculates future outcomes 4 to 8 moves ahead before committing to a physical move on the board.


4. Alpha-Beta Pruning: Speeding Up Calculation Time

Searching every single branch in a Game Tree of depth 6 requires evaluating millions of positions per second. To make an AI respond instantly on a smartphone, developers implement Alpha-Beta Pruning.

Alpha-Beta pruning discards entire branches of the decision tree as soon as it proves that a candidate move is strictly worse than a previously evaluated alternative. It maintains two bounds throughout the recursive search:

  • Alpha ($\alpha$): The best score that the Maximizer (AI) is guaranteed to achieve so far. (Starts at $-\infty$).
  • Beta ($\beta$): The best score that the Minimizer (Human) is guaranteed to restrict the AI to so far. (Starts at $+\infty$).

Whenever a node evaluation leads to a condition where $\beta \le \alpha$, the algorithm "prunes" (cuts off) the rest of the child branches under that node. It does not waste CPU cycles exploring moves that a smart opponent would never allow the AI to reach.


5. The Heuristic Evaluation Function (The AI's Brain Score)

In a complex middle-game of Chir Bhir, the search tree cannot reach terminal states (Win or Loss) within reasonable computation time. Therefore, the search stops at a specified depth (e.g., Depth 6) and calls a Heuristic Evaluation Function $f(s)$ to judge how advantageous a board position $s$ is.

An expert-level Chir Bhir AI assigns dynamic weighted mathematical values to different tactical aspects of the board:

The Evaluation Formula:

Eval(S) = (W1 * Piece_Difference) + (W2 * Mill_Count) + (W3 * Blocked_Opponent_Pieces) + (W4 * Double_Mill_Threats) + (W5 * Freedom_of_Movement)

Key Heuristic Variables Explained:

  1. Piece Count Advantage ($W_1 = 100$): Simply counting total remaining pieces. Reducing an opponent from 4 pieces down to 3 is prioritized heavily because 3 pieces triggers the flying phase.
  2. Closed Mills ($W_2 = 50$): Rewards the creation of a 'Bhar' during the turn.
  3. Double Mill / Trample Setup ($W_4 = 150$): A setup where moving a single piece back and forth creates a mill on every consecutive turn. This is given the highest weight in middle-game strategy.
  4. Mobility / Trapping ($W_5 = 15$): Counts the total legal moves available to a player. If an opponent has 0 available moves, their evaluation drops to negative infinity ($-\infty$), signaling an immediate win by trapping!

6. The Strict No-Mill Rule & Draw Mechanics: Code Logic

A crucial rule in competitive Chir Bhir is that a piece actively forming part of an established "Bhar" (Mill) cannot be captured/removed by the opponent unless all of the opponent's remaining pieces are locked in mills.

In digital engine programming, this logic prevents crashes or infinite loops through strict conditional checks during the CAPTURE phase:

function getValidCaptures(opponentPlayer) {
  let validList = [];
  for (let i = 0; i < 24; i++) {
    if (board[i] === opponentPlayer) {
      // Check if piece belongs to a complete mill
      if (!isPartOfMill(i, opponentPlayer)) {
        validList.push(i);
      }
    }
  }
  // DRAW CONDITION RULE:
  // If ALL opponent pieces are protected in mills, capture length becomes ZERO.
  if (validList.length === 0) {
    declareMatchDraw("All pieces in Mill. Strict No-Mill Rule triggers DRAW!");
  }
  return validList;
}

This simple mathematical condition ensures fair play and prevents game-breaking deadlocks during online or local matches.


7. Human Strategy vs Algorithmic Decision-Making

Understanding how an AI processes Chir Bhir allows human players to adapt their strategic thinking:

  • Control Intersections (Nodes): Vertices with 4 connecting edges (like middle cross points) offer greater mobility ($W_5$) than 2-edge corner nodes. Algorithms prioritize these early in the placement phase.
  • Avoid Greedy Captures: A novice human player often captures any available piece immediately. A computer AI will sacrifice a capture to position a piece that seals off the opponent's entire movement path for a total trap victory.
  • Break the Double-Mill Loop: If an opponent sets up a double mill, human intervention must focus on blocking the pivot node rather than attempting to form a competing single mill.

Conclusion

Chir Bhir is far more than a simple pastime passed down through generations. It is a living model of discrete graph algorithms, decision trees, and mathematical optimization. Whether played on a traditional board carved into stone or rendered through an advanced AI mobile application like Chir Bhir Arena, the underlying beauty of the game remains rooted in pure, elegant logic.

Popular posts from this blog

Download Chir Bhir Arena App on Android: Official Installation & User Guide

Frequently Asked Questions (FAQs) About Chir Bhir Game Rules & Solutions

Chir Bhir Arena Game Feature Guide: AI Mode, Private Rooms & Custom Rules