Mancala
Mancala is a family of board games played around the world, sometimes called "sowing" games, or "count-and-capture" games, which describes the gameplay. This version includes 7 variations of Mancala.
Commands:
@create,
@describe,
@dolist,
@halt,
@lock,
@lset,
@ouse,
@parent,
@pemit,
@queue,
@remit,
@set,
@trigger,
@use,
@wait,
@wipe.
Functions:
add(),
after(),
and(),
ansi(),
capstr(),
center(),
conn(),
div(),
eq(),
extract(),
fdiv(),
filter(),
first(),
get(),
gt(),
gte(),
hasattr(),
ifelse(),
inc(),
iter(),
last(),
lattr(),
lcon(),
left(),
ljust(),
lnum(),
loc(),
locate(),
map(),
match(),
member(),
mod(),
mul(),
name(),
not(),
or(),
owner(),
pmatch(),
poss(),
r(),
rand(),
repeat(),
rest(),
reverse(),
revwords(),
rjust(),
round(),
setdiff(),
setq(),
setr(),
setunion(),
sign(),
sort(),
sortby(),
space(),
strmatch(),
sub(),
subj(),
switch(),
tagwrap(),
u(),
v(),
words().
Compatibility:
PennMUSH.
Instructions
Copy and paste the below code into a compatible MUSH or MUX.
MUSHCode for Mancala
@create Mancala ASCII Art
@lock Mancala ASCII Art==me
@set Mancala ASCII Art=NO_COMMAND
&ASCPIT_0 Mancala ASCII Art=[space(6)]|[space(8)]|[space(6)]
&ASCPIT_1 Mancala ASCII Art=[space(6)]|%b%b%b%b[u(colorpiece,extract(%0,1,1))]%b%b%b|[space(6)]
&ASCPIT_2 Mancala ASCII Art=[space(6)]|%b%b[u(colorpiece,extract(%0,1,1))]%b[u(colorpiece,extract(%0,2,1))]%b%b%b|[space(6)]
&ASCPIT_3 Mancala ASCII Art=%b%b%b[u(colorpiece,extract(%0,3,1))]%b%b|%b%b[u(colorpiece,extract(%0,2,1))]%b%b%b%b%b|%b%b[u(colorpiece,extract(%0,1,1))]%b%b%b
&ASCPIT_4 Mancala ASCII Art=%b%b[u(colorpiece,extract(%0,3,1))]%b%b%b|%b%b[u(colorpiece,extract(%0,2,1))]%b%b[u(colorpiece,extract(%0,4,1))]%b%b|%b%b%b[u(colorpiece,extract(%0,1,1))]%b%b
&ASCPIT_5 Mancala ASCII Art=%b%b[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,5,1))]%b|%b%b[u(colorpiece,extract(%0,2,1))]%b[u(colorpiece,extract(%0,1,1))]%b%b%b|%b%b%b[u(colorpiece,extract(%0,4,1))]%b%b
&ASCPIT_6 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,5,1))]%b%b|%b%b[u(colorpiece,extract(%0,2,1))]%b%b[u(colorpiece,extract(%0,1,1))]%b%b|%b%b[u(colorpiece,extract(%0,4,1))]%b[u(colorpiece,extract(%0,6,1))]%b
&ASCPIT_7 Mancala ASCII Art=%b%b[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,4,1))]%b|%b[u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]%b[u(colorpiece,extract(%0,7,1))]%b%b|%b%b[u(colorpiece,extract(%0,2,1))]%b[u(colorpiece,extract(%0,6,1))]%b
&ASCPIT_8 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]|%b%b[u(colorpiece,extract(%0,2,1))]%b%b[u(colorpiece,extract(%0,4,1))]%b%b|[u(colorpiece,extract(%0,7,1))]%b[u(colorpiece,extract(%0,6,1))]%b[u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_9 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]%b|%b%b[u(colorpiece,extract(%0,2,1))]%b[u(colorpiece,extract(%0,4,1))]%b[u(colorpiece,extract(%0,9,1))]%b|%b[u(colorpiece,extract(%0,7,1))]%b[u(colorpiece,extract(%0,6,1))][u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_10 Mancala ASCII Art=[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]%b|%b%b[u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))][u(colorpiece,extract(%0,2,1))][u(colorpiece,extract(%0,9,1))]%b%b|%b[u(colorpiece,extract(%0,7,1))]%b[u(colorpiece,extract(%0,6,1))]%b[u(colorpiece,extract(%0,8,1))]
&ASCPIT_11 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,11,1))][u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]|%b[u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))]%b[u(colorpiece,extract(%0,2,1))]%b[u(colorpiece,extract(%0,9,1))]%b|%b[u(colorpiece,extract(%0,7,1))][u(colorpiece,extract(%0,6,1))]%b[u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_12 Mancala ASCII Art=[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,11,1))][u(colorpiece,extract(%0,5,1))][u(colorpiece,extract(%0,1,1))]%b%b|%b%b[u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))][u(colorpiece,extract(%0,2,1))][u(colorpiece,extract(%0,9,1))]%b%b|%b%b[u(colorpiece,extract(%0,7,1))][u(colorpiece,extract(%0,6,1))][u(colorpiece,extract(%0,12,1))][u(colorpiece,extract(%0,8,1))]
&ASCPIT_13 Mancala ASCII Art=[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,11,1))]%b[u(colorpiece,extract(%0,5,1))][u(colorpiece,extract(%0,1,1))][u(colorpiece,extract(%0,13,1))]|%b%b[u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))][u(colorpiece,extract(%0,2,1))][u(colorpiece,extract(%0,9,1))]%b%b|[u(colorpiece,extract(%0,7,1))][u(colorpiece,extract(%0,6,1))][u(colorpiece,extract(%0,12,1))]%b[u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_14 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,11,1))][u(colorpiece,extract(%0,5,1))][u(colorpiece,extract(%0,1,1))]%b|%b[u(colorpiece,extract(%0,14,1))][u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))][u(colorpiece,extract(%0,2,1))][u(colorpiece,extract(%0,9,1))][u(colorpiece,extract(%0,13,1))]%b|%b[u(colorpiece,extract(%0,7,1))][u(colorpiece,extract(%0,6,1))][u(colorpiece,extract(%0,12,1))][u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_15 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(15%)%b%b)]|[space(6)]
&ASCPIT_16 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(16%)%b%b)]|[space(6)]
&ASCPIT_17 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(17%)%b%b)]|[space(6)]
&ASCPIT_18 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(18%)%b%b)]|[space(6)]
&ASCPIT_19 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(19%)%b%b)]|[space(6)]
&ASCPIT_20 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(20%)%b%b)]|[space(6)]
&ASCPIT_21 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(21%)%b%b)]|[space(6)]
&ASCPIT_22 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(22%)%b%b)]|[space(6)]
&ASCPIT_23 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(23%)%b%b)]|[space(6)]
&ASCPIT_24 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(24%)%b%b)]|[space(6)]
&ASCPIT_25 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(25%)%b%b)]|[space(6)]
&ASCPIT_26 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(26%)%b%b)]|[space(6)]
&ASCPIT_27 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(27%)%b%b)]|[space(6)]
&ASCPIT_28 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(28%)%b%b)]|[space(6)]
&ASCPIT_29 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(29%)%b%b)]|[space(6)]
&ASCPIT_30 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(30%)%b%b)]|[space(6)]
&ASCPIT_31 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(31%)%b%b)]|[space(6)]
&ASCPIT_32 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(32%)%b%b)]|[space(6)]
&ASCPIT_33 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(33%)%b%b)]|[space(6)]
&ASCPIT_34 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(34%)%b%b)]|[space(6)]
&ASCPIT_35 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(35%)%b%b)]|[space(6)]
&ASCPIT_36 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(36%)%b%b)]|[space(6)]
&ASCPIT_37 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(37%)%b%b)]|[space(6)]
&ASCPIT_38 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(38%)%b%b)]|[space(6)]
&ASCPIT_39 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(39%)%b%b)]|[space(6)]
&ASCPIT_40 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(40%)%b%b)]|[space(6)]
&ASCPIT_41 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(41%)%b%b)]|[space(6)]
&ASCPIT_42 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(42%)%b%b)]|[space(6)]
&ASCPIT_43 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(43%)%b%b)]|[space(6)]
&ASCPIT_44 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(44%)%b%b)]|[space(6)]
&ASCPIT_45 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(45%)%b%b)]|[space(6)]
&ASCPIT_46 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(46%)%b%b)]|[space(6)]
&ASCPIT_47 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(47%)%b%b)]|[space(6)]
&ASCPIT_48 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(48%)%b%b)]|[space(6)]
&BOARDMAP Mancala ASCII Art=[center(name(v(player_0)),79)]%r[space(16)] 6 [space(6)] 5 [space(6)] 4 [space(5)] 3 [space(6)] 2 [space(6)] 1%r [setq(0, map(pitmap_0, 6 5 4 3 2 1))][setq(9, v(pieces_00))][setq(8, v(pieces_10))].--.----.----[repeat(.----.---,5)].----.----.----.--.%r |-/[ljust(u(tophalf, %q8,1,6),6)]%\--/[u(pitdisp_a, 6 5 4 3 2 1)]%\--/[ljust(u(tophalf, %q9,25,6),6)]%\-|%r |/[ljust(u(tophalf, %q8,7,8),8)]%\[u(pitdisp_b, 6 5 4 3 2 1)]|/[ljust(u(tophalf, %q9,31,8),8)]%\|%r |[ljust(u(tophalf, %q8,15,10),10)]|%\[u(pitdisp_c, 6 5 4 3 2 1)]/|[ljust(u(tophalf, %q9,39,10),10)]|%r |[space(10)]|->--[repeat(--<--->--,5)]--<-|[space(10)]|[setq(0, map(pitmap_1, 1 2 3 4 5 6))]%r |[rjust(u(bothalf, %q8,39,10),10)]|/[u(pitdisp_a, 1 2 3 4 5 6)]%\|[rjust(u(bothalf, %q9,15,10),10)]|%r |%\[rjust(u(bothalf, %q8,31,8),8)]/[u(pitdisp_b, 1 2 3 4 5 6)]|%\[rjust(u(bothalf, %q9,7,8),8)]/|%r |-%\[rjust(u(bothalf, %q8,25,6),6)]/--%\[u(pitdisp_c, 1 2 3 4 5 6)]/--%\[rjust(u(bothalf, %q9,1,6),6)]/-|%r `--`----'----[repeat(`----'---,5)]`----'----`----'--'%r [space(15)] 1 [space(6)] 2 [space(6)] 3 [space(5)] 4 [space(6)] 5 [space(6)] 6%r[center(name(v(player_1)),79)]
&BOTHALF Mancala ASCII Art=iter(revwords(extract(%0,%1,%2)), u(colorpiece,##),%b,)
&COLORPIECE Mancala ASCII Art=ansi(switch(mod(%0,6), 0, r, 1, b, 2, c, 3, y, 4, m, 5, g)h, o)
@DESCRIBE Mancala ASCII Art=[tagwrap(PRE,[ifelse(words(lattr(me)), [u(boardmap)][ifelse(hasattr(me,turn), %rIt is [name(v(player_[v(turn)]))]'s turn., center(Use this game for instructions - 'use [name(me)]',79))], center(To initialize the [name(me)] type: @tr [name(me)]/INITPIECES,79))])]
@set Mancala ASCII Art/DESCRIBE=no_command visual
&PITDISP_A Mancala ASCII Art=after(iter(%0, %\-/[extract(r(##),1,1,|)],%b,),%\-/)
&PITDISP_B Mancala ASCII Art=iter(%0, |[extract(r(##),2,1,|)],%b,)
&PITDISP_C Mancala ASCII Art=after(iter(%0, /-%\[extract(r(##),3,1,|)],%b,),/-%\)
&PITMAP_0 Mancala ASCII Art=setq(%0, u(ascpit_[words(v(pieces_0%0))], v(pieces_0%0)))
&PITMAP_1 Mancala ASCII Art=setq(%0, u(ascpit_[words(v(pieces_1%0))], v(pieces_1%0)))
&TOPHALF Mancala ASCII Art=iter(extract(%0,%1,%2), u(colorpiece,##),%b,)
@create Mancala Game Code
@lock Mancala Game Code==me
@set Mancala Game Code=NO_COMMAND
&COMP_RECORDS Mancala Game Code=ifelse(setr(0, sub(v(record_%1), v(record_%0))), %q0, ifelse(setr(0, sub(last(v(record_%1)), last(v(record_%0)))), %q0, sub(member(v(hiscorers) %0 %1, %0), member(v(hiscorers) %0 %1, %1))))
&CREDITS_CMD Mancala Game Code=$mccredits: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, Mancala Credits)] [ansi(hm, repeat(-,41))]%r [ansi(c, This mancala game was coded by)] [ansi(hw, Alierak)] [ansi(c, and)] [ansi(hw, Kareila)][ansi(c, @ChaoticMUX%r %(chaotic.mit.edu 4201%). It was a lot of work%, so please%, if you use%r this code%, have the courtesy to leave these credits intact. :%))]%r[ansi(hm, repeat(-,69))]
&ENOUGH_GAMES Mancala Game Code=gte(last(v(record_%0)),5)
&FORFEIT_CMD Mancala Game Code=$mcforfeit: @pemit %# = switch(0, hasattr(me,turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)],%#), {You're not playing this game.[setq(0,#-1)]}, setq(0,me)); @remit loc(%q0) = %n forfeits the Mancala game with [name(setdiff(v(player_0) [v(player_1)],%#))].; @tr %q0/game_over=switch(%#, v(player_0), -1, v(player_1), 1)
&GAME_OVER Mancala Game Code=@remit loc(me) = switch(%0, 1, {[name(v(player_0))] has won the Mancala game with [name(v(player_1))]![setq(0,1)][setq(1,0)]}, -1, {[name(v(player_1))] has won the Mancala game with [name(v(player_0))]![setq(0,0)][setq(1,1)]}, 0, {[name(v(player_0))] and [name(v(player_1))] have tied at Mancala![setq(0,1)][setq(1,1)]}); &record_[v(player_0)] me = u(update_record, v(record_[v(player_0)]), %q0); &record_[v(player_1)] me = u(update_record, v(record_[v(player_1)]), %q1); &hiscorers me = sortby(me/comp_records, filter(me/enough_games, setunion(v(hiscorers), v(player_0) [v(player_1)]))); @pemit/list v(watching) = [ansi(hm, repeat(-,13))] [ansi(hc, Mancala Records)] [ansi(hm, repeat(-,39))]%r [ansi(hc, #%b%b[ljust(Player,28)] Games Played [center(Wins,11)] Percentage)]%r[ansi(hm, repeat(-,69))][ansi(c, map(me/show_record, sortby(me/comp_records, v(player_0) [v(player_1)])))]%r[ansi(hm, repeat(-,69))]; @tr me/initpieces
&HELP_CMD Mancala Game Code=$mchelp:@pemit %#=u(use)
&INITPIECES Mancala Game Code=&pieces_01 me=0 6 12 18; &pieces_02 me=1 7 13 19; &pieces_03 me=2 8 14 20; &pieces_04 me=3 9 15 21; &pieces_05 me=4 10 16 22; &pieces_06 me=5 11 17 23; &pieces_16 me=24 30 36 42; &pieces_15 me=25 31 37 43; &pieces_14 me=26 32 38 44; &pieces_13 me=27 33 39 45; &pieces_12 me=28 34 40 46; &pieces_11 me=29 35 41 47; &pieces_00 me; &pieces_10 me; &undo_info me; &turn me; &watching me; @wipe me/player_?; &busy me
&MOVE_CMD Mancala Game Code=$mcmove *: @pemit %# = switch(0, hasattr(me,turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)],%#), {You're not playing this game.[setq(0,#-1)]}, strmatch(%#, v(player_[v(turn)])), {It's not your turn.[setq(0,#-1)]}, not(hasattr(me,busy)), {You can't do that right now.[setq(0,#-1)]}, member(1 2 3 4 5 6, %0), {That's not a valid bowl number.[setq(0,#-1)]}, words(v(pieces_[v(turn)]%0)), {There aren't any pieces in that bowl.[setq(0,#-1)]}, setq(0,me)); @pemit/list get(%q0/watching) = %n moves [setr(1, words(v(pieces_[v(turn)]%0)))] stone[ifelse(gt(%q1,1),s,)] from %p %0-bowl.; &busy %q0=moving stones; @tr %q0/move_stones=v(turn),%0;
&MOVE_ORDER_0 Mancala Game Code=06 05 04 03 02 01 00 16 15 14 13 12 11
&MOVE_ORDER_1 Mancala Game Code=16 15 14 13 12 11 10 06 05 04 03 02 01
&MOVE_STONES Mancala Game Code=&undo_info me=iter(v(move_order_0) 10, &pieces_## me=[v(pieces_##)]%;) &turn me=[v(turn)]; think setq(0, v(pieces_%0%1)); &pieces_%0%1 me; @dolist reverse(rest(reverse(setr(1, extract(repeat(v(move_order_%0)%b, 5), inc(member(v(move_order_%0), %0%1)), words(%q0)))))) = {&pieces_## me=v(pieces_##) [extract(%q0,#@,1)]}; &pieces_[setr(1, last(%q1))] me=v(pieces_%q1) [setr(0, last(%q0))]; @wait 0={@switch/first 1 = strmatch(lattr(me/pieces_0*), pieces_00), {@tr me/wipe_board=0}, strmatch(lattr(me/pieces_1*), pieces_10), {@tr me/wipe_board=1}, eq(%q1,%00), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into [poss(v(player_%0))] own mancala and gets to move again.; @tr me/next_turn=%0}, and(eq(%0, div(%q1,10)), eq(words(v(pieces_%q1)),1), hasattr(me, pieces_[setr(2, rjust(sub(17,%q1),2,0))])), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into an empty bowl across from [setr(3, words(v(pieces_%q2)))] of [name(v(player_[not(%0)]))]'s stones and captures [switch(%q3,1,it,them)] into [poss(v(player_%0))] mancala!; &pieces_%00 me=v(pieces_%00) [v(pieces_%q1)] [v(pieces_%q2)]; &pieces_%q1 me; &pieces_%q2 me; @tr me/next_turn=not(%0)}, {@tr me/next_turn=not(%0)}}
&NEXT_TURN Mancala Game Code=&turn me=%0; @switch/first 1 = strmatch(lattr(me/pieces_0*), pieces_00), {@tr me/wipe_board=0}, strmatch(lattr(me/pieces_1*), pieces_10), {@tr me/wipe_board=1}, {@pemit/list v(watching) = u(boardmap)%rIt is [name(v(player_[v(turn)]))]'s turn.; &busy me}
&NUGGETS_CMD Mancala Game Code=$mcnuggets:@pemit %#=Would you like fries with that? (Type "mchelp" for help.)
@OUSE Mancala Game Code=looks curiously at the [name(me)].
@set Mancala Game Code/OUSE=no_command
&OWNED_FILTER Mancala Game Code=match(owner(%0), owner(me))
&PLAY_CMD Mancala Game Code=$mcplay *: @pemit %# = switch(0, not(hasattr(me, turn)), {There is already a Mancala game in progress.[setq(0,#-1)]}, not(strmatch(conn(%#), -1)), {You're not special enough to do that.[setq(0,#-1)]}, not(or(strmatch(%0,me), strmatch(%#, setr(2, pmatch(%0))))), {You can't play against yourself![setq(0,#-1)]}, and(member(lcon(here), %q2), not(strmatch(conn(%q2), -1))), {I don't see that player here.[setq(0,#-1)]}, setq(0,me)); @remit loc(%q0) = %n starts a game of Mancala with [name(%q2)]. Type 'mcwatch' to watch.; &player_0 %q0=%#; &player_1 %q0=%q2; &watching %q0=%# %q2; &turn %q0=rand(2); @pemit/list get(%q0/watching) = The [name(me)] is currently set up for variation [v(variation)], [v(vdesc)].%r[name(v(player_[v(turn)]))] will go first.; @tr %q0/next_turn=v(turn)
@QUEUE Mancala Game Code=
@set Mancala Game Code/QUEUE=no_inherit no_clone wizard
&RESET_CMD Mancala Game Code=$mcreset: @pemit %# = switch(0, hasattr(me,turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)],%#), switch(conn(v(player_0))[conn(v(player_1))], -1-1, setq(0,me), {At least one of the players is still connected.[setq(0,#-1)]}), setq(0,me)); @remit loc(%q0) = %n resets the Mancala game.; @halt %q0 = {@tr [ifelse(or(gt(words(v(pieces_00)),24), gt(words(v(pieces_10)),24)), setq(0,#-1)me, #-1)]/game_over=sign(sub(words(v(pieces_00)), words(v(pieces_10)))); @tr %q0/initpieces}
&RULES_CMD Mancala Game Code=$mcrules: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, Mancala Variation [v(variation)] Rules)] [ansi(hm, repeat(-,40))]%r[ansi(c, u(rules))]%r[ansi(hm, repeat(-,78))]
&RULES_CMD2 Mancala Game Code=$mcrules *: @pemit %# = switch(#-1, setr(1, locate(me, Mancala Variation %0, iX)), {That variation of Mancala rules doesn't seem to exist.}, {[ansi(hm, repeat(-,11))] [ansi(hc, [name(%q1)] Rules)] [ansi(hm, repeat(-,40))]%r[ansi(c, u(%q1/rules))]%r[ansi(hm, repeat(-,78))]})
&SHOW_RECORD Mancala Game Code=%r[ansi(hc, rjust(ifelse(setr(0, member(v(hiscorers),%0)), %q0, --), 2).)] [ansi(hw, ljust(left(name(%0),28),28))] [ansi(c, [rjust(last(setr(0, v(record_%0))), 7)][rjust(extract(%q0,2,1), 12)][rjust(first(%q0), 12)]%%)]
&TOP_ALL_CMD Mancala Game Code=$mctop/all: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, All Mancala Players With 5 Games Or More)] [ansi(hm, repeat(-,16))]%r [ansi(hc, #%b%b[ljust(Player,28)] Games Played [center(Wins,11)] Percentage)]%r[ansi(hm, repeat(-,69))][ansi(c, map(me/show_record, v(hiscorers)))]%r[ansi(hm, repeat(-,69))]
&TOP_CMD Mancala Game Code=$mctop: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, Top Mancala Players)] [ansi(hm, repeat(-,37))]%r [ansi(hc, #%b%b[ljust(Player,28)] Games Played [center(Wins,11)] Percentage)]%r[ansi(hm, repeat(-,69))][ansi(c, map(me/show_record, extract(v(hiscorers),1,10)))]%r[ansi(hm, repeat(-,69))]
&UNDO_CMD Mancala Game Code=$mcundo: @pemit %# = switch(0, hasattr(me, turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)], %#), {You're not playing this game.[setq(0,#-1)]}, hasattr(me, undo_info), {There is no undo information available.[setq(0,#-1)]}, strmatch(%#, v(player_[last(v(undo_info),=)])), {The last move isn't yours to undo.[setq(0,#-1)]}, or(not(hasattr(me, busy)), strmatch(%#, v(player_[v(turn)]))), {Sorry, the next player has already moved.[setq(0,#-1)]}, setq(0,me)); @pemit/list get(%q0/watching) = %n takes back %p last move.; @halt %q0 = {@tr %q0/undo_info; @tr %q0/next_turn=last(v(undo_info),=); &undo_info %q0; &busy %q0=undoing a move;}
&UPDATE_RECORD Mancala Game Code=[round(mul(100, fdiv(setr(2, add(extract(%0,2,1), %1)), setr(3, add(1, last(%0))))),0)] %q2 %q3
@USE Mancala Game Code=[ansi(hm, repeat(-,9))] [ansi(hc, Mancala Commands)] [ansi(hm, repeat(-,43))]%r [ansi(hc, ljust(mcvar,26))] [ansi(c, show the current variation of Mancala)]%r [ansi(hc, ljust(mcvars,26))] [ansi(c, list the supported variations)]%r [ansi(hc, ljust(mcvar <var>,26))] [ansi(c, select a new variation of the rules)]%r [ansi(hc, ljust(mcrules,26))] [ansi(c, show full rules of the current variation)]%r [ansi(hc, ljust(mcrules <var>,26))] [ansi(c, show a specified variation of the rules)]%r%r [ansi(hc, ljust(mcplay <player>,26))] [ansi(c, start a game with <player>)]%r [ansi(hc, ljust(mcwatch %[on|off%],26))] [ansi(c, start or stop watching a game in progress)]%r [ansi(hc, ljust(mcmove <#>,26))] [ansi(c, move the stones from your <#> bowl)]%r [ansi(hc, ljust(mcundo,26))] [ansi(c, undo the last move if possible)]%r%r [ansi(hc, ljust(mcforfeit,26))] [ansi(c, give up and let the other player win)]%r [ansi(hc, ljust(mcreset,26))] [ansi(c, reset the game %(records a win if obvious%))]%r [ansi(hc, ljust(mctop%[/all%],26))] [ansi(c, display top 10 %(or all%) scorers)]%r [ansi(hc, ljust(mccredits,26))] [ansi(c, show the credits for this code)]%r [ansi(hc, ljust(mcnuggets,26))] [ansi(c, order some food)]%r[ansi(hm, repeat(-,70))]
@set Mancala Game Code/USE=no_command
&VARS_CMD Mancala Game Code=$mcvars: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, Supported Mancala Variations)] [ansi(hm, repeat(-,13))] [ansi(hw,*)] [ansi(hc, = current)] [ansi(hm, repeat(-,11))][iter(sort(iter(filter(owned_filter, lcon(me)), get(##/variation))), %r [switch(##, v(variation), ansi(hw,*), %b)] [ansi(hc,##.)] [ansi(c, capstr(get(locate(me, Mancala Variation ##, iX)/vdesc)))])]%r[ansi(hm, repeat(-,78))]
&VAR_CMD Mancala Game Code=$mcvar:@pemit %#=The [name(me)] is currently set up for variation [v(variation)], [v(vdesc)].
&VAR_CMD2 Mancala Game Code=$mcvar *: @pemit %# = switch(0, not(hasattr(me, turn)), {You can't change the rules in the middle of a game![setq(0,#-1)]}, not(strmatch(setr(1, locate(me, Variation %0, iX)), #-1)), {That variation of Mancala rules doesn't seem to exist.[setq(0,#-1)]}, not(strmatch(%0, v(variation))), {That's already the current variation.[setq(0,#-1)]}, setq(0,me)); @parent %q0=%q1; @remit loc(%q0) = %n changes the Mancala rules to variation [v(variation)], [v(vdesc)].
&WATCH_CMD Mancala Game Code=$mcwatch*: @switch/first %0 = %boff, {@pemit %# = switch(0, hasattr(me, turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(watching), %#), {You're not watching the Mancala game.[setq(0,#-1)]}, not(member(v(player_0) [v(player_1)], %#)), {You're still playing! Use mcreset to quit.[setq(0,#-1)]}, {You stop watching the Mancala game.[setq(0,me)][setq(1,%#)]}); @remit loc(%q1) = %n stops watching the Mancala game.; &watching %q0=setdiff(v(watching), %#)}, {@pemit %# = switch(0, hasattr(me, turn), {There is no Mancala game in progress.[setq(0,#-1)]}, not(member(v(watching), %#)), {You're already watching this game.[setq(0,#-1)]}, {You are now watching the Mancala game. Type 'mcwatch off' to stop watching.[setq(0,me)][setq(1,%#)]}); @remit loc(%q1) = %n watches the Mancala game.; &watching %q0=v(watching) %#}
&WIPE_BOARD Mancala Game Code=@pemit/list v(watching) = [name(v(player_%0))]'s side of the board is empty, so [name(v(player_[not(%0)]))] collects all of [poss(v(player_[not(%0)]))] remaining pieces into [poss(v(player_[not(%0)]))] mancala.; &pieces_[not(%0)]0 me=iter(v(move_order_[not(%0)]), v(pieces_##)); @dolist lnum(6) = {@wipe me/pieces_?#@}; @wait 0 = {@pemit/list v(watching) = u(boardmap)}; @tr me/game_over=sign(sub(words(v(pieces_00)), words(v(pieces_10))))
@create Mancala Variation 1
@parent Mancala Variation 1=Mancala Game Code
@lock/Basic Mancala Variation 1==me
@lset Mancala Variation 1/Basic=no_inherit
@set Mancala Variation 1 = NO_COMMAND
&RULES Mancala Variation 1=Each player has six numbered bowls and one larger bowl, called the mancala, adjacent to her 1-bowl. On each turn, a player takes the stones out of one of her numbered bowls (mcmove #) and places them one by one into the other bowls, moving clockwise and including her own mancala but not the opponent's. If she places the last stone in her own mancala, she gets to move again. If the last stone ends up in an empty one of the player's own numbered bowls, and the opponent's bowl across from it contains any stones, the player moves the contents of both bowls to her own mancala. The game ends when either player empties all their numbered bowls. The player with stones left gets to keep them, and the player with more stones at that point wins. A tie counts as a win for both players.
&VARIATION Mancala Variation 1=1
&VDESC Mancala Variation 1=the original rules (player with stones left keeps them)
@create Mancala Variation 2
@parent Mancala Variation 2=Mancala Game Code
@lock/Basic Mancala Variation 2==me
@lset Mancala Variation 2/Basic=no_inherit
@set Mancala Variation 2 = NO_COMMAND
&RULES Mancala Variation 2=This is the same as the original rules (mcrules 1) except for what happens when either side of the board is cleared. In this variation, the player with the empty side gets all the remaining pieces. As in the original, this happens regardless of which player's move causes the bowls to be empty.
&VARIATION Mancala Variation 2=2
&VDESC Mancala Variation 2=Rak & Kar's rules (player with no stones left gets the rest of them)
&WIPE_BOARD Mancala Variation 2=@pemit/list v(watching) = [name(v(player_%0))]'s side of the board is empty, so [subj(v(player_%0))] collects all of [name(v(player_[not(%0)]))]'s remaining pieces into [poss(v(player_%0))] mancala.; &pieces_%00 me=iter(v(move_order_%0), v(pieces_##)); @dolist lnum(6) = {@wipe me/pieces_?#@}; @wait 0 = {@pemit/list v(watching) = u(boardmap)}; @tr me/game_over=sign(sub(words(v(pieces_00)), words(v(pieces_10))))
@create Mancala Variation 3
@parent Mancala Variation 3=Mancala Game Code
@lock/Basic Mancala Variation 3==me
@lset Mancala Variation 3/Basic=no_inherit
@set Mancala Variation 3 = NO_COMMAND
&MOVE_ORDER_0 Mancala Variation 3=06 12 04 14 02 16 00 01 15 03 13 05 11
&MOVE_ORDER_1 Mancala Variation 3=16 02 14 04 12 06 10 11 05 13 03 15 01
&RULES Mancala Variation 3=This is the same as the original rules (mcrules 1) except for the order in which stones are placed on each turn. Don't blame me, LITE came up with this. LITE warns that the game gets exceedingly weird. If you move from an even-numbered bowl, you start zigzagging down the board towards your mancala, placing stones in all the even-numbered bowls. Next you place one in your mancala, and then you start using the odd-numbered bowls beginning with the opponent's 6-bowl. If you start on an odd-numbered bowl, you zigzag towards your mancala along the odd-numbered bowls, then start using the even-numbered bowls beginning with your 6-bowl. Notice that it takes more stones to reach your mancala from an odd-numbered bowl. You'll probably have to play this one a couple of times to get the hang of it, I know I will...
&VARIATION Mancala Variation 3=3
&VDESC Mancala Variation 3=alternating sides (drop stones in zigzag instead of clockwise order)
@create Mancala Variation 4
@parent Mancala Variation 4=Mancala Game Code
@lock/Basic Mancala Variation 4==me
@lset Mancala Variation 4/Basic=no_inherit
@set Mancala Variation 4 = NO_COMMAND
&MOVE_ORDER_0 Mancala Variation 4=03 02 01 00 16 15 14 04 05 06 11 12 13
&MOVE_ORDER_1 Mancala Variation 4=13 12 11 10 06 05 04 14 15 16 01 02 03
&RULES Mancala Variation 4=This is the same as the original rules (mcrules 1) except for the order in which stones are placed on each turn. This one is sTiLe's idea. If you move from your 1, 2, or 3-bowl, you begin moving toward your mancala like normal. If you are the player on the top, you circle around the board and cross from your opponent's 4-bowl to yours. You then move backwards along your row, go from your 6 to your opponent's 1-bowl, then cross at their 3-bowl back to yours. The basic movement is that of an infinity symbol (8 on its side), crossing at 4-4 and 3-3.
&VARIATION Mancala Variation 4=4
&VDESC Mancala Variation 4=figure-eight (cross over in middle of board when dropping stones)
@create Mancala Variation 5
@parent Mancala Variation 5=Mancala Game Code
@lock/Basic Mancala Variation 5==me
@lset Mancala Variation 5/Basic=no_inherit
@set Mancala Variation 5 = NO_COMMAND
&FORFEIT_CMD Mancala Variation 5=$mcforfeit: @pemit %# = switch(0, hasattr(me,turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)],%#), {You're not playing this game.[setq(0,#-1)]}, setq(0,me)); @remit loc(%q0) = %n forfeits the Mancala game with [name(setdiff(v(player_0) [v(player_1)],%#))].; @tr %q0/game_over=switch(%#, v(player_0), 1, v(player_1), -1)
&GAME_OVER Mancala Variation 5=@remit loc(me) = switch(%0, -1, {[name(v(player_0))] has won the Mancala game with [name(v(player_1))]![setq(0,1)][setq(1,0)]}, 1, {[name(v(player_1))] has won the Mancala game with [name(v(player_0))]![setq(0,0)][setq(1,1)]}, 0, {[name(v(player_0))] and [name(v(player_1))] have tied at Mancala![setq(0,1)][setq(1,1)]}); &record_[v(player_0)] me = u(update_record, v(record_[v(player_0)]), %q0); &record_[v(player_1)] me = u(update_record, v(record_[v(player_1)]), %q1); &hiscorers me = sortby(me/comp_records, filter(me/enough_games, setunion(v(hiscorers), v(player_0) [v(player_1)]))); @pemit/list v(watching) = [ansi(hm, repeat(-,13))] [ansi(hc, Mancala Records)] [ansi(hm, repeat(-,39))]%r [ansi(hc, #%b%b[ljust(Player,28)] Games Played [center(Wins,11)] Percentage)]%r[ansi(hm, repeat(-,69))][ansi(c, map(me/show_record, sortby(me/comp_records, v(player_0) [v(player_1)])))]%r[ansi(hm, repeat(-,69))]; @tr me/initpieces
&RULES Mancala Variation 5=This is the same as Rak & Kar's rules (mcrules 2) except that the player with the fewest stones at the end wins. This is based on variation 2 (player with no stones left gets the rest of them) instead of the original rules to keep the primary strategy from being "run off the board as quickly as possible".
&VARIATION Mancala Variation 5=5
&VDESC Mancala Variation 5=anti-mancala (fewest stones wins)
&WIPE_BOARD Mancala Variation 5=@pemit/list v(watching) = [name(v(player_%0))]'s side of the board is empty, so [subj(v(player_%0))] collects all of [name(v(player_[not(%0)]))]'s remaining pieces into [poss(v(player_%0))] mancala.; &pieces_%00 me=iter(v(move_order_%0), v(pieces_##)); @dolist lnum(6) = {@wipe me/pieces_?#@}; @wait 0 = {@pemit/list v(watching) = u(boardmap)}; @tr me/game_over=sign(sub(words(v(pieces_00)), words(v(pieces_10))))
@create Mancala Variation 6
@parent Mancala Variation 6=Mancala Game Code
@lock/Basic Mancala Variation 6==me
@lset Mancala Variation 6/Basic=no_inherit
@set Mancala Variation 6 = NO_COMMAND
&MOVE_STONES Mancala Variation 6=&undo_info me=iter(v(move_order_0) 10, &pieces_## me=[v(pieces_##)]%;) &turn me=[v(turn)]; think setq(0, v(pieces_%0%1)); &pieces_%0%1 me; @dolist reverse(rest(reverse(setr(1, extract(repeat(v(move_order_%0)%b, 5), inc(member(v(move_order_%0), %0%1)), words(%q0)))))) = {&pieces_## me=v(pieces_##) [extract(%q0,#@,1)]}; &pieces_[setr(1, last(%q1))] me=v(pieces_%q1) [setr(0, last(%q0))]; @wait 0 = {@switch/first 1 = strmatch(lattr(me/pieces_0*), pieces_00), {@tr me/wipe_board=0}, strmatch(lattr(me/pieces_1*), pieces_10), {@tr me/wipe_board=1}, eq(%q1,%00), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into [poss(v(player_%0))] own mancala and gets to move again.; @tr me/next_turn=%0}, and(eq(words(v(pieces_%q1)),1), hasattr(me, pieces_[setr(2, rjust(sub(17,%q1),2,0))])), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into an empty bowl across from [setr(3, words(v(pieces_%q2)))] stone[switch(%q3,1,,s)] and captures [switch(%q3,1,it,them)] into [poss(v(player_%0))] mancala!; &pieces_%00 me=v(pieces_%00) [v(pieces_%q1)] [v(pieces_%q2)]; &pieces_%q1 me; &pieces_%q2 me; @tr me/next_turn=not(%0)}, {@tr me/next_turn=not(%0)}}
&RULES Mancala Variation 6=This is the same as the original rules (mcrules 1) except that players may capture stones by landing in an empty bowl across from an occupied one on either side of the board.
&VARIATION Mancala Variation 6=6
&VDESC Mancala Variation 6=capture anywhere (empty bowls on opponent's side work too)
@create Mancala Variation 7
@parent Mancala Variation 7=Mancala Game Code
@lock/Basic Mancala Variation 7==me
@lset Mancala Variation 7/Basic=no_inherit
@set Mancala Variation 7 = NO_COMMAND
&MOVE_STONES Mancala Variation 7=&undo_info me=iter(v(move_order_0) 10, &pieces_## me=[v(pieces_##)]%;) &turn me=[v(turn)]; think setq(0, v(pieces_%0%1)); &pieces_%0%1 me; @dolist reverse(rest(reverse(setr(1, extract(repeat(v(move_order_%0)%b, 5), inc(member(v(move_order_%0), %0%1)), words(%q0)))))) = {&pieces_## me=v(pieces_##) [extract(%q0,#@,1)]}; &pieces_[setr(1, last(%q1))] me=v(pieces_%q1) [setr(0, last(%q0))]; @wait 0 = {@switch/first 1 = strmatch(lattr(me/pieces_0*), pieces_00), {@tr me/wipe_board=0}, strmatch(lattr(me/pieces_1*), pieces_10), {@tr me/wipe_board=1}, eq(%q1,%00), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into [poss(v(player_%0))] own mancala and gets to move again.; @tr me/next_turn=%0}, and(eq(%0, div(%q1,10)), eq(words(v(pieces_%q1)),1), hasattr(me, pieces_[setr(2, rjust(sub(17,%q1),2,0))])), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into an empty bowl across from [setr(3, words(v(pieces_%q2)))] of [name(v(player_[not(%0)]))]'s stones and captures [switch(%q3,1,it,them)] into [poss(v(player_%0))] [after(%q1,%0)]-bowl!; &pieces_%q1 me=v(pieces_%q1) [v(pieces_%q2)]; &pieces_%q2 me; @tr me/next_turn=not(%0)}, {@tr me/next_turn=not(%0)}}
&RULES Mancala Variation 7=This is the same as the original rules (mcrules 1) except that when a player makes a capture by landing in an empty bowl on her own side across from some of the opponent's stones, she moves the captured stones into the bowl where she landed, rather than into her mancala.
&VARIATION Mancala Variation 7=7
&VDESC Mancala Variation 7=capture across (move stones across the board when you capture)
@parent Mancala Game Code=Mancala ASCII Art
@create Mancala
@lock Mancala==#0
@set Mancala=!NO_COMMAND
@parent Mancala=Mancala Game Code
give Mancala=Mancala Game Code
give Mancala=Mancala ASCII Art
give Mancala=Mancala Variation 1
give Mancala=Mancala Variation 2
give Mancala=Mancala Variation 3
give Mancala=Mancala Variation 4
give Mancala=Mancala Variation 5
give Mancala=Mancala Variation 6
give Mancala=Mancala Variation 7
drop Mancala
@lock Mancala ASCII Art==me
@set Mancala ASCII Art=NO_COMMAND
&ASCPIT_0 Mancala ASCII Art=[space(6)]|[space(8)]|[space(6)]
&ASCPIT_1 Mancala ASCII Art=[space(6)]|%b%b%b%b[u(colorpiece,extract(%0,1,1))]%b%b%b|[space(6)]
&ASCPIT_2 Mancala ASCII Art=[space(6)]|%b%b[u(colorpiece,extract(%0,1,1))]%b[u(colorpiece,extract(%0,2,1))]%b%b%b|[space(6)]
&ASCPIT_3 Mancala ASCII Art=%b%b%b[u(colorpiece,extract(%0,3,1))]%b%b|%b%b[u(colorpiece,extract(%0,2,1))]%b%b%b%b%b|%b%b[u(colorpiece,extract(%0,1,1))]%b%b%b
&ASCPIT_4 Mancala ASCII Art=%b%b[u(colorpiece,extract(%0,3,1))]%b%b%b|%b%b[u(colorpiece,extract(%0,2,1))]%b%b[u(colorpiece,extract(%0,4,1))]%b%b|%b%b%b[u(colorpiece,extract(%0,1,1))]%b%b
&ASCPIT_5 Mancala ASCII Art=%b%b[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,5,1))]%b|%b%b[u(colorpiece,extract(%0,2,1))]%b[u(colorpiece,extract(%0,1,1))]%b%b%b|%b%b%b[u(colorpiece,extract(%0,4,1))]%b%b
&ASCPIT_6 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,5,1))]%b%b|%b%b[u(colorpiece,extract(%0,2,1))]%b%b[u(colorpiece,extract(%0,1,1))]%b%b|%b%b[u(colorpiece,extract(%0,4,1))]%b[u(colorpiece,extract(%0,6,1))]%b
&ASCPIT_7 Mancala ASCII Art=%b%b[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,4,1))]%b|%b[u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]%b[u(colorpiece,extract(%0,7,1))]%b%b|%b%b[u(colorpiece,extract(%0,2,1))]%b[u(colorpiece,extract(%0,6,1))]%b
&ASCPIT_8 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]|%b%b[u(colorpiece,extract(%0,2,1))]%b%b[u(colorpiece,extract(%0,4,1))]%b%b|[u(colorpiece,extract(%0,7,1))]%b[u(colorpiece,extract(%0,6,1))]%b[u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_9 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]%b|%b%b[u(colorpiece,extract(%0,2,1))]%b[u(colorpiece,extract(%0,4,1))]%b[u(colorpiece,extract(%0,9,1))]%b|%b[u(colorpiece,extract(%0,7,1))]%b[u(colorpiece,extract(%0,6,1))][u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_10 Mancala ASCII Art=[u(colorpiece,extract(%0,3,1))]%b[u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]%b|%b%b[u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))][u(colorpiece,extract(%0,2,1))][u(colorpiece,extract(%0,9,1))]%b%b|%b[u(colorpiece,extract(%0,7,1))]%b[u(colorpiece,extract(%0,6,1))]%b[u(colorpiece,extract(%0,8,1))]
&ASCPIT_11 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,11,1))][u(colorpiece,extract(%0,5,1))]%b[u(colorpiece,extract(%0,1,1))]|%b[u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))]%b[u(colorpiece,extract(%0,2,1))]%b[u(colorpiece,extract(%0,9,1))]%b|%b[u(colorpiece,extract(%0,7,1))][u(colorpiece,extract(%0,6,1))]%b[u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_12 Mancala ASCII Art=[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,11,1))][u(colorpiece,extract(%0,5,1))][u(colorpiece,extract(%0,1,1))]%b%b|%b%b[u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))][u(colorpiece,extract(%0,2,1))][u(colorpiece,extract(%0,9,1))]%b%b|%b%b[u(colorpiece,extract(%0,7,1))][u(colorpiece,extract(%0,6,1))][u(colorpiece,extract(%0,12,1))][u(colorpiece,extract(%0,8,1))]
&ASCPIT_13 Mancala ASCII Art=[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,11,1))]%b[u(colorpiece,extract(%0,5,1))][u(colorpiece,extract(%0,1,1))][u(colorpiece,extract(%0,13,1))]|%b%b[u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))][u(colorpiece,extract(%0,2,1))][u(colorpiece,extract(%0,9,1))]%b%b|[u(colorpiece,extract(%0,7,1))][u(colorpiece,extract(%0,6,1))][u(colorpiece,extract(%0,12,1))]%b[u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_14 Mancala ASCII Art=%b[u(colorpiece,extract(%0,3,1))][u(colorpiece,extract(%0,11,1))][u(colorpiece,extract(%0,5,1))][u(colorpiece,extract(%0,1,1))]%b|%b[u(colorpiece,extract(%0,14,1))][u(colorpiece,extract(%0,10,1))][u(colorpiece,extract(%0,4,1))][u(colorpiece,extract(%0,2,1))][u(colorpiece,extract(%0,9,1))][u(colorpiece,extract(%0,13,1))]%b|%b[u(colorpiece,extract(%0,7,1))][u(colorpiece,extract(%0,6,1))][u(colorpiece,extract(%0,12,1))][u(colorpiece,extract(%0,8,1))]%b
&ASCPIT_15 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(15%)%b%b)]|[space(6)]
&ASCPIT_16 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(16%)%b%b)]|[space(6)]
&ASCPIT_17 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(17%)%b%b)]|[space(6)]
&ASCPIT_18 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(18%)%b%b)]|[space(6)]
&ASCPIT_19 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(19%)%b%b)]|[space(6)]
&ASCPIT_20 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(20%)%b%b)]|[space(6)]
&ASCPIT_21 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(21%)%b%b)]|[space(6)]
&ASCPIT_22 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(22%)%b%b)]|[space(6)]
&ASCPIT_23 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(23%)%b%b)]|[space(6)]
&ASCPIT_24 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(24%)%b%b)]|[space(6)]
&ASCPIT_25 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(25%)%b%b)]|[space(6)]
&ASCPIT_26 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(26%)%b%b)]|[space(6)]
&ASCPIT_27 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(27%)%b%b)]|[space(6)]
&ASCPIT_28 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(28%)%b%b)]|[space(6)]
&ASCPIT_29 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(29%)%b%b)]|[space(6)]
&ASCPIT_30 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(30%)%b%b)]|[space(6)]
&ASCPIT_31 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(31%)%b%b)]|[space(6)]
&ASCPIT_32 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(32%)%b%b)]|[space(6)]
&ASCPIT_33 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(33%)%b%b)]|[space(6)]
&ASCPIT_34 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(34%)%b%b)]|[space(6)]
&ASCPIT_35 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(35%)%b%b)]|[space(6)]
&ASCPIT_36 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(36%)%b%b)]|[space(6)]
&ASCPIT_37 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(37%)%b%b)]|[space(6)]
&ASCPIT_38 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(38%)%b%b)]|[space(6)]
&ASCPIT_39 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(39%)%b%b)]|[space(6)]
&ASCPIT_40 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(40%)%b%b)]|[space(6)]
&ASCPIT_41 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(41%)%b%b)]|[space(6)]
&ASCPIT_42 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(42%)%b%b)]|[space(6)]
&ASCPIT_43 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(43%)%b%b)]|[space(6)]
&ASCPIT_44 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(44%)%b%b)]|[space(6)]
&ASCPIT_45 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(45%)%b%b)]|[space(6)]
&ASCPIT_46 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(46%)%b%b)]|[space(6)]
&ASCPIT_47 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(47%)%b%b)]|[space(6)]
&ASCPIT_48 Mancala ASCII Art=[space(6)]|[ansi(hr,%b%b%(48%)%b%b)]|[space(6)]
&BOARDMAP Mancala ASCII Art=[center(name(v(player_0)),79)]%r[space(16)] 6 [space(6)] 5 [space(6)] 4 [space(5)] 3 [space(6)] 2 [space(6)] 1%r [setq(0, map(pitmap_0, 6 5 4 3 2 1))][setq(9, v(pieces_00))][setq(8, v(pieces_10))].--.----.----[repeat(.----.---,5)].----.----.----.--.%r |-/[ljust(u(tophalf, %q8,1,6),6)]%\--/[u(pitdisp_a, 6 5 4 3 2 1)]%\--/[ljust(u(tophalf, %q9,25,6),6)]%\-|%r |/[ljust(u(tophalf, %q8,7,8),8)]%\[u(pitdisp_b, 6 5 4 3 2 1)]|/[ljust(u(tophalf, %q9,31,8),8)]%\|%r |[ljust(u(tophalf, %q8,15,10),10)]|%\[u(pitdisp_c, 6 5 4 3 2 1)]/|[ljust(u(tophalf, %q9,39,10),10)]|%r |[space(10)]|->--[repeat(--<--->--,5)]--<-|[space(10)]|[setq(0, map(pitmap_1, 1 2 3 4 5 6))]%r |[rjust(u(bothalf, %q8,39,10),10)]|/[u(pitdisp_a, 1 2 3 4 5 6)]%\|[rjust(u(bothalf, %q9,15,10),10)]|%r |%\[rjust(u(bothalf, %q8,31,8),8)]/[u(pitdisp_b, 1 2 3 4 5 6)]|%\[rjust(u(bothalf, %q9,7,8),8)]/|%r |-%\[rjust(u(bothalf, %q8,25,6),6)]/--%\[u(pitdisp_c, 1 2 3 4 5 6)]/--%\[rjust(u(bothalf, %q9,1,6),6)]/-|%r `--`----'----[repeat(`----'---,5)]`----'----`----'--'%r [space(15)] 1 [space(6)] 2 [space(6)] 3 [space(5)] 4 [space(6)] 5 [space(6)] 6%r[center(name(v(player_1)),79)]
&BOTHALF Mancala ASCII Art=iter(revwords(extract(%0,%1,%2)), u(colorpiece,##),%b,)
&COLORPIECE Mancala ASCII Art=ansi(switch(mod(%0,6), 0, r, 1, b, 2, c, 3, y, 4, m, 5, g)h, o)
@DESCRIBE Mancala ASCII Art=[tagwrap(PRE,[ifelse(words(lattr(me)), [u(boardmap)][ifelse(hasattr(me,turn), %rIt is [name(v(player_[v(turn)]))]'s turn., center(Use this game for instructions - 'use [name(me)]',79))], center(To initialize the [name(me)] type: @tr [name(me)]/INITPIECES,79))])]
@set Mancala ASCII Art/DESCRIBE=no_command visual
&PITDISP_A Mancala ASCII Art=after(iter(%0, %\-/[extract(r(##),1,1,|)],%b,),%\-/)
&PITDISP_B Mancala ASCII Art=iter(%0, |[extract(r(##),2,1,|)],%b,)
&PITDISP_C Mancala ASCII Art=after(iter(%0, /-%\[extract(r(##),3,1,|)],%b,),/-%\)
&PITMAP_0 Mancala ASCII Art=setq(%0, u(ascpit_[words(v(pieces_0%0))], v(pieces_0%0)))
&PITMAP_1 Mancala ASCII Art=setq(%0, u(ascpit_[words(v(pieces_1%0))], v(pieces_1%0)))
&TOPHALF Mancala ASCII Art=iter(extract(%0,%1,%2), u(colorpiece,##),%b,)
@create Mancala Game Code
@lock Mancala Game Code==me
@set Mancala Game Code=NO_COMMAND
&COMP_RECORDS Mancala Game Code=ifelse(setr(0, sub(v(record_%1), v(record_%0))), %q0, ifelse(setr(0, sub(last(v(record_%1)), last(v(record_%0)))), %q0, sub(member(v(hiscorers) %0 %1, %0), member(v(hiscorers) %0 %1, %1))))
&CREDITS_CMD Mancala Game Code=$mccredits: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, Mancala Credits)] [ansi(hm, repeat(-,41))]%r [ansi(c, This mancala game was coded by)] [ansi(hw, Alierak)] [ansi(c, and)] [ansi(hw, Kareila)][ansi(c, @ChaoticMUX%r %(chaotic.mit.edu 4201%). It was a lot of work%, so please%, if you use%r this code%, have the courtesy to leave these credits intact. :%))]%r[ansi(hm, repeat(-,69))]
&ENOUGH_GAMES Mancala Game Code=gte(last(v(record_%0)),5)
&FORFEIT_CMD Mancala Game Code=$mcforfeit: @pemit %# = switch(0, hasattr(me,turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)],%#), {You're not playing this game.[setq(0,#-1)]}, setq(0,me)); @remit loc(%q0) = %n forfeits the Mancala game with [name(setdiff(v(player_0) [v(player_1)],%#))].; @tr %q0/game_over=switch(%#, v(player_0), -1, v(player_1), 1)
&GAME_OVER Mancala Game Code=@remit loc(me) = switch(%0, 1, {[name(v(player_0))] has won the Mancala game with [name(v(player_1))]![setq(0,1)][setq(1,0)]}, -1, {[name(v(player_1))] has won the Mancala game with [name(v(player_0))]![setq(0,0)][setq(1,1)]}, 0, {[name(v(player_0))] and [name(v(player_1))] have tied at Mancala![setq(0,1)][setq(1,1)]}); &record_[v(player_0)] me = u(update_record, v(record_[v(player_0)]), %q0); &record_[v(player_1)] me = u(update_record, v(record_[v(player_1)]), %q1); &hiscorers me = sortby(me/comp_records, filter(me/enough_games, setunion(v(hiscorers), v(player_0) [v(player_1)]))); @pemit/list v(watching) = [ansi(hm, repeat(-,13))] [ansi(hc, Mancala Records)] [ansi(hm, repeat(-,39))]%r [ansi(hc, #%b%b[ljust(Player,28)] Games Played [center(Wins,11)] Percentage)]%r[ansi(hm, repeat(-,69))][ansi(c, map(me/show_record, sortby(me/comp_records, v(player_0) [v(player_1)])))]%r[ansi(hm, repeat(-,69))]; @tr me/initpieces
&HELP_CMD Mancala Game Code=$mchelp:@pemit %#=u(use)
&INITPIECES Mancala Game Code=&pieces_01 me=0 6 12 18; &pieces_02 me=1 7 13 19; &pieces_03 me=2 8 14 20; &pieces_04 me=3 9 15 21; &pieces_05 me=4 10 16 22; &pieces_06 me=5 11 17 23; &pieces_16 me=24 30 36 42; &pieces_15 me=25 31 37 43; &pieces_14 me=26 32 38 44; &pieces_13 me=27 33 39 45; &pieces_12 me=28 34 40 46; &pieces_11 me=29 35 41 47; &pieces_00 me; &pieces_10 me; &undo_info me; &turn me; &watching me; @wipe me/player_?; &busy me
&MOVE_CMD Mancala Game Code=$mcmove *: @pemit %# = switch(0, hasattr(me,turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)],%#), {You're not playing this game.[setq(0,#-1)]}, strmatch(%#, v(player_[v(turn)])), {It's not your turn.[setq(0,#-1)]}, not(hasattr(me,busy)), {You can't do that right now.[setq(0,#-1)]}, member(1 2 3 4 5 6, %0), {That's not a valid bowl number.[setq(0,#-1)]}, words(v(pieces_[v(turn)]%0)), {There aren't any pieces in that bowl.[setq(0,#-1)]}, setq(0,me)); @pemit/list get(%q0/watching) = %n moves [setr(1, words(v(pieces_[v(turn)]%0)))] stone[ifelse(gt(%q1,1),s,)] from %p %0-bowl.; &busy %q0=moving stones; @tr %q0/move_stones=v(turn),%0;
&MOVE_ORDER_0 Mancala Game Code=06 05 04 03 02 01 00 16 15 14 13 12 11
&MOVE_ORDER_1 Mancala Game Code=16 15 14 13 12 11 10 06 05 04 03 02 01
&MOVE_STONES Mancala Game Code=&undo_info me=iter(v(move_order_0) 10, &pieces_## me=[v(pieces_##)]%;) &turn me=[v(turn)]; think setq(0, v(pieces_%0%1)); &pieces_%0%1 me; @dolist reverse(rest(reverse(setr(1, extract(repeat(v(move_order_%0)%b, 5), inc(member(v(move_order_%0), %0%1)), words(%q0)))))) = {&pieces_## me=v(pieces_##) [extract(%q0,#@,1)]}; &pieces_[setr(1, last(%q1))] me=v(pieces_%q1) [setr(0, last(%q0))]; @wait 0={@switch/first 1 = strmatch(lattr(me/pieces_0*), pieces_00), {@tr me/wipe_board=0}, strmatch(lattr(me/pieces_1*), pieces_10), {@tr me/wipe_board=1}, eq(%q1,%00), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into [poss(v(player_%0))] own mancala and gets to move again.; @tr me/next_turn=%0}, and(eq(%0, div(%q1,10)), eq(words(v(pieces_%q1)),1), hasattr(me, pieces_[setr(2, rjust(sub(17,%q1),2,0))])), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into an empty bowl across from [setr(3, words(v(pieces_%q2)))] of [name(v(player_[not(%0)]))]'s stones and captures [switch(%q3,1,it,them)] into [poss(v(player_%0))] mancala!; &pieces_%00 me=v(pieces_%00) [v(pieces_%q1)] [v(pieces_%q2)]; &pieces_%q1 me; &pieces_%q2 me; @tr me/next_turn=not(%0)}, {@tr me/next_turn=not(%0)}}
&NEXT_TURN Mancala Game Code=&turn me=%0; @switch/first 1 = strmatch(lattr(me/pieces_0*), pieces_00), {@tr me/wipe_board=0}, strmatch(lattr(me/pieces_1*), pieces_10), {@tr me/wipe_board=1}, {@pemit/list v(watching) = u(boardmap)%rIt is [name(v(player_[v(turn)]))]'s turn.; &busy me}
&NUGGETS_CMD Mancala Game Code=$mcnuggets:@pemit %#=Would you like fries with that? (Type "mchelp" for help.)
@OUSE Mancala Game Code=looks curiously at the [name(me)].
@set Mancala Game Code/OUSE=no_command
&OWNED_FILTER Mancala Game Code=match(owner(%0), owner(me))
&PLAY_CMD Mancala Game Code=$mcplay *: @pemit %# = switch(0, not(hasattr(me, turn)), {There is already a Mancala game in progress.[setq(0,#-1)]}, not(strmatch(conn(%#), -1)), {You're not special enough to do that.[setq(0,#-1)]}, not(or(strmatch(%0,me), strmatch(%#, setr(2, pmatch(%0))))), {You can't play against yourself![setq(0,#-1)]}, and(member(lcon(here), %q2), not(strmatch(conn(%q2), -1))), {I don't see that player here.[setq(0,#-1)]}, setq(0,me)); @remit loc(%q0) = %n starts a game of Mancala with [name(%q2)]. Type 'mcwatch' to watch.; &player_0 %q0=%#; &player_1 %q0=%q2; &watching %q0=%# %q2; &turn %q0=rand(2); @pemit/list get(%q0/watching) = The [name(me)] is currently set up for variation [v(variation)], [v(vdesc)].%r[name(v(player_[v(turn)]))] will go first.; @tr %q0/next_turn=v(turn)
@QUEUE Mancala Game Code=
@set Mancala Game Code/QUEUE=no_inherit no_clone wizard
&RESET_CMD Mancala Game Code=$mcreset: @pemit %# = switch(0, hasattr(me,turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)],%#), switch(conn(v(player_0))[conn(v(player_1))], -1-1, setq(0,me), {At least one of the players is still connected.[setq(0,#-1)]}), setq(0,me)); @remit loc(%q0) = %n resets the Mancala game.; @halt %q0 = {@tr [ifelse(or(gt(words(v(pieces_00)),24), gt(words(v(pieces_10)),24)), setq(0,#-1)me, #-1)]/game_over=sign(sub(words(v(pieces_00)), words(v(pieces_10)))); @tr %q0/initpieces}
&RULES_CMD Mancala Game Code=$mcrules: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, Mancala Variation [v(variation)] Rules)] [ansi(hm, repeat(-,40))]%r[ansi(c, u(rules))]%r[ansi(hm, repeat(-,78))]
&RULES_CMD2 Mancala Game Code=$mcrules *: @pemit %# = switch(#-1, setr(1, locate(me, Mancala Variation %0, iX)), {That variation of Mancala rules doesn't seem to exist.}, {[ansi(hm, repeat(-,11))] [ansi(hc, [name(%q1)] Rules)] [ansi(hm, repeat(-,40))]%r[ansi(c, u(%q1/rules))]%r[ansi(hm, repeat(-,78))]})
&SHOW_RECORD Mancala Game Code=%r[ansi(hc, rjust(ifelse(setr(0, member(v(hiscorers),%0)), %q0, --), 2).)] [ansi(hw, ljust(left(name(%0),28),28))] [ansi(c, [rjust(last(setr(0, v(record_%0))), 7)][rjust(extract(%q0,2,1), 12)][rjust(first(%q0), 12)]%%)]
&TOP_ALL_CMD Mancala Game Code=$mctop/all: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, All Mancala Players With 5 Games Or More)] [ansi(hm, repeat(-,16))]%r [ansi(hc, #%b%b[ljust(Player,28)] Games Played [center(Wins,11)] Percentage)]%r[ansi(hm, repeat(-,69))][ansi(c, map(me/show_record, v(hiscorers)))]%r[ansi(hm, repeat(-,69))]
&TOP_CMD Mancala Game Code=$mctop: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, Top Mancala Players)] [ansi(hm, repeat(-,37))]%r [ansi(hc, #%b%b[ljust(Player,28)] Games Played [center(Wins,11)] Percentage)]%r[ansi(hm, repeat(-,69))][ansi(c, map(me/show_record, extract(v(hiscorers),1,10)))]%r[ansi(hm, repeat(-,69))]
&UNDO_CMD Mancala Game Code=$mcundo: @pemit %# = switch(0, hasattr(me, turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)], %#), {You're not playing this game.[setq(0,#-1)]}, hasattr(me, undo_info), {There is no undo information available.[setq(0,#-1)]}, strmatch(%#, v(player_[last(v(undo_info),=)])), {The last move isn't yours to undo.[setq(0,#-1)]}, or(not(hasattr(me, busy)), strmatch(%#, v(player_[v(turn)]))), {Sorry, the next player has already moved.[setq(0,#-1)]}, setq(0,me)); @pemit/list get(%q0/watching) = %n takes back %p last move.; @halt %q0 = {@tr %q0/undo_info; @tr %q0/next_turn=last(v(undo_info),=); &undo_info %q0; &busy %q0=undoing a move;}
&UPDATE_RECORD Mancala Game Code=[round(mul(100, fdiv(setr(2, add(extract(%0,2,1), %1)), setr(3, add(1, last(%0))))),0)] %q2 %q3
@USE Mancala Game Code=[ansi(hm, repeat(-,9))] [ansi(hc, Mancala Commands)] [ansi(hm, repeat(-,43))]%r [ansi(hc, ljust(mcvar,26))] [ansi(c, show the current variation of Mancala)]%r [ansi(hc, ljust(mcvars,26))] [ansi(c, list the supported variations)]%r [ansi(hc, ljust(mcvar <var>,26))] [ansi(c, select a new variation of the rules)]%r [ansi(hc, ljust(mcrules,26))] [ansi(c, show full rules of the current variation)]%r [ansi(hc, ljust(mcrules <var>,26))] [ansi(c, show a specified variation of the rules)]%r%r [ansi(hc, ljust(mcplay <player>,26))] [ansi(c, start a game with <player>)]%r [ansi(hc, ljust(mcwatch %[on|off%],26))] [ansi(c, start or stop watching a game in progress)]%r [ansi(hc, ljust(mcmove <#>,26))] [ansi(c, move the stones from your <#> bowl)]%r [ansi(hc, ljust(mcundo,26))] [ansi(c, undo the last move if possible)]%r%r [ansi(hc, ljust(mcforfeit,26))] [ansi(c, give up and let the other player win)]%r [ansi(hc, ljust(mcreset,26))] [ansi(c, reset the game %(records a win if obvious%))]%r [ansi(hc, ljust(mctop%[/all%],26))] [ansi(c, display top 10 %(or all%) scorers)]%r [ansi(hc, ljust(mccredits,26))] [ansi(c, show the credits for this code)]%r [ansi(hc, ljust(mcnuggets,26))] [ansi(c, order some food)]%r[ansi(hm, repeat(-,70))]
@set Mancala Game Code/USE=no_command
&VARS_CMD Mancala Game Code=$mcvars: @pemit %# = [ansi(hm, repeat(-,11))] [ansi(hc, Supported Mancala Variations)] [ansi(hm, repeat(-,13))] [ansi(hw,*)] [ansi(hc, = current)] [ansi(hm, repeat(-,11))][iter(sort(iter(filter(owned_filter, lcon(me)), get(##/variation))), %r [switch(##, v(variation), ansi(hw,*), %b)] [ansi(hc,##.)] [ansi(c, capstr(get(locate(me, Mancala Variation ##, iX)/vdesc)))])]%r[ansi(hm, repeat(-,78))]
&VAR_CMD Mancala Game Code=$mcvar:@pemit %#=The [name(me)] is currently set up for variation [v(variation)], [v(vdesc)].
&VAR_CMD2 Mancala Game Code=$mcvar *: @pemit %# = switch(0, not(hasattr(me, turn)), {You can't change the rules in the middle of a game![setq(0,#-1)]}, not(strmatch(setr(1, locate(me, Variation %0, iX)), #-1)), {That variation of Mancala rules doesn't seem to exist.[setq(0,#-1)]}, not(strmatch(%0, v(variation))), {That's already the current variation.[setq(0,#-1)]}, setq(0,me)); @parent %q0=%q1; @remit loc(%q0) = %n changes the Mancala rules to variation [v(variation)], [v(vdesc)].
&WATCH_CMD Mancala Game Code=$mcwatch*: @switch/first %0 = %boff, {@pemit %# = switch(0, hasattr(me, turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(watching), %#), {You're not watching the Mancala game.[setq(0,#-1)]}, not(member(v(player_0) [v(player_1)], %#)), {You're still playing! Use mcreset to quit.[setq(0,#-1)]}, {You stop watching the Mancala game.[setq(0,me)][setq(1,%#)]}); @remit loc(%q1) = %n stops watching the Mancala game.; &watching %q0=setdiff(v(watching), %#)}, {@pemit %# = switch(0, hasattr(me, turn), {There is no Mancala game in progress.[setq(0,#-1)]}, not(member(v(watching), %#)), {You're already watching this game.[setq(0,#-1)]}, {You are now watching the Mancala game. Type 'mcwatch off' to stop watching.[setq(0,me)][setq(1,%#)]}); @remit loc(%q1) = %n watches the Mancala game.; &watching %q0=v(watching) %#}
&WIPE_BOARD Mancala Game Code=@pemit/list v(watching) = [name(v(player_%0))]'s side of the board is empty, so [name(v(player_[not(%0)]))] collects all of [poss(v(player_[not(%0)]))] remaining pieces into [poss(v(player_[not(%0)]))] mancala.; &pieces_[not(%0)]0 me=iter(v(move_order_[not(%0)]), v(pieces_##)); @dolist lnum(6) = {@wipe me/pieces_?#@}; @wait 0 = {@pemit/list v(watching) = u(boardmap)}; @tr me/game_over=sign(sub(words(v(pieces_00)), words(v(pieces_10))))
@create Mancala Variation 1
@parent Mancala Variation 1=Mancala Game Code
@lock/Basic Mancala Variation 1==me
@lset Mancala Variation 1/Basic=no_inherit
@set Mancala Variation 1 = NO_COMMAND
&RULES Mancala Variation 1=Each player has six numbered bowls and one larger bowl, called the mancala, adjacent to her 1-bowl. On each turn, a player takes the stones out of one of her numbered bowls (mcmove #) and places them one by one into the other bowls, moving clockwise and including her own mancala but not the opponent's. If she places the last stone in her own mancala, she gets to move again. If the last stone ends up in an empty one of the player's own numbered bowls, and the opponent's bowl across from it contains any stones, the player moves the contents of both bowls to her own mancala. The game ends when either player empties all their numbered bowls. The player with stones left gets to keep them, and the player with more stones at that point wins. A tie counts as a win for both players.
&VARIATION Mancala Variation 1=1
&VDESC Mancala Variation 1=the original rules (player with stones left keeps them)
@create Mancala Variation 2
@parent Mancala Variation 2=Mancala Game Code
@lock/Basic Mancala Variation 2==me
@lset Mancala Variation 2/Basic=no_inherit
@set Mancala Variation 2 = NO_COMMAND
&RULES Mancala Variation 2=This is the same as the original rules (mcrules 1) except for what happens when either side of the board is cleared. In this variation, the player with the empty side gets all the remaining pieces. As in the original, this happens regardless of which player's move causes the bowls to be empty.
&VARIATION Mancala Variation 2=2
&VDESC Mancala Variation 2=Rak & Kar's rules (player with no stones left gets the rest of them)
&WIPE_BOARD Mancala Variation 2=@pemit/list v(watching) = [name(v(player_%0))]'s side of the board is empty, so [subj(v(player_%0))] collects all of [name(v(player_[not(%0)]))]'s remaining pieces into [poss(v(player_%0))] mancala.; &pieces_%00 me=iter(v(move_order_%0), v(pieces_##)); @dolist lnum(6) = {@wipe me/pieces_?#@}; @wait 0 = {@pemit/list v(watching) = u(boardmap)}; @tr me/game_over=sign(sub(words(v(pieces_00)), words(v(pieces_10))))
@create Mancala Variation 3
@parent Mancala Variation 3=Mancala Game Code
@lock/Basic Mancala Variation 3==me
@lset Mancala Variation 3/Basic=no_inherit
@set Mancala Variation 3 = NO_COMMAND
&MOVE_ORDER_0 Mancala Variation 3=06 12 04 14 02 16 00 01 15 03 13 05 11
&MOVE_ORDER_1 Mancala Variation 3=16 02 14 04 12 06 10 11 05 13 03 15 01
&RULES Mancala Variation 3=This is the same as the original rules (mcrules 1) except for the order in which stones are placed on each turn. Don't blame me, LITE came up with this. LITE warns that the game gets exceedingly weird. If you move from an even-numbered bowl, you start zigzagging down the board towards your mancala, placing stones in all the even-numbered bowls. Next you place one in your mancala, and then you start using the odd-numbered bowls beginning with the opponent's 6-bowl. If you start on an odd-numbered bowl, you zigzag towards your mancala along the odd-numbered bowls, then start using the even-numbered bowls beginning with your 6-bowl. Notice that it takes more stones to reach your mancala from an odd-numbered bowl. You'll probably have to play this one a couple of times to get the hang of it, I know I will...
&VARIATION Mancala Variation 3=3
&VDESC Mancala Variation 3=alternating sides (drop stones in zigzag instead of clockwise order)
@create Mancala Variation 4
@parent Mancala Variation 4=Mancala Game Code
@lock/Basic Mancala Variation 4==me
@lset Mancala Variation 4/Basic=no_inherit
@set Mancala Variation 4 = NO_COMMAND
&MOVE_ORDER_0 Mancala Variation 4=03 02 01 00 16 15 14 04 05 06 11 12 13
&MOVE_ORDER_1 Mancala Variation 4=13 12 11 10 06 05 04 14 15 16 01 02 03
&RULES Mancala Variation 4=This is the same as the original rules (mcrules 1) except for the order in which stones are placed on each turn. This one is sTiLe's idea. If you move from your 1, 2, or 3-bowl, you begin moving toward your mancala like normal. If you are the player on the top, you circle around the board and cross from your opponent's 4-bowl to yours. You then move backwards along your row, go from your 6 to your opponent's 1-bowl, then cross at their 3-bowl back to yours. The basic movement is that of an infinity symbol (8 on its side), crossing at 4-4 and 3-3.
&VARIATION Mancala Variation 4=4
&VDESC Mancala Variation 4=figure-eight (cross over in middle of board when dropping stones)
@create Mancala Variation 5
@parent Mancala Variation 5=Mancala Game Code
@lock/Basic Mancala Variation 5==me
@lset Mancala Variation 5/Basic=no_inherit
@set Mancala Variation 5 = NO_COMMAND
&FORFEIT_CMD Mancala Variation 5=$mcforfeit: @pemit %# = switch(0, hasattr(me,turn), {There is no Mancala game in progress.[setq(0,#-1)]}, member(v(player_0) [v(player_1)],%#), {You're not playing this game.[setq(0,#-1)]}, setq(0,me)); @remit loc(%q0) = %n forfeits the Mancala game with [name(setdiff(v(player_0) [v(player_1)],%#))].; @tr %q0/game_over=switch(%#, v(player_0), 1, v(player_1), -1)
&GAME_OVER Mancala Variation 5=@remit loc(me) = switch(%0, -1, {[name(v(player_0))] has won the Mancala game with [name(v(player_1))]![setq(0,1)][setq(1,0)]}, 1, {[name(v(player_1))] has won the Mancala game with [name(v(player_0))]![setq(0,0)][setq(1,1)]}, 0, {[name(v(player_0))] and [name(v(player_1))] have tied at Mancala![setq(0,1)][setq(1,1)]}); &record_[v(player_0)] me = u(update_record, v(record_[v(player_0)]), %q0); &record_[v(player_1)] me = u(update_record, v(record_[v(player_1)]), %q1); &hiscorers me = sortby(me/comp_records, filter(me/enough_games, setunion(v(hiscorers), v(player_0) [v(player_1)]))); @pemit/list v(watching) = [ansi(hm, repeat(-,13))] [ansi(hc, Mancala Records)] [ansi(hm, repeat(-,39))]%r [ansi(hc, #%b%b[ljust(Player,28)] Games Played [center(Wins,11)] Percentage)]%r[ansi(hm, repeat(-,69))][ansi(c, map(me/show_record, sortby(me/comp_records, v(player_0) [v(player_1)])))]%r[ansi(hm, repeat(-,69))]; @tr me/initpieces
&RULES Mancala Variation 5=This is the same as Rak & Kar's rules (mcrules 2) except that the player with the fewest stones at the end wins. This is based on variation 2 (player with no stones left gets the rest of them) instead of the original rules to keep the primary strategy from being "run off the board as quickly as possible".
&VARIATION Mancala Variation 5=5
&VDESC Mancala Variation 5=anti-mancala (fewest stones wins)
&WIPE_BOARD Mancala Variation 5=@pemit/list v(watching) = [name(v(player_%0))]'s side of the board is empty, so [subj(v(player_%0))] collects all of [name(v(player_[not(%0)]))]'s remaining pieces into [poss(v(player_%0))] mancala.; &pieces_%00 me=iter(v(move_order_%0), v(pieces_##)); @dolist lnum(6) = {@wipe me/pieces_?#@}; @wait 0 = {@pemit/list v(watching) = u(boardmap)}; @tr me/game_over=sign(sub(words(v(pieces_00)), words(v(pieces_10))))
@create Mancala Variation 6
@parent Mancala Variation 6=Mancala Game Code
@lock/Basic Mancala Variation 6==me
@lset Mancala Variation 6/Basic=no_inherit
@set Mancala Variation 6 = NO_COMMAND
&MOVE_STONES Mancala Variation 6=&undo_info me=iter(v(move_order_0) 10, &pieces_## me=[v(pieces_##)]%;) &turn me=[v(turn)]; think setq(0, v(pieces_%0%1)); &pieces_%0%1 me; @dolist reverse(rest(reverse(setr(1, extract(repeat(v(move_order_%0)%b, 5), inc(member(v(move_order_%0), %0%1)), words(%q0)))))) = {&pieces_## me=v(pieces_##) [extract(%q0,#@,1)]}; &pieces_[setr(1, last(%q1))] me=v(pieces_%q1) [setr(0, last(%q0))]; @wait 0 = {@switch/first 1 = strmatch(lattr(me/pieces_0*), pieces_00), {@tr me/wipe_board=0}, strmatch(lattr(me/pieces_1*), pieces_10), {@tr me/wipe_board=1}, eq(%q1,%00), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into [poss(v(player_%0))] own mancala and gets to move again.; @tr me/next_turn=%0}, and(eq(words(v(pieces_%q1)),1), hasattr(me, pieces_[setr(2, rjust(sub(17,%q1),2,0))])), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into an empty bowl across from [setr(3, words(v(pieces_%q2)))] stone[switch(%q3,1,,s)] and captures [switch(%q3,1,it,them)] into [poss(v(player_%0))] mancala!; &pieces_%00 me=v(pieces_%00) [v(pieces_%q1)] [v(pieces_%q2)]; &pieces_%q1 me; &pieces_%q2 me; @tr me/next_turn=not(%0)}, {@tr me/next_turn=not(%0)}}
&RULES Mancala Variation 6=This is the same as the original rules (mcrules 1) except that players may capture stones by landing in an empty bowl across from an occupied one on either side of the board.
&VARIATION Mancala Variation 6=6
&VDESC Mancala Variation 6=capture anywhere (empty bowls on opponent's side work too)
@create Mancala Variation 7
@parent Mancala Variation 7=Mancala Game Code
@lock/Basic Mancala Variation 7==me
@lset Mancala Variation 7/Basic=no_inherit
@set Mancala Variation 7 = NO_COMMAND
&MOVE_STONES Mancala Variation 7=&undo_info me=iter(v(move_order_0) 10, &pieces_## me=[v(pieces_##)]%;) &turn me=[v(turn)]; think setq(0, v(pieces_%0%1)); &pieces_%0%1 me; @dolist reverse(rest(reverse(setr(1, extract(repeat(v(move_order_%0)%b, 5), inc(member(v(move_order_%0), %0%1)), words(%q0)))))) = {&pieces_## me=v(pieces_##) [extract(%q0,#@,1)]}; &pieces_[setr(1, last(%q1))] me=v(pieces_%q1) [setr(0, last(%q0))]; @wait 0 = {@switch/first 1 = strmatch(lattr(me/pieces_0*), pieces_00), {@tr me/wipe_board=0}, strmatch(lattr(me/pieces_1*), pieces_10), {@tr me/wipe_board=1}, eq(%q1,%00), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into [poss(v(player_%0))] own mancala and gets to move again.; @tr me/next_turn=%0}, and(eq(%0, div(%q1,10)), eq(words(v(pieces_%q1)),1), hasattr(me, pieces_[setr(2, rjust(sub(17,%q1),2,0))])), {@pemit/list v(watching) = [name(v(player_%0))] drops [poss(v(player_%0))] last stone into an empty bowl across from [setr(3, words(v(pieces_%q2)))] of [name(v(player_[not(%0)]))]'s stones and captures [switch(%q3,1,it,them)] into [poss(v(player_%0))] [after(%q1,%0)]-bowl!; &pieces_%q1 me=v(pieces_%q1) [v(pieces_%q2)]; &pieces_%q2 me; @tr me/next_turn=not(%0)}, {@tr me/next_turn=not(%0)}}
&RULES Mancala Variation 7=This is the same as the original rules (mcrules 1) except that when a player makes a capture by landing in an empty bowl on her own side across from some of the opponent's stones, she moves the captured stones into the bowl where she landed, rather than into her mancala.
&VARIATION Mancala Variation 7=7
&VDESC Mancala Variation 7=capture across (move stones across the board when you capture)
@parent Mancala Game Code=Mancala ASCII Art
@create Mancala
@lock Mancala==#0
@set Mancala=!NO_COMMAND
@parent Mancala=Mancala Game Code
give Mancala=Mancala Game Code
give Mancala=Mancala ASCII Art
give Mancala=Mancala Variation 1
give Mancala=Mancala Variation 2
give Mancala=Mancala Variation 3
give Mancala=Mancala Variation 4
give Mancala=Mancala Variation 5
give Mancala=Mancala Variation 6
give Mancala=Mancala Variation 7
drop Mancala