📜 ⬆️ ⬇️

Few nice mancalas

Although the label was the wrong color and contained many spelling errors, most of it was in place, including the inscription “ May contain nuts ” in tiny font.
sir terry pratchett

Go or ur ? One can argue for a long time which of the games is older, but it will win, in this confrontation, most likely, Mancala . Archaeologists prefer to deal with material evidence, but as soon as it comes to board games, everything quickly goes into the realm of speculation. It was found a lot of boards, but much less information about how to play them. The ancients did not bother with a detailed description of the rules.

With Mancala, the situation is exactly the opposite. This is not a single game, but a very numerous family. In West Africa alone, there are dozens (if not hundreds) of varieties. Board (as a material artifact) for such games is not required. It is enough to take a handful of pebbles and dig a few holes in the sand. Not surprisingly, archaeologists have difficulty determining the age of these games. They simply have nothing to look for! But for the attentive researcher of the "board games", mancalas are no less interesting than the birds of the Mockingbird family for Charles Darwin .

To date, the directory Zillions of Games contains more than two thousand applications . It cannot be said that there were no mancal among them at all. In any case, the double-row and four-row versions of games are presented very thoroughly. Here is a set of games provided by just one of the applications:


This is indeed a worthy list, but, as I wrote above, the number of mancal is in the hundreds, and here are the most familiar of them, let's say. There are much more amazing and wonderful varieties of this game. And now I want to do them! But for a start, it is worth making a small glossary of terms so that people who are not familiar with the subject have at least some chance to figure it out.
')
Dictionary
  • sowing - In most of the nations practicing them, mancalas symbolize habitual agricultural activities. The seeding metaphor unites all these games. Carrying out the course, the player takes all the stones from one of his holes and starts laying them out one by one , in all the following holes, in one of the directions allowed by the rules. There are various proverbs and sayings that link the tactics of the game with agricultural concepts, similar to the Russian version of "what you sow, come around."
  • single seeding - In a large number of game variants, “seeding” is performed “once”. After the player lays out the last of the stones taken (it does not matter if it is an empty or filled hole), the turn passes to another player. There are various “seeding” options that make it difficult to calculate in the game. For example, sowing may not start from the next hole, but from the current one (that is, one stone just stays in the hole) or the starting hole may be skipped when sowing, if the number of stones taken is enough to make one or more circles, bypassing all the holes .
  • Cyclic sowing - A more complicated variation of the course. The course begins as well as “single seeding”, but if a player lays out the last stone in the filled hole, he immediately takes all the stones from it (including the one added last) and continues seeding from the next hole. The course ends when the last stone falls into an empty hole.
  • infinite sowing - As it is easy to guess, performing a “cyclic sowing”, the player may well “get hung up”. The player will not be able to complete the move, since the last stone will never fall into an empty hole. Such a situation is called “endless seeding” and the reaction to it is governed by the rules of a particular game. Usually, in the event of the “endless sowing”, the game is considered not played or replayed.
  • capture - The goal of almost any mancala (there are a few exceptions) - the capture of the maximum number of stones. The rules for transferring stones from the board to your “barn” vary significantly, depending on the game. In double-rowed mankals, the rules of capture are often associated with the number of stones in the final hole (for example, in Togyz Kumalak , the capture is performed if after adding the last stone of sowing the number of stones in the hole has become even). In the four-row mancala, since the sowing goes only through its territory, the capture is “positional” (in Chuba , if the last stone fell into the empty hole of the inner row, all the stones from the opposing hole in the enemy’s internal row, as well as the stones from the outer hole behind it row, if they are there).
  • serial capture - Often, capture is done from several wells at once. For example, in Wari , a player captures stones if there are 2 or 3 stones in the last hole of the crop. If in the previous (in the direction of sowing) the enemy's holes also turned out to have 2 or 3 stones, they are also captured!
  • full capture - In most mancal, the player will not be able to complete the move, left without stones. Often, in such cases, the game ends. All stones remaining on the territory of the enemy are shifted to his barn, and then counted. This is quite a normal completion of the game, but in order to make the game more interesting, rules are introduced that aim to increase the duration of the game. For example, the rules may prohibit the execution of moves leading to the seizure of all remaining stones in the enemy’s territory, the so-called “full capture”.
  • the rule of "hunger" - The other side of the same coin. If the enemy is left without stones on his side, the player must “feed up” him by throwing at least one stone into foreign territory. If such a move is impossible - the game ends. This is one of the examples of a very rare type of forced moves for mancal, which are similar to compulsory taking in Checkers or leaving a check in Chess .
  • zero seeding - In many cases, the first player takes precedence. In order to solve this problem (as well as to break all kinds of opening “homework” debuts), in some mancalas, the capture is not performed during the first turn. The goal of this “zero” run is to randomize the position on the board. Often, to save time, players perform “zero seeding” at the same time. In these cases, it also serves to determine the sequence of the move. The first player to complete the seeding makes the first move.
  • Komi - This term came from Go and is another way to compensate for the benefits of the first player. The second player, even before the start of the game, receives a certain number of points (usually fractional, to eliminate the possibility of any draws). In Go and some modern mancalah, this approach is actively used.
  • sente and gote - Two more concepts from Go. Sente is a move to which the enemy is forced to respond, and Gote - on the contrary, a forced move. Some modern mancala operate with these terms, although they understand them somewhat in their own way.
  • Ping-pong rule - In Alemungul, a situation is possible in which players will have the opportunity, move by move, to throw one and the same stone to each other. The rule of "ping-pong" prohibits such a repetition of the position. By analogy with the previous terms, it should be called the " Rule Co. ", but, apparently, the people of Ethiopia were poorly familiar with the Japanese game.


Tchuka ruma


I decided to start with a simple one. Chuka Ruma is not a traditional game (in the sense that it is not 5,000 years old, but only 120), but according to the rules it is very similar to Dacon , which is widespread in Indonesia. Except that Chuka Ruma is designed for the game of one person. Yes, this is the only known mancala solitaire. Here's what she looks like:


It is required to transfer all the stones to the “barn” (extreme right well), observing the following rules:


This remarkable “mind gymnastics” was first (in 1895) described by the French mathematician Henri-Auguste Delannoy in correspondence with his colleague Edouard Lucas. Any resemblance to the "Dacon" is not accidental, since, apparently, it was this game that Henri-Auguste used as a prototype.

The easiest sowing
In principle, no one bothers to use for development mankal "regular" ZRF. Heaps of stones are represented by separate figures (by the number of stones) and the whole task of “sowing” is to correctly change the type of several figures in one move (ZSG notation becomes completely unreadable, but no one is going to read it). It would be almost as simple as castling if it were not for one fatal flaw of ZRF . It completely lacks any arithmetic!

The code on it is really nightmare.
(define AB if (piece? $1) (change-type $2) else) (define OC (set-position-flag occ true)) (define ABC ((AB $1 $2) ((AB $3 $4) ((AB $5 $6) ((AB $7 $8) ((AB $9 $10) ((AB $11 $12) ((AB $13 $14) ((AB $15 $16) ((AB $17 $18) ((AB $19 $20) ((AB $21 $22) ((AB $23 $24) ((AB $25 $26) ((AB $27 $28) ((AB $29 $30) ((AB $31 $32) ((AB $33 $34) ((AB $35 $36) ((AB $37 $38) ((AB $39 $40) ((AB $41 $42) ((AB $43 $44) ((AB $45 $46) ((AB $47 $48) ((AB $49 $50) ((AB $51 $52) ((AB $53 $54) ((AB $55 $56) ((AB $57 $58) ((AB $59 $60) ((AB $61 $62) ((AB $63 $64) ((AB $65 $66) ((AB $67 $68) ((AB $69 $70) ((AB $71 $72) (set-flag emu true))))))))))))))))))))))))))))))))))))) ) (define sow-in-store cascade (while not-empty? e) to (OC) (go from)) (define sow-in-store2 cascade (while not-empty? e) cascade e to (while (not-in-zone? store) (opposite e)) ) (define sow-in-store3 cascade (while not-empty? e) cascade e cascade e to (while (not-in-zone? store) (opposite e)) ) ... 


This is part of the Kalah implementation and getting through all of its macros is really not easy. I decided not to torture my brain and use the Axiom . Used as a scripting language, ForthScript certainly makes the programming process somewhat piquant . But you can add numbers in it!

Let's start with the definition of figures
 DEFER MARK ... {pieces {piece} m {piece} p1 1 {value} {piece} p2 2 {value} ... pieces} ... ' m IS MARK 


Figure m - fictitious. From it will be performed "readout" when building all the other figures. The alias MARK will allow it to be referenced from the code above. The numerical value is the number of stones in the “pile” and, concurrently, the weight of the “figure” used by AI Axiom (for “Chuka Rumani” this question is not particularly relevant, but in games of two players it will be of paramount importance).

Add moving figures
 : get-value ( -- value ) empty? IF (    ) 0 (  0 ) ELSE (  ) piece piece-value (   value    ) ENDIF ; : move-q ( -- ) get-value stone-count ! (      ) next verify (     ) from here move (         ) build-trace (     ) from to (     ) use-trace (     ... ) add-move (     ) ; {moves q-moves {move} move-q moves} {pieces ... {piece} q1 {moves} q-moves 1 {value} {piece} q2 {moves} q-moves 2 {value} {piece} q3 {moves} q-moves 3 {value} ... pieces} 


There are two “dark horses” - build-trace and use-trace , then we will look at their basic implementation. The rest of move-q is related to the “movement” of the shape. The fact is that any move in ZoG must be associated with one of two possible actions: moving a piece from one board position to another ( move ) or adding a new piece to the board ( drop ). Accordingly, one of these control words must also be involved in the description of the move. All other (side) actions must be performed after this (main) action.

Calculate the "route"
 COLS [] trace[] VARIABLE trace-count VARIABLE stone-count : build-trace ( -- ) 0 trace-count ! (   , ""  ) 0 BEGIN (    ) DUP COLS >= IF (  ,      ) DROP 0 (  ,        ) ENDIF DUP trace-count @ < IF (          ) DUP trace[] @ (     ) ELSE (  ) trace-count ++ (    ) from here <> IF (       ) get-value (      ) ELSE 0 (    ,  ""    ) ENDIF ENDIF 1+ OVER trace[] ! (    ) stone-count -- (     ) stone-count @ 0= IF (     ... ) TRUE (   ) ELSE (  ) 1+ next verify (     ) FALSE (     ) ENDIF UNTIL (  ,     TRUE ) ... (      "" ) DROP ; 


All changes are calculated, it remains to apply them!

And change all the figures that fall under the distribution
 : use-trace ( -- ) 0 BEGIN (     ) next verify (     ) DUP trace[] @ (      ) MARK + create-piece-type (     ,    MARK ) 1+ DUP trace-count @ >= (    -   ) UNTIL DROP (      ! ) ; 


Well, we learned to take stones from the hole and lay them out one by one, in the direction of sowing. In one form or another, this code will be used in all today's mankals. Of course, the real code is a bit more complicated . For example, it is necessary to “highlight” those groups of stones that are allowed to walk (otherwise they will not be able to go) and remove the highlight from the other groups. When hit in the "barn", you must mark all groups left on the board. And of course, you need to write a code that defines the conditions for the completion of the game. A lot of little things without which nothing will work!

Here's what happened in the end:



I must say that AI Axiom clicks such puzzles "like nuts". The initial alignment (two stones in four holes) ZoG decided on the minimum settings of the "duration of the course." For more complex layouts, the settings had to be “tweaked”, because, otherwise, the program got into a dead end. In the process of testing, another “solved” alignment was found, for those who like to “break their brains” .

Ohojitxi


This very original mancala is played in the Republic of Côte d'Ivoire. Externally, it looks like an ordinary double-row mancala, with six holes on each side, but since the board is “vertical” when playing, it is more appropriate to rank it not as a double row, but as a six-row mancala. Sowing once , counterclockwise and only on its territory - in three rows facing the player.

Surprises don't end there! The goal of the game is not to capture the enemy’s stones, but to get rid of your own. Captured stones are transferred to the enemy (placed in one of his holes). The one who gets rid of all his stones first will win. Capture serial , if the last stone falls into the hole with three stones (complementing them to four) - the stones are captured. Together with them, stones are captured from all previous (against the direction of sowing) holes containing four stones. If initially all 24 stones were in the same hole, the game could be completed in one move!



In general, the game is pretty funny. At first glance, it is not much different from the previous solitaire (since sowing is always carried out only on its territory), but if the enemy has time to “collect four” before you, be sure, he will try to choose the hole in such a way as to maximize frustrating all your plans ( and you have to start all over again). The only limitation is that he cannot choose the same hole each time.

How important to be attentive
The Axiom board is one large linear array. Seriously, we can just start from scratch and go through all the positions, adding one to the index. Since, in real life, one-dimensional boards are rarely met (rarely, but they are found ), Axiom takes care of us, providing a means for defining “two-dimensional” boards:

 2 CONSTANT COLS 6 CONSTANT ROWS {board ROWS COLS {grid} board} 

In fact, this is still the same one-dimensional array, the cells of which are named in a funny way (it also allows you to define “directions” by operating with increments of coordinates, not pairs of positions, but we will not need this now):


In the ZRF description, we need to mark the board in a similar way for ZoG to understand what it is dealing with:

  (board (image "Images/Ohojitxi/6x2.bmp") (grid (start-rectangle 6 4 73 89) (dimensions ("a/b" (67 0)) ; files ("6/5/4/3/2/1" (0 85)) ; ranks ) ) ) 

This is where the fun begins. We write a lot of code , coding crops and grabs, gradually forgetting about the dull and backward ZRF. At some point, we become desperately need to encode a new rule - “when performing a seizure, the player cannot choose the same hole of the enemy each time”. Obviously, tagging holes must be stored somewhere! And where else, if not on the board?

 4 CONSTANT COLS 

Feel free to expand the board twice! No, it even works. Some time Immediately after this, we receive a mysterious message from the program:


It is clear that someone does not understand someone, but it takes another half an hour of nervous searches to recall the ZRF! And already after the game is made, debugged and even sent for publication, the fact emerges that we made two board options.

It is pleasant to play Okhochich in the presence of a large amount of free time. The party of equal rivals can last a very long time. In order to collect the last stones, you have to spend a lot of moves. As a rule, the enemy manages earlier and everything starts from the beginning. Serial capture helps break the vicious circle, but it still needs to be folded. When the program plays “with itself”, the average duration of the game is about 500 moves (however, it beats me so fast that I don’t have time to figure out what happened).

Afrika


Yes, it is through this letter! The word is German. I mean, the game was invented by the German - Ralf Gering. And it happened in 2004. This is a scandalous mancala! First, she is less than 120 years old. In addition, she collected 5 "hate ratings" on BoardGameGeek . Later it turned out that they were all from the “virtuals” of the same person (I suspect that it was something personal) and out of five was left one, the very first.

Seriously speaking, this game is too unlike any other mancala. According to the "gameplay" it is much closer to Checkers . It's all about the capture mechanism. In "Africa" ​​it is mandatory! Other mancalas also have “forced” moves (the rule of “hunger” - in most African mancalas), but there they are not of such paramount importance! If there is a possibility of capture - the player must take! And this is what makes the game unique.


The rules are simple. Sowing once , always from its row, counterclockwise, without entering the "barns". Capturing is carried out from an opponent’s non-empty hole located opposite the player’s empty hole and can only be made from holes containing the minimum number of stones (if there are two stones in one hole and three stones in the other hole, you can only take one from two). Capture is considered a separate move and takes precedence over "sowing." Such rules naturally lead to the tactic of “give less to take more”:


The diagram perfectly illustrates the concept. We give away one stone in order to take four in return (I’ll say right away that such an obvious move subsequently leads to a dead end, the problem has a better solution). The great thing about this is that the enemy cannot ignore our sacrifice. He is obliged to take a stone and, losing a turn, cannot protect his own. This is much more “sente” than the meaning put into this concept in Go. As in Checkers , the rejection of forced moves will make the game much less interesting.

As a rule, in games with “obligatory take”, “reverse game” is of certain interest (it is possible for many to be a surprise, but “ Giveaway ”, in tactical terms, is much more difficult game than ordinary checkers). In November 2010, Benedikt Rosenau proposed a “reverse” version of the game, based on the rules of “Africa.” Of course, I implemented both versions of the game.

Whose stones?
In Ohochichi sowing was carried out on its territory, and in the Chuka Rum the player was generally alone. “Africa” is the first game in which we enter enemy territory. Immediately there is a problem. The fact is that in ZoG a player can only move his pieces! In part, this limitation is related to performance issues and it may even seem reasonable, as long as we are not confronted with something like this . In our case, it is important that we should monitor not only the type of figures (the number of stones and the mark), but also their belonging.

Luckily it's just
 : get-player ( -- ) here COLS < IF (        ) Second (    Second ) ELSE (  ... ) First (  First ) ENDIF ; 


This is almost all that cares, with the exception of one nuance. If, after a player’s move, there are groups left opposite his empty holes in his territory, we must find the smallest of them and mark it (and also possibly several other groups containing an equal number of stones) so that one of them can be picked up by the enemy (this will be his mandatory move). Of course, he can take them only on the condition that the marked figures belong to him, therefore this situation will have to be dealt with in a special way:

Mark shapes
 : use-trace ( -- ) 0 BEGIN next verify get-player ( ,     ) OVER trace[] @ (    ) DUP min-target @ = IF (       ) OVER current-player = IF (      ) check-target (   ,   ) ENDIF ENDIF DUP 0< IF (     ) SWAP DROP next-player SWAP (     ) ENDIF MARK + create-player-piece-type (          ) 1+ DUP trace-count @ >= (   ,     ) UNTIL DROP ... ; 


Since, from our point of view, the course of cyclic sowing is a sequence of single sowing, in the same way it is necessary to calculate the owner of the “marked” figure, which turned out to be on the territory of the enemy. In Chuka Rum there was also cyclic seeding, but this problem was not relevant, since there was only one player.

Statistically , the first player has a slight advantage, but I did not enter Komi (2.5 points) for the second player. The first person goes and a small advantage in the fight with the machine will not be superfluous.

Gabata


Having finished “warm up”, I started two games that were most interesting for me. Both are played on a unique three-row board and are spread on the east coast of the Somali Peninsula. Actually, the board gives the name of the first of them. Gabat is a very archaic gaming system. Some researchers consider it the ancestor of all mankal. The shape of the board dictates an unusual seeding scheme. It is easier to show than to explain:


Arrows indicate the direction of sowing. Sowing cyclical and start the course can only be from their wells (bottom row and three right wells in the second row). In principle, most of the games traditionally played on the “Gabat” board could be played on a regular, double-rowed board, but in the “Gabat” itself three-rowness is used when capturing. If the last stone falls into an empty hole, the player captures all the opponent's stones located in the same board column .

Subtlety capture
The semantics of moving shapes in ZoG is fancy. Initially, there are two possibilities: moving a shape from one board field to another ( move ) and creating a shape of a given type on a selected field ( drop ). The most important thing to remember is that throughout the course of calculating the move, the position on the board remains in the same state it was at the moment of the start of the calculation. It seems logical, but in practice it spoils a lot of blood.


The diagram shows the case I ran into quite late, when the game was basically ready. The second player (the one on top) must take one stone (from his own planting) and continue his capture. So it should look like. And this is how it looked:


At some point, I noticed that the player had two selected groups of stones! Let's try to figure out what happened. When sowing, we “moved” a group of 4 stones one hole to the right (where it remained). If no takeings were performed, we would have to replace the contents of this hole with one stone, but since we took this stone, we reset it in the trace :

 : use-trace ( -- ) 0 BEGIN next verify DUP trace[] @ DUP 0 <> IF ... ELSE (      ) DROP (    !!! ) empty? NOT IF capture ENDIF (    ,     ) ENDIF 1+ DUP trace-count @ >= UNTIL DROP ; 

We remove the stones taken from non-empty holes, but in our case, the hole was empty! We did not try to fill it with a stone from sowing (since it was taken), but we did not remove stones from it (since problems may arise when trying to remove it from an empty hole). What we did not take into account is the fact that the hole, empty at the beginning of the turn, may well cease to be so after its completion. The hole was filled with the “main” action of transferring stones to the next hole. The moral of this story is that not only the initial stroke field should be processed in a special way .

It is easy to see that captures performed in different columns are not equivalent. There are possible captures from two holes at once, as well as situations in which nothing will be captured at all (for example, at the end of a turn in one of the three initial holes of the enemy). The player gets the right to perform another move, a stone that made a seizure (an unlimited number of times) and this rule introduces even greater tactical diversity into the game. Gabatu is often called “pirate mancala” and this is only partly related to the fact that it is played on Somalia territory:



When one of the players cannot complete the next move, his opponent captures all the stones remaining on the board. The game continues for several rounds (this is typical for all games on the Gabat board). Starting the next round, players lay out the stones captured in the previous round, in their holes, three each, starting from the left, in the bottom row. If there are less than three stones in the last hole, the stronger player completes it to three of their stones. The remaining stones of a stronger player immediately go to his “barn”. Wins the one who collects all the stones.

Selus


This game is my favorite! It is played on the same board as Gabat (and also using cyclic seeding ), but with a completely different capture mechanism. In it, players build traps ("wegue"). It is not allowed to walk from the wegue , but any stone that falls into them becomes the property of the player who created them. It is easy to build a trap - if the last stone of sowing falls into a hole with three stones (complementing it to four), the hole becomes wegue . The amount of wegue is unlimited!

It is impossible to call such a capture mechanism unique. There are several Selus related games with a similar stone pick. In the Kazakh mancala " Togyz Kumalak " a player can build a "tuzdyk" (but only one per game), collecting three stones in the hole. Selus’s uniqueness lies in the fact that stones that fall into the hole can be captured (including by “taking” them from the enemy). If the last stone of sowing falls into the wegue , it is captured in the player's barn, taking another stone with it from the trap.



If the capture is performed from its wegue , the player gets another move, but there is one exception. The leftmost hole, in the bottom row, is called “ayemi” (“eye”). ayemi , ayemi , ( , wegue ). , wegue ayemi !

, wegue . , wegue . ( ), . , , . «» .

, , , ( , ). , . , . «» «» , , .

Axiom
— ! , , . Axiom :

 {move-priorities {move-priority} normal-type {move-priority} pass-type move-priorities} {moves p-moves {move} move-p {move-type} normal-type {move} Pass {move-type} pass-type moves} {pieces ... {piece} m {piece} p1 {moves} p-moves 1 {value} ... pieces} 

ZRF ( " pass turn " = forced ), ( ). But not everything is so simple. , wegue , , . , Pass , :


, Pass p-moves , , Axiom «»! , ( , Pass -). drop , , Axiom ZoG:

  ; The following dummy piece is required in order to placate the Zillions engine. ; It appears as though Zillions must find at least one "moves" keyword somewhere ; in the zrf in order for it to be happy and thus allow "moves" to work correctly. (piece (name Dummy) (dummy) (moves (from)) ) 

.

. , , , , , , . ( ). .

?


— ! Axiom — .

Source: https://habr.com/ru/post/272119/


All Articles