; *** Kalah 
; *** (c) 2001 W. D. Troyka
; *** dtroyka@justice.com


;	KALAH COMMON MACROS


;	ADD BEAN(S) TO HOLE WHILE SOWING

; 	add bean to hole while sowing first lap

(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))
)

(define add-bean
	(if (in-zone? store) (sow-in-store) else 
	(if (not-in-zone? enemy-store)
	(ABC 	 0B  1B  1B  2B  2B  3B  3B  4B  4B  5B  5B  6B  
		 6B  7B  7B  8B  8B  9B  9B 10B 10B 11B 11B 12B 
		12B 13B 13B 14B 14B 15B 15B 16B 16B 17B 17B 18B 
		18B 19B 19B 20B 20B 21B 21B 22B 22B 23B 23B 24B
		24B 25B 25B 26B 26B 27B 27B 28B 28B 29B 29B 30B
		30B 31B 31B 32B 32B 33B 33B 34B 34B 35B 35B 36B)))
)

; 	add two beans to hole while sowing second lap

(define add-bean2 
	(if (in-zone? store) (sow-in-store2) else 
	(if (not-in-zone? enemy-store)
	(ABC 	 0B  2B  1B  3B  2B  4B  3B  5B  4B  6B  5B  7B  
		 6B  8B  7B  9B  8B 10B  9B 11B 10B 12B 11B 13B 
		12B 14B 13B 15B 14B 16B 15B 17B 16B 18B 17B 19B 
		18B 20B 19B 21B 20B 22B 21B 23B 22B 24B 23B 24B
		24B 26B 25B 27B 26B 28B 27B 29B 28B 30B 29B 31B
		30B 32B 31B 33B 32B 34B 33B 35B 34B 36B 35B 36B)))
)

; 	add three beans to hole when sowing three laps

(define add-bean3 
	(if (in-zone? store) (sow-in-store3) else 
	(if (not-in-zone? enemy-store) 
	(ABC 	 0B  3B  1B  4B  2B  5B  3B  6B  4B  7B  5B  8B  
		 6B  9B  7B 10B  8B 11B  9B 12B 10B 13B 11B 14B 
		12B 15B 13B 16B 14B 17B 15B 18B 16B 19B 17B 20B 
		18B 21B 19B 22B 20B 23B 21B 24B 22B 24B 23B 24B
		24B 27B 25B 28B 26B 29B 27B 30B 28B 31B 29B 32B
		30B 33B 31B 34B 32B 35B 33B 36B 34B 36B 35B 36B)))
)

; 	add four beans to hole when sowing four laps

(define add-bean4 
	(ABC 	 0B  4B  1B  5B  2B  6B  3B  7B  4B  8B  5B  9B  
		 6B 10B  7B 11B  8B 12B  9B 13B 10B 14B 11B 15B 
		12B 16B 13B 17B 14B 18B 15B 19B 16B 20B 17B 21B 
		18B 22B 19B 23B 20B 24B 21B 25B 22B 26B 23B 27B
		24B 28B 25B 29B 26B 30B 27B 31B 28B 32B 29B 33B
		30B 34B 31B 35B 32B 36B 33B 36B 34B 36B 35B 36B)
)


;	CAPTURE BEANS

;	capture extra bean when sowing wraps around

(define EB (set-flag extra-bean true))

(define EX 
	(if (or (piece? 8B)  (piece? 9B) (piece? 10B)
		(piece? 11B) (piece? 12B)) (EB))
)

; 	capture beans in opponent's hole and place in store

(define V ns t (change-type 0B) add (verify false))

(define next $1 (while not-empty? e) (while (position-flag? occ) e))

(define ST 
	(if (flag? extra-bean) e) 
	(if (flag? sweep) (opposite e))
	(set-position-flag stop true)
)

(define e5 e e e e e) (define e10 (e5) (e5)) (define e20 (e10) (e10))
	 
(define set-stop
	(if (piece? 0B) (next) (ST) else
	 (if (piece? 1B) (next) e (ST) else
	  (if (piece? 2B) (next) e e (ST) else
	   (if (piece? 3B) (next) e e e (ST) else
	    (if (piece? 4B) (next) e e e e (ST) else 
	     (if (piece? 5B) (next) (e5) (ST) else
	      (if (piece? 6B) (next) (e5) e (ST) else
	       (if (piece? 7B) (next) (e5) e e (ST) else
	        (if (piece? 8B) (next) (e5) e e e (ST) else
	         (if (piece? 9B) (next) (e5) e e e e (ST) else
	          (if (piece? 10B) (next) (e10) (ST) else
		   (if (piece? 11B) (next) (e10) e (ST) else
		    (if (piece? 12B) (next) (e10) e e (ST) else
	(if (piece? 13B) (next) (e10) e e e (ST) else
	 (if (piece? 14B) (next) (e10) e e e e (ST) else
	  (if (piece? 15B) (next) (e10) (e5) (ST) else
	   (if (piece? 16B) (next) (e10) (e5) e (ST) else 
	    (if (piece? 17B) (next) (e10) (e5) e e (ST) else
	     (if (piece? 18B) (next) (e10) (e5) e e e (ST) else
	      (if (piece? 19B) (next) (e10) (e5) e e e e (ST) else
	       (if (piece? 20B) (next) (e20) (ST) else
	        (if (piece? 21B) (next) (e20) e (ST) else
	         (if (piece? 22B) (next) (e20) e e (ST) else
		  (if (piece? 23B) (next) (e20) e e e (ST) else
		   (if (piece? 24B) (next) (e20) e e e e (ST) else
        (if (piece? 25B) (next) (e20) (e5) (ST) else
	 (if (piece? 26B) (next) (e20) (e5) e (ST) else
	  (if (piece? 27B) (next) (e20) (e5) e e (ST) else
	   (if (piece? 28B) (next) (e20) (e5) e e e (ST) else 
	    (if (piece? 29B) (next) (e20) (e5) e e e e (ST) else
	     (if (piece? 30B) (next) (e20) (e10) (ST) else
	      (if (piece? 31B) (next) (e20) (e10) e (ST) else
	       (if (piece? 32B) (next) (e20) (e10) e e (ST) else
	        (if (piece? 33B) (next) (e20) (e10) e e e (ST) else
	         (if (piece? 34B) (next) (e20) (e10) e e e e (ST) else
		  (if (piece? 35B) (next) (e20) (e10) (e5) (ST) else
		   (if (piece? 36B) (next) (e20) (e10) (e5) e (ST)
	)))))))))))))))))))))))))))))))))))))
)

(define take-beans			
	mark (set-stop) back (next) cascade
	(while (not-position-flag? stop) to (OC) e cascade)
	(OC) (set-position-flag stop false) to back 
)

(define X	
	(if (and friend? (or (piece? 0B) (position-flag? lift-hole))) 
	(if (and (piece? 0B ns) (not-flag? extra-bean)) (V))
 	(change-type 0B) ns 
	(change-type 0B)
	(take-beans x)) 
	add (verify false)
)

;	RED STRIP MANAGEMENT

;	turn off red-strip after fourth move

(define SA				
	(if 4-move (change-type 0B) else (change-type RS)
	  (if 3-move (set-attribute 4-move true) else
	    (if 2-move (set-attribute 3-move true) else
	      (if 1-move (set-attribute 2-move true) else
	       (set-attribute 1-move true)
	))))
)

;	reset red-strip attributes

(define RA				
	(set-attribute 1-move false)
	(set-attribute 2-move false)
	(set-attribute 3-move false)
	(set-attribute 4-move false)
)

;	turn off red strip if move empties side

(define turn-off
	(opposite cc)
	(if (piece? 1B) cw
	(while (and (piece? 0B) friend?) cw)
	(if enemy? ns t (change-type 0B) add (verify false)))
	back
)

;	allow extra move after landing in store

(define MX 
	(if (in-zone? store) mark (turn-off) t (SA) back 
	cc t (set-attribute can-move true) add (verify false) 
	     else (if enemy? mark t (set-attribute can-move true) back
	     ns t (set-attribute can-move false) add (verify false) 
		  else mark t (set-attribute can-move false) back
		  ns t (set-attribute can-move true) back
)))


;	DETERMINE LEGAL MOVES

;	test to see which variant is being played

(define game-over?
	y1 
	(if 3-bean (verify (and (empty? $1) (empty? $2))) else
	(if 4-bean (verify (and (empty? $3) (empty? $4))) else
	(if 5-bean (verify (and (empty? $5) (empty? $6))) else
	(if 6-bean (verify (and (empty? $7) (empty? $8)))))))
	back
)

; 	limit move to friendly hole with pieces in it

(define preconditions
	(verify (and friend? (not-piece? 0B) 
		(or (can-move t) (piece? RS t)))) 
)

;	preliminary operations

(define Q 
	(game-over? $1 $2 $3 $4 $5 $6 $7 $8) 
	(freeze) (change-type $9) to 
	(set-flag sweep false)
	(set-flag second-lap false)
	(set-flag extra-bean false)
	(set-position-flag lift-hole true)
	mark t (change-type 0B) back
	ns t (RA) back
)

;	prevent normal move if all opponent holes are empty

(define freeze
	mark
	(while friend? cw)
	(while (and (piece? 0B) enemy?) cw)
	(if friend? (verify false))
	back
)

;	if all opponent holes are empty, capture remaining beans

(define clean-up 
	((verify (and friend? (not-piece? 0B))) 
	(game-over? $1 $2 $3 $4 $5 $6 $7 $8) to  
	(while friend? cw)
	(while (and (piece? 0B) enemy?) cw)  
	(if friend? (set-flag sweep true)
	(while friend? (if (not-piece? 0B) 
	(change-type 0B) (take-beans y)) cw) 
	add)
))


;	SOW BEANS

; 	determine drop hole

(define DH (set-position-flag drop-hole true) back else)

(define drop-hole?
	(if (piece? $1)  cc (DH) 
	(if (piece? $2)  cc cc (DH) 
	(if (piece? $3)  cc cc cc (DH) 
	(if (piece? $4)  cc cc cc cc (DH) 
	(if (piece? $5)  cc cc cc cc cc (DH) 
	(if (piece? $6)  cc cc cc cc cc cc (DH) 
	(if (piece? $7)  cw cw cw cw cw cw (DH) 
	(if (piece? $8)  cw cw cw cw cw (DH) 
	(if (piece? $9)  cw cw cw cw (DH) 
	(if (piece? $10) cw cw cw (DH) 
	(if (piece? $11) cw cw (DH) 
	(if (piece? $12) cw (DH) 
	(verify false)))))))))))))
)

(define drop-hole4?
	(if (piece? $1) cc (DH) 
	(if (piece? $2) cc cc (DH) 
	(if (piece? $3) cc cc cc (DH) 
	(if (piece? $4) cc cc cc cc (DH) 
	(if (piece? $5) cw cw cw cw (DH) 
	(if (piece? $6) cw cw cw (DH) 
	(if (piece? $7) cw cw (DH) 
	(if (piece? $8) cw (DH) 
	(verify false)))))))))
)

(define drop-hole5a?
	(if (piece? $1)  cc (DH) 
	(if (piece? $2)  cc cc (DH) 
	(if (piece? $3)  cc cc cc (DH) 
	(verify false))))
)

; 	macros for counting holes

(define L1				; sow partial first lap
	(while (not-position-flag? drop-hole) 
	cc (add-bean))) 

(define FL1 cc				; finish first lap
	(while (not-position-flag? lift-hole) 
	(add-bean) cc)) 

(define L2 				; sow partial second lap
	(while (not-position-flag? drop-hole) 
	cc (add-bean2))) 

(define FL2 cc	 			; finish second lap
	(while (not-position-flag? lift-hole) 
	(add-bean2) cc))

(define L3 				; sow partial third lap
	(while (not-position-flag? drop-hole) 
	cc (add-bean3))) 

(define FL3 cc	 			; finish third lap
	(while (not-position-flag? lift-hole) 
	(add-bean3) cc))

(define L4 				; sow partial fourth lap
	(while (not-position-flag? drop-hole) 
	cc (add-bean4)))

; 	basic move macro - broken up to keep move generation 
; 	within paramaters

(define sow

	(drops

	((preconditions)  				; first lap
	(drop-hole? 1B 2B 3B 4B 5B 6B 7B 8B 9B 10B 11B 12B)
	(Q Td4 Bd4 Te3 Be3 Ta1 Ba1 Tb8 Bb8 0B) (EX) (L1) (MX) (X)
	add)

	((if (piece? 13B) (preconditions)		; exactly one lap 
	(Q Td4 Bd4 Te3 Be3 Ta1 Ba1 Tb8 Bb8 0B) (EB) (FL1) (MX) (X)
	add))

	((preconditions)  				; second lap 
	(drop-hole? 14B 15B 16B 17B 18B 19B 20B 21B 22B 23B 24B 25B)
	(Q Td4 Bd4 Te3 Be3 Ta1 Ba1 Tb8 Bb8 1B) (L2) mark (FL1) back (MX) 
	add)

	((if (piece? 26B) (preconditions)    		; exactly two laps
	(Q Td4 Bd4 Te3 Be3 Ta1 Ba1 Tb8 Bb8 2B) (FL2) (MX) 
	add))

	((preconditions)  				; third lap 
	(drop-hole? 27B 28B 29B 30B 31B 32B 33B 34B 35B 36B RS RS)
	(Q Td4 Bd4 Te3 Be3 Ta1 Ba1 Tb8 Bb8 2B) (L3) mark (FL2) back (MX) 
	add)

	(clean-up Td4 Bd4 Te3 Be3 Ta1 Ba1 Tb8 Bb8)	; capture all beans

))


;	PIECE DEFINITIONS

(define common-piece
	(name $1)
	(notation "$2")
	(help "$2")
      	(description "$2:  Beans in a hole are sown one at a time in
		successive holes counterclockwise around the board.  If 
		a sowing ends in an occupied hole on either side of the
		board, the beans in that hole, including the bean just 
		dropped, are picked up and a new sowing begins as part 
		of the same turn.  You can make up to 20 moves in a turn 
		this way.  Beans are not dropped into the store but are 
		sown into the lift hole on subsequent laps.  If the last 
		bean is dropped in an empty hole on the player's side of 
		the board, any beans in the opponent's opposing hole 
		are captured.  If the last bean is droped in an empty 
		opponent hole, the turn is over.")
)

(define Piece
	(common-piece)
	(image 	Bottom "Mancala\$2.bmp"
		Top "Mancala\$2.bmp")
)

(define red-attributes
	(dummy)
 	(attribute can-move true)
	(attribute 1-move false)
        (attribute 2-move false) 
	(attribute 3-move false)
	(attribute 4-move false) 
	(attribute $1 true)
	(attribute $2 false) 
	(attribute $3 false)
	(attribute $4 false)
)

(define Red-Strip (piece (Piece RS red-strip) (red-attributes)))



;	GAME BLOCK

(define common
   (description "Kalah is a popular Mancala game commonly found on 
	internet game sites, sometimes under the names Kalaha, Makalah, 
	or simply Mancala.  Its origins are murky but it appears likely 
	that Kalah is not an indigenous game but rather a modern variant 
	of the Indonesian game Congklak.  The rules are as follows:
	\\
	The board is divided into twelve holes and two stores.  One player 
	plays from the bottom six holes and the other plays from the top 
	six.  The stores are used for storing captured pieces.  The right 
	store is for the bottom player and the left store for the top player.
	\\
	The game begins with three beans in each of the twelve holes.  The 
	bottom player goes first.  A move is made by picking up the beans 
	in a player's hole and sowing them one at a time counterclockwise 
	around the board. Sowing begins with the hole immediately after 
	the lift hole and continues until all the beans have been dropped.  
	Beans are dropped in a player's store but not in the opponent's 
	store.  Unlike in Wari, beans are dropped in the lift hole on 
	subsequent laps.
	\\
	If the last bean is dropped in the player's store, the player gets 
	another turn, which is indicated by a red strip.  (You can get up 
	to four extra turns this way.)  If the last bean is dropped in an 
	empty friendly hole, any beans in the opposing enemy hole are 
	captured -- along with the last dropped bean -- and the turn ends.  
	If the last bean is dropped in an enemy hole or an occupied 
	friendly hole, the turn ends. 
	\\
	The game ends when a player captures over half of the beans (19 in
	the 3-bean variant) or when all of one player's holes are empty.  
	In the latter case, all remaining beans are awarded to the opponent.  
	If it is your turn to move and all opponent holes are empty, click 
	on any occupied hole to capture the remaining beans.  The winner 
	is the player with the most captured beans at the end of the game. 
	\\
	If the players each capture half the beans, a draw is declared.
	The holes hold up to thirty-six beans.  Any additional beans 
	added to a hole are skimmed off the top and removed from play.
	In the variants, the players start with three through six beans 
	in each hole on boards with dimensions 2x4, 2x5, 2x6, 2x7, and 2x8.  
	A player wins by capturing more than half of all available beans.
	\\
	Please send any comments or bug reports to dtroyka@justice.com.  
	For other Mancala games available on Zillions, check out Congklak,
	Cross-Wari, and Cross-Kalah.")
   (history "Mancala v. 2.0  (c) 2001  W. D. Troyka.
	\\
	Kalah is arguably the most popular Mancala game on the web.  Applets
	and other computer players can be found at:
	\\
	imagiware.com/mancala  (3-bean)\
	vole.caltech.edu/#mancala  (3-bean)\
	www.nrr.co.uk/mancala  (4-bean)\
	www.lookoutnow.com/game/man.htm  (4-bean)\
	www.rocketsnail.com/mancala  (4-bean)\
	www.msoworld.com/playgames.html  (1 through 4-bean)\
	mathsrv.ku-eichstaett.de/MGF/homes/grothmann/java/Kalah.html  (6-bean)
	\\
	The game is also discussed at: 
	\\
	www.ahs.uwaterloo.ca/~museum/vexhibit/CC/kalah.html\
	lycos.go2net.com/games/board/mancala\
	www.playsite.com/t/games/board/mancala/rules.html\
	www.centralconnector.com/GAMES/mancala.html\
	www.cmi.k12.il.us/Urbana/projects/AncientCiv/africa/Mancala.html\
	www.msoworld.com/mindzine/news/classic/mancala\
	Robbie Bell, Board Games Round The World
	\\
	Kalah appears to be a single lap version of the Indonesian game 
	Congklak (known as Dakon in Java and Sungka in Malaysia and the 
	Phillipines).  The rules of Congklak are the same as for Kalah, 
	except that in Congklak beans are sown clockwise, boards are 
	frequently 2x7 with 7 beans per hole in the initial position 
	(or 2x5 with 5 beans), and sowing takes place in multiple laps 
	-- meaning that if the last bean drops into an occupied hole, 
	all beans in that hole are picked up for another lap of sowing, 
	and so on until the last bean drops in an empty hole or the 
	store.  As in Kalah, if the last bean drops in the store, the 
	player gets another turn. 
	\\
	The history of Kalah is elusive.  It appears likely that the game 
	was first marketed -- and perhaps invented -- by the Kalah Game Co. 
	of Holbrook, Massachusetts, U.S.A. in the early 1940s.  Information on 
	the Kalah Game Co. can be found at the University of Waterloo site 
	listed above.  According to a 1963 press release available at the site, 
	in 1905 William J. Champion, the founder of the company, `came across 
	an article concerning the ancient game of Kalah, a game which closely 
	complies with the modern approach to mathematics.`  He began 
	researching the game and `finally traced it back some 7,000 years to 
	the ancient Sumerians.`  He also claims to have found an `urn painting 
	of Ajax and Achilles playing it during the siege of Troy.`  As the 
	press release notes, the company was featured in an article in the  
	June 14, 1963 issue of Time magazine.
	\\
	Mr. Champion, no doubt, was describing the history of Mancala games 
	generally (and got carried away!).  What remains uncertain is whether 
	the specific rule set of Kalah was invented by Champion, perhaps 
	as a variant of Congklak, or whether it predated him.  At any rate, 
	there is no reliable evidence that Mancala games have been played for 
	7,000 years.  As for the urn, I have not seen it but have read a 
	description suggesting that the game played by Ajax and Achilles was 
	Pente Grammai, not Mancala.  Champion claimed to have invented 
	the name Kalah from the Kalahari Desert in South Africa, where 
	Mancala is played by scooping out pits in the sand.  It seems more
	plausible that the name Kalah was derived from Mancala.  Anybody 
	with any information on these issues is invited to email me at 
	dtroyka@justice.com.  (I am also curious to know exactly what 
	Pente Grammai is -- descriptions are hard to come by!).")
   (strategy "Focus on getting extra turns by sowing into the store.  It 
	is possible to win a game without capturing a single enemy bean if 
	you receive enough extra turns.  If you keep the hole immediately 
	preceding your store empty, you will automatically gain two extra
	moves by sowing from any other hole into the store.  For example,
	if you sow from the third hole, that will leave one bean in the 
	first hole, which you can then sow into the store to gain yet 
	another move.
	\\
	Be careful, of course, to protect heavily occupied holes from 
	capture.  Holes that are closer to the enemy store are more 
	vulnerable.  An opponent who can empty the opposite hole into 
	the store may, on the next move, be able to end a sowing in the 
	same opposite hole, resulting in capture.
	\\
	In general you should try to attack as many enemy holes as possible.  
	An enemy hole is attacked if the last bean sown from a player's hole 
	will drop directly across from it.  It is easier to obtain extra 
	turns and to threaten enemy holes if you maintain a small number 
	of beans in most of your holes.  Defensively, if an enemy hole 
	threatens capture or multiple turns, you can overload the hole 
	by sowing a bean into it.
	\\
	Try to collect thirteen beans in a hole.  Sowing thirteen beans will 
	always result in capture because the sowing ends in the lift hole, 
	which is empty, and at a minimum the opposite hole will have the 
	bean you just dropped into it.  Conversely, if the opponent has 
	thirteen beans in a hole, you should if possible sow into the hole
	to give it fourteen beans.
	\\
	Running out of beans is a real threat in this game.  Unlike in Wari, 
	there is no `feed` rule requiring you to give beans to a depleted 
	opponent.  You should always look ahead to see whether you can starve 
	the opponent by hoarding beans.  If the opponent becomes depleted, you 
	gain all remaining beans.  
	\\
	Draw by repetition is impossible because beans are siphoned off into 
	the store whenever a sowing wraps around the board edge.  A draw is 
	possible only when each player captures half of the beans.
	\\
	The bottom player enjoys a first-move advantage, particularly in the 
	4-bean variant.  This probably explains why Kalah was originally 
	marketed by the Kalah Game Co. as a 3-bean or 6-bean game.  Today 
	many Kalah computer players start with the 4-bean set-up, probably 
	due to the influence of Wari.  According to Geoffrey Irving, the 
	3-bean version has been fully solved.  His web site at 
	vole.caltech.edu/#mancala offers a Kalah computer opponent 
	that plays perfectly.
	\\
	Mr. Champion of the Kalah Game Co. lost to a Kalah computer player 
	long before Tinsley lost to Chinook or Kasparov lost to Deep Blue.  
	According to an article in the June 14, 1963 issue of Time magazine, 
	M.I.T. `computer wizards` programmed a computer that `clobbered 
	Champion Champion consistently.`  The article does not say when 
	this happened but it had to be 1963 at the latest.")  
   (animate-drops false)
   (animate-captures false)
   (players Bottom Top)
   (turn-order Bottom Bottom Bottom Bottom Bottom Top Top Top Top Top)
   (pass-turn forced)
   (count-condition (Bottom Top) stalemated)
)

(define image-audio
   (music "..\Audio\Mancala\Nyayito.mid")		; song from Ghana
   (opening-sound "..\Audio\Mancala\drop.wav")
   (drop-sound "..\Audio\Mancala\sow.wav")
   (change-sound "..\Audio\Mancala\sow.wav")
   (win-sound "..\Audio\Mancala\elephant.wav")
   (loss-sound "..\Audio\Mancala\elephant.wav")
   (capture-sound "")
   (piece (Piece 36B 36-beans))
   (piece (Piece 35B 35-beans))
   (piece (Piece 34B 34-beans))
   (piece (Piece 33B 33-beans))
   (piece (Piece 32B 32-beans))
   (piece (Piece 31B 31-beans))
   (piece (Piece 30B 30-beans))
   (piece (Piece 29B 29-beans))
   (piece (Piece 28B 28-beans))
   (piece (Piece 27B 27-beans))
   (piece (Piece 26B 26-beans))
   (piece (Piece 25B 25-beans))
   (piece (Piece 24B 24-beans))
   (piece (Piece 23B 23-beans))
   (piece (Piece 22B 22-beans))
   (piece (Piece 21B 21-beans))
   (piece (Piece 20B 20-beans))
   (piece (Piece 19B 19-beans))
   (piece (Piece 18B 18-beans))
   (piece (Piece 17B 17-beans))
   (piece (Piece 16B 16-beans))
   (piece (Piece 15B 15-beans))
   (piece (Piece 14B 14-beans))
   (piece (Piece 13B 13-beans))
   (piece (Piece 12B 12-beans))
   (piece (Piece 11B 11-beans))
   (piece (Piece 10B 10-beans))
   (piece (Piece 9B 9-beans))
   (piece (Piece 8B 8-beans))
   (piece (Piece 7B 7-beans))
   (piece (Piece 6B 6-beans))
   (piece (Piece 5B 5-beans))
   (piece (Piece 4B 4-beans))
   (piece (Piece 3B 3-beans))
   (piece (Piece 2B 2-beans))	
   (piece (Piece 1B 1-bean))
   (piece (Piece 0B 0-beans) (attribute can-move true))
)


;	SELECT SCREEN

(define select-board
    (board 
      	(image "Mancala\select.bmp")
  	(grid
     		(start-rectangle 20 20 170 55)
		(dimensions 
			("A/B/C" (192 0))  ; files
     		 	("6/5/4/3/2/1/0" (0 38))) ; ranks
)))

(define Select
	(name $1)
	(notation "$2")
	(help "Click here to select the $2 variants")
      	(description "$2:  Click here to select the $2 variants")
	(image 	Background "Mancala\$3.bmp")
	(open "$2.zrf")
)

(define Mancala-Select
   (title "Mancala Select")
   (description "Select the Mancala variant you want to play.")
   (history "Mancala v. 2.0  (c) 2001  W. D. Troyka")
   (strategy "")
   (music "..\Audio\Mancala\jeopardy.mid")
   (change-sound "..\Audio\Mancala\midiprompt.wav")
   (players Background Top Bottom)
   (turn-order Background)
   (select-board)
   (board-setup 
	(Background  
		(Wari A6) 	(Kalah B6) 	(Endodoi C6)
		(W4 A5)		(K4 B5)		(E4 C5)
		(W5 A4)		(K5 B4)		(E5 C4)
		(W6 A3)		(K6 B3)		(E6 C3)
		(W7 A2)		(K7 B2)		(E7 C2)
		(W8 A1)		(K8 B1)		(E8 C1)
		(Music A0)	(Music B0)	(Music C0)))
   (piece (Select Wari Wari2x6 header-W))
   (piece (Select W4 Wari2x4 S4))
   (piece (Select W5 Wari2x5 S5))
   (piece (Select W6 Wari2x6 S6))
   (piece (Select W7 Wari2x7 S7))
   (piece (Select W8 Wari2x8 S8))
   (piece (Select Kalah Kalah2x6 header-K))
   (piece (Select K4 Kalah2x4 S4))
   (piece (Select K5 Kalah2x5 S5))
   (piece (Select K6 Kalah2x6 S6))
   (piece (Select K7 Kalah2x7 S7))
   (piece (Select K8 Kalah2x8 S8))
   (piece (Select Endodoi Endodoi2x6 header-E))
   (piece (Select E4 Endodoi2x4 S4))
   (piece (Select E5 Endodoi2x5 S5))
   (piece (Select E6 Endodoi2x6 S6))
   (piece (Select E7 Endodoi2x7 S7))
   (piece (Select E8 Endodoi2x8 S8))
   (piece (name Music) (dummy) (moves (flip flip flip add)))
   (piece (name bean) (dummy))
)
