Today"s guest blogger is Anoush Najarian that leads the MATLAB performance Team at yellowcomic.com. And while she mostly concentrates on help MATLAB run fast, in she spare time, she likes to use MATLAB for hobby jobs in robotics, math, and games.
You are watching: How to win mancala in one move
Contents
Winning at Mancala
Let me tell you what occurred when i got exhausted of shedding at Mancala, and decided to write some MATLAB password to play it. Shout-out to my daughter, 6th grader Natalie, for introducing me come the game, and also being a partner in these experiments.

Now, over there are numerous ways to play the gamings in the Mancala family. The rule collection we created the code for is: you pick from any kind of hole, and drop one rock at a time when circling the plank in counterclockwise fashion, drop a stone into your house whenever you pass with it. If girlfriend drop your last rock into her home, you get a "free" turn. If friend drop her last stone into a non-empty hole, you obtain to proceed with what I speak to an "automatic" move, choose up all stones from that hole. In the intial position, there are four stones in every hole.
See more: How Many Moles Are Present In 17.4 G Of Lead To Moles, How Many Moles Are Present In 17

You know exactly how some games have a first-player advantage? It turns out that in Mancala, girlfriend can uncover a means not just to success (which is nice), however to victory all the marbles (awesome), and also to execute so on her very an initial move!
% below is driver password to discover (one the many!)% all-48-marble-win-on-first-move solutions, which operation in ~20s top top my% laptop!gametrees = 0 <4 4 4 4 4 4 4 4 4 4 4 4> <>;nummoves = 0;while nummoves % display screen one highest-score entry for g = 1:L

Some that the various other Mancala rule sets the end there include: no "free" move, no "automatic" move, only picking indigenous the side of the plank you space sitting following to, different number of holes, marbles!
For example, mean "automatic" move and complimentary moves room allowed, but you deserve to only location on your side that the board. Then you still have the right to can win catching a pretty outstanding 42 marbles on your very first move! Tiny change on heat 18 of the driver code (loop 1:6 instead of 1:12) will offer you the succession of theatre to use for this variation!
What"s Next?What we"d really favor to develop up to below is to usage the game-playing code for cultivate the AI. We newly watched interesting videos favor Deep learning in 11 lines of MATLAB Code, and are passionate to try deep reinforcement finding out for games.