Mancala

I will put a web version of this game onto this page in the near future. In the meantime you can download and play a java version from my public github repository.

# Mancala

A Java Swing implementation of the classic Mancala board game featuring a single-player mode against a minimax AI opponent, animated stone sowing, synthesized sound effects, and a persistent high-score leaderboard.

## Features

**AI Opponent** — Minimax algorithm with alpha-beta pruning at three difficulty levels

**Animated Gameplay** — Stone sowing flight animations, capture flashes, and gem pulse effects

**High-Score Leaderboard** — Top 10 scores persisted locally, sortable by score and time

**Player Profiles** — Name persistence across sessions

**Customizable Setup** — Choose 4, 5, or 6 starting stones per pit

**Programmatic Board Rendering** — Pixel-perfect board drawn with Java2D (no image assets needed for the board)

## Gameplay

### Board Layout

[P2 Store] [12][11][10][ 9][ 8][ 7]

[P1 Store] [ 0][ 1][ 2][ 3][ 4][ 5]

– Pits 0–5: Player 1 (bottom row)

– Pits 7–12: Player 2 / Computer (top row)

– Indices 6 and 13: Stores

### Rules

1. On your turn, click any of your non-empty pits.

2. Stones are distributed counter-clockwise, one per pit (your opponent’s store is skipped).

3. **Extra Turn** — If the last stone lands in your store, you get another move.

4. **Capture** — If the last stone lands in an empty pit on your side and the opposite pit is not empty, you capture both pits’ stones into your store.

5. The game ends when either player has no stones remaining in their pits. All remaining stones go to their respective stores.

6. The player with the most stones in their store wins.

### Difficulty Levels

| Easy | 1-ply | 80% random, 20% optimal |

| Medium | 3-ply | 45% random, 55% optimal |

| Hard | 9-ply | Always plays optimally |

On easy and medium levels you will see a guide to where your last stone will land when you hover over a pit.