home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 70
/
070.d81
/
b.mancala
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
9KB
|
292 lines
100 rem@ 02
110 gosub2570:clr:poke2043,0
120 diml(12),tr(5),bo(5),nu(5),a(12),n%(5),x$(12),la$(12)
130 restore:n=0
140 gosub1950:gosub2220
150 forx=1to12
160 f=1
170 readl(x)
180 gosub850
190 next
200 forx=1to12:readx$(x):la$(x)=" "+x$(x)+" ":next
210 f=0
220 print"":printtab(7)"[159]change default board? ([153]y/[153]n)"
230 geta$:ifa$<>"n"anda$<>"y"anda$<>"q"then230
240 ifa$="q"thengosub2920:gosub2860:poke198,0:goto220
250 ifa$="n"thengosub810:goto290
260 f=1:gosub2220:gosub2470
270 forx=1to12:gosub850:next
280 f=0:goto220
290 print"[159]play against computer or human? ([153]c/[153]h)"
300 getch$:ifch$<>"c"andch$<>"h"andch$<>"q"then300
310 ifch$="q"thengosub2920:gosub2860:poke198,0:goto290
320 gosub810:ifch$="h"thench$="2":goto380
330 ifch$="c"thench$="1"
340 print""tab(5)"[159] difficulty level? ([153]0-[153]9) ";
350 getbo$:ifbo$<"0"orbo$>"9"andbo$<>"q"then350
360 ifbo$="q"thengosub2920:gosub2860:poke198,0:goto340
370 gosub810:printtab(10)"[159]computer is player 1":gosub1250:gosub810
380 print""tab(5)"[159] starting player? ([153]1/[153]2) "
390 geta$:ifa$<>"1"anda$<>"2"anda$<>"q"then390
400 ifa$="q"thengosub2920:gosub2860:poke198,0:goto380
410 pn=val(a$):ifpn<1orpn>2then380
420 goto430
430 ifpn=1thenpt=12
440 ifpn=1andch$="2"then480
450 ifpn=1andch$="1"thengosub810:print""tab(12)"computer thinking";:gosub1400
460 ifpn=1andch$="1"then600
470 ifpn=2thenpt=6
480 gosub810
490 gosub2860
500 print""tab(5)"[159]player"pn"[159]starting pocket? ":ifpn=2then560
510 ifpn=1thenprint""tab(31)"([153]0-[153]4)"
520 getx$:ifx$<>"q"thenifx$<"0"orx$>"4"then520
530 ifx$="q"thengosub2920:gosub2860:poke198,0:goto500
540 ifpn=1thenx=val(x$)+1:ifx<1orx>5then490
550 goto600
560 ifpn=2thenprint""tab(31)"[153]5-9"
570 getx$:ifx$<>"q"thenifx$<"5"orx$>"9"then570
580 ifx$="q"thengosub2920:gosub2860:poke198,0:goto500
590 ifpn=2thenx=val(x$)+2:ifx<7orx>11then480
600 ifl(x)=0thengosub810:print""tab(10)"pocket "x$(x)" empty":gosub1250:goto790
610 gosub810:print""tab(9)"[159]starting location is [158]"x$(x);:gosub2810
620 tv=l(x)
630 ifpn=1andx=6then430
640 ifpn=2andx=12then480
650 l(x)=0
660 n=0:gosub850
670 forn=1totv
680 ifx+n=ptthenx=x+1
690 ifx+n>12thenx=x-12:goto690
700 l(x+n)=l(x+n)+1
710 gosub850
720 nextn
730 x=x+tv
740 ifl(6)>29thencl=14:hi=60:pn=1:goto1800
750 ifl(12)>29thencl=6:hi=70:pn=2:goto1800
760 ifl(x)<>1then610
770 ifpn=1andx=6then420
780 ifpn=2andx=12then420
790 ifpn=1thenpn=2:goto420
800 ifpn=2thenpn=1:goto420
810 print"";
820 print" "
830 print" ";
840 return
850 ifx+n<6thenc=6*(x+n):r=3
860 ifx+n=6thenc=35:r=8
870 ifx+n>6andx+n<12thenc=36-((x+n-6)*6):r=14
880 ifx+n=12thenc=1:r=8
890 print"";:printtab(c);
900 forj=1tor:print"";:next
910 v=l(x+n)
920 ifv=othen1070
930 gosub1920
940 forz=1tov
950 ifz=9thenc=c+1:gosub1210
960 ifz=17thenc=c+1:gosub1210
970 ifz=25thenc=c+1:gosub1210
980 ifv=0thenv=z:goto1050
990 iff=1thenprint" ";:gosub1920:print"[146][157][209][157]";:goto1040
1000 ifz<vthenprint"";
1010 ifz=vthenprint" ";:gosub1920:print"[146][157][209][157]";
1020 ifx+n=6andpn=1thencl=7:hi=40:gosub1320:goto1050
1030 ifx+n=12andpn=2thencl=10:hi=50:gosub1320:goto1050
1040 ifz=vthengosub1260
1050 next
1060 ifv>1then1140
1070 forz=v+1totv+1
1080 print" [157]";
1090 ifz=9thenc=c+1:gosub1180
1100 ifz=17thenc=c+1:gosub1180
1110 ifz=25thenc=c+1:gosub1180
1120 ifz=tv+1then1130
1130 next
1140 print"";
1150 return
1160 data6,6,6,6,6,0,6,6,6,6,6,0
1170 data"0","1","2","3","4","t1","5","6","7","8","9","t2"
1180 print"";:printtab(c);
1190 forj=1tor:print"";:next
1200 return
1210 printtab(c);
1220 forj=1to8:print"[145]";:next
1230 ifx+n<6thenprint"";
1240 return
1250 ford=1to1500:next:return
1260 s=54272
1270 pokes+24,10:pokes+5,0:pokes+6,0:pokes,90:pokes+1,170
1280 pokes+2,50:pokes+3,50:pokes+4,129
1290 fort=1to5
1300 pokes+4,128
1310 return
1320 ifbkthen poke53280,cl
1330 s=54272
1340 pokes+24,15:pokes+5,40:pokes+6,250:pokes,100:pokes+1,hi
1350 pokes+2,50:pokes+3,50:pokes+4,65
1360 fort=1to5
1370 pokes+4,64:
1380 poke53280,11
1390 return
1400 dn=pn
1410 ifdn=1thendt=12
1420 ifdn=2thendt=6
1430 forq=1to5:bo(q)=0:ifdn=2thendn=1:dt=12
1440 forb=1to12:a(b)=l(b):next
1450 b=q
1460 vb=a(b):ifa(b)=0thenbo(q)=-1:goto1620
1470 a(b)=a(b)-vb
1480 ifdn=1andb=6thena(b)=a(b)+vb:goto1610
1490 ifdn=2andb=12thena(b)=a(b)+vb:goto1610
1500 n1=0
1510 forn1=1tovb
1520 ifb+n1=dtthenb=b+1
1530 ifb+n1>12thenb=b-12:goto1530
1540 a(b+n1)=a(b+n1)+1
1550 next
1560 b=b+vb
1570 ifa(b)<>1then1460
1580 ifdn=1andb=6then1610
1590 ifdn=1thendn=2:goto1620
1600 ifdn=2thendn=1
1610 ifdn=1thenbo(q)=val(bo$)-.5:goto1620
1620 tr(q)=a(6)+bo(q)
1630 cl=1:hi=100:gosub1320:next
1640 forq=1to5
1650 next
1660 forq=1to5:nu(q)=tr(q):next
1670 forp=1to4
1680 forw=1to4
1690 ho=nu(w)
1700 ifnu(w+1)<nu(w)thennu(w)=nu(w+1):nu(w+1)=ho
1710 next
1720 iff=0thenp=5
1730 next
1740 forq=1to5
1750 ifnu(5)=tr(q)thenx=q
1760 next
1770 print"";
1780 forq=1to5:tr(q)=0:bo(q)=0:next
1790 return
1800 poke53281,cl:print""tab(5)" "
1810 print""tab(5)"[159] player"pn"wins! "
1820 rem@ 01
1830 forcl=1to20:forhi=60to160step20:poke53281,cl+1:gosub1320:next:next
1840 rem@ 02
1850 print:poke53281,0
1860 ti$="000000":bk=1
1870 ifti<150then1870
1880 print""tab(5)"[159] play again? ([158]y/[158]n) ";
1890 geta$:ifa$=""then1890
1900 ifa$="y"thenrun
1910 goto2950
1920 ifx+n<7thenpoke646,7
1930 ifx+n>6thenpoke646,10
1940 return
1950 poke53280,0:poke53281,0
1960 print"[147] [176][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][174]"
1970 print" [221] [221]"
1980 print" [221][158] [211]trategy [221]"
1990 print" [221][156] [163][163][163][163][163][163][163][163][163][163][163][163] [221]"
2000 print" [221][159] [208]layer 1 takes all marbles from [221]"
2010 print" [221][159]one pocket on his side of the board.[221]"
2020 print" [221][159][205]oving clockwise, the player drops a[221]"
2030 print" [221][159]marble in each pocket, except in his[221]"
2040 print" [221][159]opponent's treasury. [193]fter dropping[221]"
2050 print" [221][159]the last marble, player 1 takes the [221]"
2060 print" [221][159]marbles in that pocket and continues[221]"
2070 print" [221][159]on until the last marble in hand is [221]"
2080 print" [221][159]dropped into an empty pocket. [221]"
2085 print" [221][159] [221]"
2090 print" [221][159] [193]t this point player 2 moves on [221]"
2100 print" [221][159]his side. [201]f a player's last marble[221]"
2110 print" [221][159]is dropped into his treasury,he may [221]"
2120 print" [221][159]continue from any pocket on his side[221]"
2130 print" [221][159]of the board. [212]he player with the [221]"
2140 print" [221][159]most marbles in his treasury wins. [221]"
2150 print" [221] [221]"
2160 print" [173][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][192][189]";
2170 print" [200]it any key to continue ";
2180 geta$:ifa$=""then2180
2190 ifa$="q"thengosub2920
2200 printchr$(142);
2210 return
2220 print"[147]";:poke53280,11:poke53281,0
2230 print"[146][147]";
2240 print"[152] [155] {$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}{$60}> [154][146] ";
2250 print" [155] [146] [151] [152] [155][146] [151] [152] [155][146] [151] [152] [155][146] [151] [152] [155][146] [154][146] ";
2260 print" [155] [146] [151] [152] [155][146] [151] [152] [155][146] [151] [152] [155][146] [151] [152] [155][146] [154][146] ";
2270 print" [155] [146] [151] [152] [155][146] [151] [152] [155][146] [151] [152] [155][146] [151] [152] [155][146] [146] [154] ";
2280 print" [150]t2[154] [155] [146] [151] [152] [15