Sunday, December 10, 2017

Mancala AI

My kids were into mancala for a little while this year, and so I made a version of it that you (mainly my kids) can play in a web browser.  A secondary reason to do it was to explore more about the game and its strategies.
Looks like south has a pretty good lead here...

There are around 650 billion board positions (depending on which rule set you use, here I'm focusing on "Kalah").  In the year 2000, someone at Caltech found the winning strategy for it - that is, they solved it so we can now know what the best move is in each position.  The player that goes first has a slight advantage in random play.  

For a simple human-player strategy, we could learn from the "Advanced Heuristic Minimax", which uses the following principles, weighing the earlier ones more strongly than the later ones:
  • Maximize the amount of counters in your own store.
  • Keep the opponents score to a minimum.
  • Prefer to move the counters from your right-most pit.
  • Have as many moves as possible from which to choose.
  • Hoard as many counters as possible in the left-most pit.
  • Keep as many counters on your own side as possible.
Below is a link to the online version I made, which has four computer opponent choices: Random Rachel just picks each move randomly.  Greedy Greg moves to take as many pieces as he can, choosing randomly when he can't capture.  Minnie Max uses a minimax strategy, looking ahead about 8 moves.  And then there's Foolish Frank, who also uses minimax, but makes the worst move he can find.




No comments:

Post a Comment