← Mancala against the computer

Mancala Strategy: the Best First Move, Extra Turns and How to Beat the Computer

The game on this site is Kalah with six pits a side and four seeds in each. We solved it exactly for the rules this page uses, compared every rule of thumb with the exact value of each move in 3,000 positions, and played the page's own code for all three levels: 10,000 games for each figure against Easy, 400 against Hard, 200 against Expert. The winning line over Hard was replayed move by move on the real engine.
The short answer

On these rules the player who moves first wins 28:20 with perfect play, and only two first moves win at all: the third pit from the left (then the sixth), or the sixth pit alone. When a move that ends in your store is available, it is the exactly best move in 93.5% of positions; the biggest capture is best in only 58%. The Hard level here always answers the same way, and seven fixed clicks beat it every time: 6, 3, 3, 1, 3, 1, 3.

Which Mancala this page plays

“Mancala” covers hundreds of games, and advice for one does not carry over to another. The game here is Kalah: six pits a side, four seeds in each, 48 seeds in all, so 25 in your store wins. The details that matter for strategy:

  • You always move first. Seeds go anticlockwise, one per pit; your own store gets one on the way, the computer's store is skipped.
  • If the last seed lands in your store, you move again — as many times in a row as you can manage.
  • If the last seed lands in an empty pit on your side and the pit facing it holds seeds, you take those seeds and your own. If the facing pit is empty, nothing is captured and your seed stays where it fell.
  • A pit with 13 seeds goes all the way round and ends where it started. That pit is empty at that moment, so this is a capture as well.
  • The game stops the moment either side's six pits are empty — even in the middle of your chain of extra turns — and the other player banks everything still in front of him.
Its store123456Your store
Computer0444444
You4444440

The page shows no labels, so here your pits are numbered 1 to 6 from the left; pit 6 is the one next to your store. A pit in the top row is called by the number of your pit it faces: “top 5” is the computer's pit above your pit 5.

The best first move, exactly

The game is small enough to solve. For the rules above, perfect play by both sides ends 28:20 for the player who moves first — that is you. But the first click already decides whether that win is still there:

Your first clickResult with perfect play afterwards
Pit 117:31loses
Pit 219:29loses
Pit 328:20wins, and gives an extra turn
Pit 423:25loses
Pit 520:28loses
Pit 626:22wins

Pit 3 holds four seeds and stands four steps from your store, so it is the only first move that earns an extra turn. What you do with that turn matters just as much:

After pit 3, your second clickResult with perfect play afterwards
Pit 628:20
Pit 526:22
Pit 425:23
Pit 224:24, a draw
Pit 121:27
Its store123456Your store
Computer0445555
You4405502

This is the board after 3 and then 6: two seeds banked and four of the computer's pits loaded with five. Its best reply is top 5, which keeps the result at 28:20; every other reply loses by more, from 29:19 to 33:15. The extra turn itself can be priced exactly: if the turn passed to the computer right after pit 3, perfect play would end 23:25. The second move in a row is worth ten seeds.

Solved with our own program for this page's rules (capture only when the facing pit holds seeds). The solver was checked against a plain exhaustive search built on the page's own move code in 400 positions, with no disagreement. That Kalah with six pits and four seeds is a first-player win has been known since 2000.

Extra turns: the one rule that is almost always right

To see which rules of thumb hold up, we took 3,000 positions from games between two decent players and computed the exact value of every legal move in each. An extra turn was on offer in 53% of them. Taking it — with the rightmost pit that qualifies — was the exactly best move in 93.5% of those positions and cost 0.23 seeds on average. The best move that passed the turn instead was 3.15 seeds worse on average.

  • A pit earns an extra turn when its seed count equals its distance to the store: one seed in pit 6, two in pit 5, three in pit 4, and so on up to six in pit 1.
  • With several such pits, start from the right. Where two or more were available, playing the rightmost first was best in 97.9% of positions; starting from the left was best in 38.2% and cost 3.7 seeds on average. A move from a left pit drops a seed into the pits to its right and spoils their count; a move from the right touches nothing behind it.
  • Count the whole chain before the first click. In games between equal players 68% of turns were a single move, 21% were two moves and 11% three or more; the longest ran to 14.

The side that took more extra turns won 75% of those games. Part of that is the first move itself: the player who started took 10.6 extra turns a game on average, the other 4.7.

Captures: smaller and less reliable than they look

A capture feels like the big play of the game, but most are small. Between equal players there were about five captures a game, and 69% of them took exactly two seeds: one from the facing pit plus your own. A capture of eight or more happened in one game in five.

Nor is the biggest capture a safe choice. Where a capture was available and an extra turn was not, the biggest capture was the exactly best move in 58% of positions and cost 3.3 seeds on average. Where both were available, the extra turn was right in 91% of positions and the capture in 49%. So the order is: extra turn first, then look at the capture — and before taking it, check what your move leaves facing the computer's empty pits.

Defence is the same idea turned round. A computer pit that is empty, or that its move will reach with a last seed, is a threat to whatever you hold in the pit below it. A simple rule that takes the extra turn, then the biggest capture, and otherwise picks the move after which the computer's best capture is smallest wins 62% of games against Easy; the same rule without the last check wins 55%.

Pit 6: leave the pile alone

Seeds in your rightmost pit can go only two ways: one into your store and the rest across to the computer's side. In positions where pit 6 held two or more seeds and another move existed, emptying it was the best move in just 27% of cases and cost 6.9 seeds on average; the best other move cost 0.5. With six or more seeds in it, emptying it was right in 19% and cost 8.3.

There is a second reason to keep seeds at home. When the computer's side runs out, everything on your side goes to your store. The winning line over Hard below is built on nothing else: before the last click you have banked 3 seeds against 17, and still win.

Its store123456Your store
Computer17110000
You11024723

A blanket ban is not a strategy, though. A rule that never touches pit 6 unless it earns an extra turn, and otherwise plays without thought, did worse against Easy than the same rule without the ban: 41.5% against 55%. Keep the pile when you have a useful move elsewhere, not at any price.

How to beat each level here

Here is how simple ways of choosing a move do against each level. You move first; where a rule leaves a choice, it is made at random.

Your rulevs Easyvs Hardvs Expert*
A random legal move2.1%0%0%
Always the rightmost pit that holds seeds36%0%–
Easy's own rule: whatever banks the most right now55%5.0%0%
Extra turn, else the biggest capture, else random55%2.8%–
Extra turn, else the biggest capture, else the move that leaves the computer the smallest capture62%5.3%5.0%
Think it through: your move, its reply, your next move97.5%––

* Expert is limited by time (about a third of a second), so how far it looks depends on the device. The Expert column was simulated at a fixed depth of nine handovers, which is what it completed in the middle of the game on our computer; Hard always looks eight. 10,000 games per figure against Easy, 400 against Hard, 200 against Expert. The last row is the page's own search set to three handovers, playing your side. A dash means not simulated.

Easy is stronger than its name: it takes whatever banks the most seeds this move, and a random player beats it in two games out of a hundred. Its weakness is that it never looks at your reply. One-move rules win about half the games against it; reading three steps — your move, its answer, your next move — wins 97.5%. It breaks ties at random, so no fixed list of moves works against it.

Hard, in seven clicks. Hard involves no chance: the same position always gets the same reply, so a game that beats it once beats it every time. Click pits 6, 3, 3, 1, 3, 1, 3. No shorter win exists — we checked every sequence of six clicks or fewer.

ClickYour pitHard answersStores, you : Hard
16top 11:1
23top 5, top 1, top 6, top 1, top 4 — four extra turns2:6
33top 5, capturing 72:13
41 (your extra turn)–3:13
53top 1, top 23:15
61top 1, top 33:17
73top 1, then top 2, capturing 2 — and its side is empty28:20

Hard values a banked seed six times as much as a seed on the board, so it hurries its seeds into the store and across to you until its own row is bare; the 25 seeds on your side then go to your store. Expert has no such recipe: its depth depends on the device, and this line does not finish the game against it at depth nine or ten. It is not far above Hard, though. By the exact values, Hard picks the best move in 82% of positions and gives up 0.7 seeds a move on average, and in our test games the page's own search set to only four handovers, moving first with pit 6, beat Expert at depth nine 26:22.

The rules of thumb, in order of value

  1. Open with pit 3, then pit 6. No other first turn keeps the full 28:20.
  2. Take an extra turn whenever one is there, starting with the rightmost pit that earns it.
  3. Leave the pile in pit 6 alone while you have a useful move elsewhere.
  4. Before a capture, and before any quiet move, look at what the computer can capture in reply.
  5. Remember how the game ends: when one row is empty, the other player banks his whole row. Seeds on your side are yours.

Followed blindly, the simplest version of this list — extra turn, else the biggest capture, else the rightmost pit — picks the exactly best move in 72% of positions and gives up two seeds a move. Hard gives up 0.7. The difference is looking at the reply.

Questions and answers

What is the best first move in Mancala?

In Kalah with four seeds per pit, the third pit from your left: its last seed lands in your store and you move again. Then play the pit next to your store. With perfect play that opening wins 28:20 on the rules used here; the only other winning first move is the pit next to the store, 26:22.

Does the first player always win at Mancala?

With perfect play, yes: Kalah with six pits and four seeds is a win for the player who starts, 28:20 on this page's rules by our own solution. In practice the edge is large but not decisive: between two equal computer players the one who started won 73.5% of 10,000 games.

Should you always take the extra turn?

Almost always. In 3,000 positions checked against the exact solution, taking the extra turn with the rightmost pit that earns it was the best move in 93.5% of cases. When several pits earn one, play them from right to left.

Is it better to capture or to take a free turn?

The free turn. Where both were possible, the extra turn was the exactly best move in 91% of positions and the biggest capture in 49%. Most captures are small: 69% of them take just two seeds.

Should you keep seeds in the pit next to your store?

Usually yes. When that pit holds two or more seeds, emptying it is the best move in only 27% of positions and costs about seven seeds on average, because all but one of them go to the opponent. And seeds left on your side are yours when the game ends.

Can you beat the computer at Mancala?

Yes. The Hard level here is fully predictable, and seven clicks beat it every time: pits 6, 3, 3, 1, 3, 1, 3, counting from the left, for a 28:20 win. Easy and Expert have no fixed recipe; against Easy, reading your move, its reply and your next move wins 97.5% of games.

What rules does this Mancala use?

Kalah: six pits a side, four seeds each, sowing anticlockwise. A last seed in your store gives another move; a last seed in an empty pit of yours captures the facing pit if it holds seeds. The game ends when either row is empty, and the other player keeps what is left on his side.

Play Mancala against the computer →
Where to go from here
To cite this page: “Mancala Strategy: the Best First Move, Extra Turns and How to Beat the Computer”, You vs Computer, https://youvscomputer.com/games/mancala-strategy.html