(define "Columns" 6) (define "PiecesOwnedBy" (+ (count at:(mapEntry #1)) (count in:(sites #1)))) //------------------------------------------------------------------------------ (game "Kalah" (players 2) (equipment { (mancalaBoard 2 "Columns" (track "Track" "0,ESE,E,ENE,WNW,N,W" loop:True) ) (regions P1 (sites Bottom)) // P1 home (regions P2 (sites Top)) // P2 home (map {(pair P1 LastSite) (pair P2 FirstSite)}) // kalahs (storage pits) (piece "Seed" Shared) }) (rules (start (set Count 4 to:(union (sites P1) (sites P2)))) (play (move Select (from (sites Mover) if:(> (count at:(from)) 0) ) (then (sow apply:(if (= (to) (mapEntry (mover))) (moveAgain) (if (and { (is In (to) (sites Mover)) (= (count at:(to)) 1) (> (count at:("OppositePit" (to))) 0) }) (and (fromTo (from (to)) (to (mapEntry (mover))) count:(count at:(to)) ) (fromTo (from ("OppositePit" (to))) (to (mapEntry (mover))) count:(count at:("OppositePit" (to))) ) ) ) ) skipIf:(= (to) (mapEntry (next))) ) ) ) ) (end ("MancalaByScoreWhen" (no Moves Mover))) ) ) //------------------------------------------------------------------------------ (metadata (info { (description "Kalah is a mancala-style game \"imported\" or likely invented by William Julius Champion in 1940.") (rules "The board has two rows of six holes with a larger hole on either end. Play begins with four seeds in each hole. Each player controls the row nearest them. Seeds are sown consecutively in a counterclockwise pattern including the player's own larger hole but not the opponent's. If the last seed is placed in an opponent's empty hole, that seed and any opposite are captured and put in the player's larger hole. If the last seed falls in the larger hole, the player gets another turn. When one player has no seeds in any of their holes, the game ends. The other player captures all of the other seeds, and the player with the most captured seeds wins.") (source "Wikipedia") (id "68") (version "1.3.14") (classification "board/sow/two rows") (credit "Eric Piette") (date "01-01-1940") } ) (graphics { (board Style Mancala) }) (ai "Kalah_ai" ) )