2
Simple Mancala Game
Create a mancala game using as few bytes as possible.
The game
Mancala is a family of games where a player has a control over a set amount of pots filled with stones/seeds. The particular version which you should implement has a board with 14 pots, of which two are designated as scoring pots. At the start of the game the scoring pots are empty and each of the other pots contains 4 stones. On each player's turn they select one non-empty non-scoring pot, remove the stones from it, and starting with the next pot counter-clockwise they place one stone per pot, moving counterclockwise, until they have placed them all.
Unlike some other variants, there is no way to get a second turn. Once the stones from one pot have been redistributed, the play passes to the other play.
The game ends when all the stones are in the scoring pots, so that there is no valid move remaining.
The challenge
Implement a simple program to allow two players to play against each other at a shared computer. No AI is required.
For the purposes of input, the pots are labelled as shown:
(R1H1)[R1P6][R1P5][R1P4][R1P3][R1P2][R1P1]
[R2P1][R2P2][R2P3][R2P4][R2P5][R2P6](R2H1)
The scoring pots are (R1H1)
and (R2H1)
.
The input will be a list of pots separated by a semicolon: e.g. R2P3;R2P1
. These represent the moves in order from left to right. You may assume that each move is valid.
The output will be the number of stones in each pot after the input moves have been performed. The output need not use brackets in the same way as the diagram above or the examples below, but the pots must be distinguishable and the scoring pots should also be clearly distinguished from regular ones.
Worked example
The initial board position is
(0)[4][4][4][4][4][4]
[4][4][4][4][4][4](0)
Given input R2P3
the output should be
(0)[4][4][4][4][4][4]
[4][4][0][5][5][5](1)
placing the four stones from R2P3
in the first four pots working counter-clockwise from R2P3
.
Given input R2P3;R2P1
the output should be
(0)[4][4][4][4][4][4]
[0][5][1][6][6][5](1)
2Welcome to PPCG! It might be better to specify the output. Also you should put the [tag:code-golf] tag for these criterias. – Matthew Roh – 2017-02-05T03:50:17.907
I am voting to close this as unclear because as it currently stands it does not indicate input and output. It also needs a winning criterion as suggested. – Post Rock Garf Hunter – 2017-02-05T04:03:41.900
I revised it, should've helped – Sine_ – 2017-02-05T04:06:22.637
Please put Input/Output in codeblocks (backtick in each side or four spaces) – Matthew Roh – 2017-02-05T04:07:17.503
2
Also, the Sandbox might be able to help you.
– Matthew Roh – 2017-02-05T04:08:14.997I fixed it up, should be fine now, correct? Sorry, I'm quite obviously new to this. – Sine_ – 2017-02-05T04:11:00.250
@Sine_, it still contains much ambiguity. I highly recommend that you post your question in the Sandbox, where you can receive constructive feedback on your challenge ideas.
– Daniel – 2017-02-05T04:13:42.560@Dopapp linking is
[name](link)
, not(name)[link]
– Matthew Roh – 2017-02-05T04:15:11.653What's
R
andP
in the input? – clismique – 2017-02-05T04:20:35.843Row and Pot, edited to include so – Sine_ – 2017-02-05T04:22:03.397
Also, do we accept only one input for one move only? – clismique – 2017-02-05T05:01:26.560
Fixed for both the inquiries in chat and this one – Sine_ – 2017-02-05T05:21:53.220
>
My revisions should have fixed this, but I'm not sure what you mean when you ask how a turn works. – Sine_ – 2017-02-05T07:15:28.210
This looks like an interesting challenge. My understanding is that we need to take all stones contained in the designated pot. However, this is not explicitly said anywhere. If you clarify this point and show the intermediate steps between
R2P3
andR2P1
, this should be much clearer. Also, you may want to be more flexible about the input format (accepting an array of moves instead of the semicolon-separated list, for instance). – Arnauld – 2017-02-05T21:08:57.2702The edits answered my questions, although I've rewritten it to try to separate out the game rules from the challenge. Before I vote to reopen I would like to ask (as Arnauld has) how flexible you are on the input format. Personally I would allow labelling the pots
0
to13
or1
to14
in clockwise or anti-clockwise order, so long as the answer clearly specifies the convention followed. That allows people to focus on the game logic rather than on parsing the pot labels. – Peter Taylor – 2017-02-05T22:20:05.847I suppose as long as the input is in some kind of sequence and not labeled randomly, it would be quite aright – Sine_ – 2017-02-17T19:00:10.093