(define "OwnedHoles" (if (is Mover P1) (sites (values Remembered "OwnedP1")) (sites (values Remembered "OwnedP2")) ) ) (define "RemmemberOwnedHoles" (if (is Mover P1) (remember Value "OwnedP1" #1) (remember Value "OwnedP2" #1) ) ) (define "CanCaptureHoles" (if (is Mover P1) (sites (values Remembered "CanCaptureP1")) (sites (values Remembered "CanCaptureP2")) ) ) (define "RemmemberCanCaptureHoles" (if (is Mover P1) (remember Value "CanCaptureP1" #1) (remember Value "CanCaptureP2" #1) ) ) (define "OnlyPiecesInMarked" (all Sites (forEach (sites Board) if:(= 0 (state at:(site)))) if:(= 0 (count at:(site)))) ) (define "RightMostEmpty" (trackSite FirstSite "TrackCW" from:(mapEntry "RightMost" Mover) if:(is Empty (to)) ) ) (define "RememberOwnedHolesRandom" (if (< 50 (value Random (range 1 100))) (remember Value "OwnedP1" #1) (remember Value "OwnedP2" #1) ) ) (define "SitesMarkedBy" (forEach (sites Board) if:(= #1 (state at:(site)))) ) //------------------------------------------------------------------------------ (game "Mewegae" (players 2) (equipment { (mancalaBoard 2 6 store:None { (track "TrackCCW" "0,E,N,W" loop:True) (track "TrackCW" "5,W,N,E" loop:True) } ) (piece "Seed" Shared) (hand Each) (regions P1 (sites Bottom)) // P1 home (regions P2 (sites Top)) // P2 home (map "RightMost" {(pair P1 5) (pair P2 6)}) }) (rules (start { (set RememberValue "OwnedP1" (sites Bottom)) (set RememberValue "OwnedP2" (sites Top)) (set Count 4 to:(sites Track)) }) phases:{ (phase "Sowing" (play (or { (move Select (from (if ("SameTurn") (sites {(var "Replay")}) ("OwnedHoles") ) if:(and (< 0 (count at:(from))) (= 0 (state at:(from)))) ) (then (sow "TrackCCW" apply:(if (and (= 0 (state at:(to))) (= 4 (count at:(to))) ) (set State at:(to) (mover)) (if (< 1 (count at:(to))) (if (= 0 (state at:(to))) (and (moveAgain) (set Var "Replay" (to)) ) (if (!= (mover) (state at:(to))) (if (is In (to) ("CanCaptureHoles")) (and (fromTo (from (to)) (to (handSite Mover)) count:1 ) (set State at:(to) (state at:(to))) ) ("RemmemberCanCaptureHoles" (to)) ) ) ) ) ) ) ) ) } (then (if ("OnlyPiecesInMarked") (and { (forEach Site ("SitesMarkedBy" 1) (fromTo (from (site)) (to (handSite P1)) count:(count at:(site)) ) ) (forEach Site ("SitesMarkedBy" 2) (fromTo (from (site)) (to (handSite P2)) count:(count at:(site)) ) ) (forget Value "OwnedP1" All) (forget Value "OwnedP2" All) (forget Value "CanCaptureP1" All) (forget Value "CanCaptureP2" All) (set Var "Round" (+ 1 (var "Round"))) }) ) ) ) ) (end (if ("NoPieceOnBoard") { (if (>= 1 (count Cell at:(handSite P1))) (result P2 Win)) (if (>= 1 (count Cell at:(handSite P2))) (result P1 Win)) } ) ) (nextPhase ("NoPieceOnBoard") "BetweenRounds") ) (phase "BetweenRounds" (play (if (<= 4 (count Cell at:(handSite Mover))) (move (from (handSite Mover)) (to ("RightMostEmpty")) count:4 (then (and { ("RemmemberOwnedHoles" (last To)) (if (<= 4 (count Cell at:(handSite Mover))) (moveAgain) (if (= 3 (count Cell at:(handSite Mover))) (and { (fromTo (from (handSite Mover)) (to ("RightMostEmpty")) count:3 ) (fromTo (from (handSite Next)) (to ("RightMostEmpty")) count:1 ) ("RemmemberOwnedHoles" ("RightMostEmpty")) }) (if (= 2 (count Cell at:(handSite Mover))) (and { (fromTo (from (handSite Mover)) (to ("RightMostEmpty")) count:2 ) (fromTo (from (handSite Next)) (to ("RightMostEmpty")) count:2 ) ("RememberOwnedHolesRandom" ("RightMostEmpty")) }) ) ) ) }) ) ) (then (if (and (is Empty (handSite P1)) (is Empty (handSite P2))) (and (if (is Even (var "Round")) (set NextPlayer (player 2)) (set NextPlayer (player 1)) ) (set Pending) ) ) ) ) ) (nextPhase (and (is Empty (handSite P1)) (is Empty (handSite P2))) "Sowing") ) } ) ) //------------------------------------------------------------------------------ (metadata (info { (description "Mewegae is a two-row mancala-style board game played in Eritrea. It contains a simultaneous opening move that is common in games from Eritrea and Ethiopia.") (aliases {"Gabata"}) (rules "2x6 board. Play begins with four counters in each hole. Players begin the game simultaneously, sowing according to the rules below, until one player drops their final counter into an empty hole. A player picks up the contents of any of their holes and sowing them in an anti-clockwise direction, picking up the contents of the last hole in which his counters fall, and continuing sowing. This continues until the last counter falls in an empty hole. Then it is the other player's turn. A hole is captured when the last ball is dropped into an opponent's hole containing three counters, making it four. A player cannot then take from one of these holes that they have captured. Therefore, the player cannot begin a turn from their own captured hole nor can they continue sowing from it. If the last counter of a sowing falls into an opponent's captured hole, nothing happens on the first instance, but every time after that, one of those counters are removed from the board and placed in the store, and the sowing continues with the contents of any of the player's holes. Ownership of a hole continues even if it becomes empty. When a player cannot move (i.e., there are no counters in their holes except any that are in captured holes), the opponent continues to move until the player is able to move. Play continues until all counters are either placed in the store or in captured holes and thus cannot be moved. Players then count their pieces by placing four in each hole, and the player who has more than their original number takes ownership of one of the opponent's holes for every four counters more than the original number that have been taken. If no player took four more than the original, the player with three extra gets the hole, if each player has two extra the weaker player is given the two extra counters. Play then begins again as before. The game ends when one player owns all of the counters, and thus all of the holes.") (source "Pamkhurat 1971: 168.") (id "344") (version "1.3.12") (classification "board/sow/two rows") (credit "Eric Piette") (origin "This game was played in Horn of Africa, around 1971.") } ) (graphics { (board Style Mancala) (show LocalStateHoles) }) (ai "Mewegae_ai" ) )