home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Rockford Magazine
/
Rockford_Magazine_022_19xx_-_de_Disk_2_of_4_Side_B.d64
/
kalah_commo_rof
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2023-02-26
|
12KB
|
410 lines
1 goto910
2 print"X[169][141][169][141]x{$60} [234][255][169][255][133][145]l4[234]X[169]1[141][169][234][141]x{$60}
3 [153]"Xstepginputstopstepinputonx{$60} (NULL)(NULL)step(NULL)inputlistlx(NULL)Xstepuinputstopstep(NULL)inputonx{$60}
4 print"XHHH[170]H[168]HHHHHHH[152]h[138]hx{$60}
5 [153]"HHHHHHH{$60}
6 print"[160][255][200][132][251][169][216][133][252] [241][183][138][162][160][255][200][145][251][136][208][251][230][252][202][208][246]{$60}
7 [153]"newclose(NULL)left$>(NULL)on(NULL)let(NULL)(NULL)(NULL)(NULL)(NULL)(NULL)mid$(NULL)(NULL){$60}
35 ifuw=0thensysuu,15
40 pokeuc,0:pokeun,0:ur$="":ui$="":iful=0thenul=39
45 getui$:ifui$=""then45
50 ua=asc(ui$):ur=len(ur$):ifua=13andur>0thenpokeuc,1:print" [157]";:goto70
55 ifua=20thenon-(ur=0)goto45:ur$=left$(ur$,ur-1):print"[157] [157][157]";:goto45
60 ifur=ulthen45
65 gosub95:ur$=ur$+ui$:printui$;:goto45
70 ifur$=ux$thenprint"[157] ";:goto145
75 forui=urto1step-1:ifmid$(ur$,ui,1)=" "thennext
80 ur$=left$(ur$,ui):print:return
95 iflen(us$)=0then110
100 forui=1tolen(us$):ifui$<>mid$(us$,ui,1)thennext:ui$=""
105 return
110 ifua=46thenreturn
115 ifua=32andur<>0thenreturn
120 ifua>47andua<58thenreturn
125 ifua>64andua<91thenreturn
130 ifua<193orua>218thenui$="":return
135 ifpeek(ut)=uu%thenui$=chr$(ua-128)
140 return
145 gosub170:poke251,0:poke252,us/256:poke253,0:poke254,uf:sysuv
150 uz=1:uv%=peek(ut):goto300
155 uz=0:us$=uj$:ug$=uk$:ut$=ul$:up=uj:ul=uk:print"[147]";:ifuw=0thenpokeuy,6:pokeux,14
160 pokeut,uv%:poke251,0:poke252,uf:poke253,0:poke254,us/256:sysuv:ifuw=0thensysuu,15
165 pokeu1,u1%:pokeu2,u2%:pokeu3,u3%-1:pokeu4,u4%:goto35
170 u1%=peek(u1):u2%=peek(u2):u3%=peek(u3):u4%=peek(u4)
175 uj$=us$:uk$=ug$:ul$=ut$:uj=up:uk=ul:return
300 print"[147]":pokeut,uu%:ifuw=0thenpokeuy,12:pokeux,6
305 print" m e n u"
310 print" --------------------------------"
315 print" 1. begin kalah"
320 print" 2. instructions"
325 print" 3. documentation "
330 print" 4. quit"
335 print" --------------------------------"
340 print" press a number key (1-4) ";
345 ul=1:us$="1234"
347 gosub35:us$=""
350 onval(ur$)gosub1000,400,500,390
355 goto300
370 ifuz=1thensysup%:goto155
375 return
390 sysue:print"[154][147]":ifuw=0thenpokeuy,6:pokeux,14:sysuu,14
395 clr:end
400 print"[147]":pokeut,ul%:ifuw=0thenpokeuy,11:pokeux,12
405 ut$=" [203]alah":uh=1:up=0:ug$="[201]nstructions":gosub850
412 print" [201]n this game you start with a certain"
413 print" number of beans in each pit. [212]he"
414 print" object of the game is to put as many"
416 print" beans as possible into your collection"
418 print" pit. [217]our collection pit is the one"
420 print" on the right. [193]ll the pits on the"
422 print" the bottom row are yours, the others"
424 print" are the computer's."
425 uh=1:gosub835:gosub850
426 print" [197]ach time you pass your collection"
428 print" pit or stop on it, you gain one"
429 print" point. [212]he best strategy is to try"
431 print" to stop right on your collection":print" pit."
432 print" [207]nce you get better, you may"
433 print" practice capturing the computer's"
434 print" beans. [212]his can be done only when"
436 print" the pit you wish to capture has two"
438 print" or less beans in it."
439 uh=1:gosub 835:gosub 850
440 print" [212]he actual capturing is done when"
442 print" you move your beans so they land on"
444 print" the computer's side of the board."
445 print" [212][200][201][211][160][208][201][212][160][205][213][211][212][160][200][193][214][197][160][212][215][207][160][207][210][160][204][197][211][211][160][194][197][193][206][211]"
446 print" [201][206][160][201][212][160][207][210] [207][210][160][217][207][213][210][160][194][197][193][206][211][160][215][201][204][204][160][194][197][195][207][205][197]"
448 print" [212][200][197] [195][207][205][208][213][212][197][210]'[211] [208][207][211][211][197][211][211][201][207][206]."
455 uh=1:gosub835:gosub850
460 print" [206]ote:
475 [153]" right$f at any time you wish to return"
480 [153]" to the (NULL)val(NULL)(NULL) press 'h' (NULL)val(NULL)(NULL)(NULL)(NULL)."
485 [141]835
490 [139]uz[178]1[167][158]up%:[137]155
495 [142]
500 [153]"load":[151]ut,ul%:[139]uw[178]0[167][151]uy,2:[151]ux,10
501 ut$[178]" (NULL)alah":uh[178]1:up[178]0:ug$[178]"str$ocumentation":[141]850
502 [153]" (NULL)o the best of our knowledge,"
503 [153]" this program is in the public"
504 [153]" domain. right$f this is not true,"
505 [153]" please contact:"
506 [153]" len(NULL)(NULL)(NULL)(NULL)str$(NULL)(NULL)valclosepeek(NULL)(NULL)right$(NULL)val(NULL)(NULL)close(NULL)atnlenleft$right$(NULL)val(NULL)"
507 [153]" 3370 (NULL)harmacy atnve.
508 print" [193]gincourt, [207]ntario"
509 print" [195]anada, [205]1[215] 2[203]4"
510 print" (416) 499-4292"
511 uh=1:gosub835:gosub850
512 print" [208]rogram [206]ame: [203]alah
513 [153]" (NULL)ritten by : peekill ascinzer"
514 [153]" (NULL)evised by : (NULL)eter (NULL)agsdale"
515 [153]" (NULL)his program will run on any
516 print" [194][193][211][201][195][160]2.0 [208][197][212] [195]omputer
517 [153]" peekatn(NULL)right$len 4.0 (NULL)val(NULL)closelenomputer
518 print" 8032 [195][194][205] [195]omputer
519 [153]" lenommodore 64 lenomputer
585 gosub835
590 ifuz=1thensysup%:goto155
595 return
700 printuc$"[147]before running this program on an 8032
705 [153]" load the 'cbm 4032' program":[128]
800 [153]"load";:[151]ut,uu%:[139]uw[178]0[167][151]uy,1:[151]ux,14
801 [129]i[178]1[164]38:[153]" wait";:[130]
802 [129]i[178]1[164]22:[153]"cmd wait";:[130]
803 [129]i[178]1[164]37:[153]"cmdcmd wait";:[130]
804 [129]i[178]1[164]22:[153]"oncmd wait";:[130]
805 [153]"step wait
806 print" [146] [146][169]
807 [153]" wait tab((NULL)wait o m m o d o r e
808 print"[223] [146]
809 [153]"educational
810 print"software
811 [153]"1983
812 printleft$(ud$,24);"press space bar or wait[146]"uc$:ui=0
813 getui$:ifui$<>" "thenui=ui+1:ifui<250then813
814 goto300
835 pokeun,0:printleft$(ud$,24);"press space bar to continue[146]"
840 getui$:ifui$<>" "then840
845 return
850 up=up+1:print"[147]"left$(ut$+up$,21);right$(up$+ug$+str$(up),18)
855 print" --------------------------------------"
860 ifuh=0thenprintleft$(ud$,24);left$(up$,7);"help - press h <return>"
865 uh=0:print"":return
875 printleft$(ud$,24);" one moment please... ":return
900 ux$="h":us=32768:u1=196:u2=197:u3=198:u4=216:uc=167:ub=1024:ud=1084:ue=1105
901 ut=59468:uu%=12:ul%=14:up%=1158:un=158:poke50003,0:uw=peek(50003):uf=peek(53)
902 ifuw=0thenus=1024:u1=209:u2=210:u3=211:u4=214:uc=204:ub=2048:ux=53280:ud=2064
903 ifuw=0thenut=53272:uu%=21:ul%=23:up%=2151:un=198:uy=53281:uu=2199:ue=2087
904 uc$=chr$(155):uv=1214:ifuw=0thenuf=196:uv=2238
905 ud$="":up$=" "
907 dim board%(3,14),l1%(6),l2%(6,6), pit%(14,2),i(3),m%(6)
909 return
910 gosub900:print"[147]":print"[160]":rem shifted space
915 ifpeek(us+40)<>96then700
920 if(fre(0)-(sgn(fre(0))<0)*65536)>500then935
925 printuc$"[147]this machine does not have enough"
930 print"memory to run this program !":sysue:end
935 print"[147]"uc$:ifuw=0then965
940 ifuf=60oruf=108oruf=124then950
945 poke52,0:poke53,uf-4:clr:gosub900
950 ifuw=160thenpoke1103,88:poke1104,228:poke1107,85:poke1111,228:goto965
955 ifuw<>1thenprint"[147]this pgm will not work on this machine!":sysue:end
960 poke1103,49:poke1104,230:poke1107,46:poke1111,230:goto965
965 sysud
970 gosub800:goto300
1000 ifuz=1thensysup%:sysup%:uz=0
1001 print"[147]"uc$;:restore:ifuw=0thenpokeuy,9:pokeux,5
1005 ut$=" kalah":up=0
1030 rem
1040 rem pit location data
1050 data 30,11,25,11,20,11,15,11,10,11,5,11,1,15,5,17,10,17,15,17,20,17
1060 data 25,17,30,17,35,15
1070 for i= 1 to 14
1080 read pit%(i,1):read pit%(i,2):next
1090 rem---main calling routine----
1100 gosub 1250:rem initialize
1110 gosub 1410:rem instructions
1120 gosub 1650:rem draw board
1130 if p$="c" then 1190
1140 gosub 1950:rem get human's move
1150 if a$="r" then gosub 3120:goto 1230
1160 if a$="t" then gosub 3210:goto 1140
1170 l=0:gosub 2090:rem display move
1180 if w$<>"n" then 1220
1190 gosub 2680:rem find computer move
1200 l=0:gosub 2090:rem display move
1210 if w$="n" then 1140
1220 gosub 3120:rem win message
1230 if ur$="y" then 1100
1240 print"[147]":return
1250 rem---initialize---
1260 m=rnd(-ti)
1270 p$="":w$="":nm=6
1280 blank$=" "
1290 beans$="[209][209][209][209][157][157][157][157][209][209][209][209][157][157][157][157][209][209][209][209]"
1300 erase$=" [157][157][157][157] [157][157][157][157] "
1310 inf=30000:l=0
1320 bo%(0,7)=0:bo%(0,14)=0
1330 return
1340 rem----move cursor to x,y---
1350 poke u4,y-1:print:printtab(x);:return
1410 rem---instructions----
1420 poke ut,uu%
1460 rem---input # of beans & level--
1465 up=0:ug$=" intro[146]":gosub850
1470 print" how many beans per pit[160](3[160]makes a"
1471 print" good beginner's game) ? [157][157]";
1480 ul=2:us$="h0123456789"
1490 gosub 35
1500 if val(ur$)>15 then print"[145][145][145][145]":goto1470
1540 nb=val(ur$)
1550 print" how hard do you want the game to be?"
1560 printtab(5)"0 = random play
1570 [153][163]5)"1 = beginner"
1580 [153][163]5)"2 = intermediate":[153][163]5)"3 = advanced"
1585 [153][163]5)"option> ";
1590 ul[178]1:us$[178]"h0123"
1600 [141]35
1610 level[178][197](ur$)
1620 [153]:[153]" do you want to go first? ";:ul[178]1:us$[178]"ynh"
1630 [141] 35:[139] ur$[178]"n" [167] p$[178]"c"
1640 [151] ut,uu%:[142]
1650 [143]---draw board----
1660 [129] i[178]1 [164] 6
1670 bo%(0,i)[178]nb:bo%(0,i[170]7)[178]nb
1680 [130] i
1690 [143]---board w/o beans---
1700 up[178]level[171]1:ug$[178]"computer levelwait":[141]850
1710 [153]" i'm playing at level"level""
1720 [153]" stepclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclose(NULL)"
1730 [153]"stepcloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclosecloseclose closecloseclosecloseclosecloseclosecloseclose(NULL)"
1740 [153]" waitstep (NULL) waitstep (NULL) waitstep (NULL) waitstepcloseclose(NULL) waitstep (NULL) waitstepcloseclose(NULL) waitstep (NULL) waitstep (NULL) "
1750 [129] i[178] 1 [164] 3
1760 [153]" wait wait wait wait wait wait wait wait "
1770 [130] i
1780 [153]" wait (NULL)wait step (NULL)wait step (NULL)wait stepclose(NULL)wait stepclose(NULL)wait step (NULL)wait step wait "
1790 [153]" wait wait "
1800 [153]" wait waitstep (NULL) waitstep (NULL) waitstepcloseclose(NULL) waitstep (NULL) waitstepcloseclose(NULL) waitstep (NULL) wait "
1810 [129] i[178] 1 [164] 3
1820 [153]" wait wait wait wait wait wait wait wait "
1830 [130] i
1840 [153]" (NULL)wait step (NULL)wait step (NULL)wait step (NULL)wait stepclose(NULL)wait stepclose(NULL)wait step (NULL)wait step (NULL)wait step "
1850 [153]"(NULL) 1 2 3 4 5 6 waitstep"
1860 [153]" (NULL) waitstep"
1870 [143]--put beans in pits----
1880 [129] i[178] 1 [164] 6
1890 pit[178]i
1900 [141]2580:[143] beans
1910 pit[178]i[170]7
1920 [141] 2580
1930 [130] i
1940 [142]
1950 [143]---human's move----
1960 x[178]0:y[178]6:[141] 1340
1970 [153]blank$:[141] 1340
1980 [153]" your move (1 to 6) ";:ul[178]1:us$[178]"123456rth"
1990 [141]35
2000 [139] ur$[178]"r" [167] 2080
2010 [139] ur$[178]"t" [167] 2080
2030 m[178][197](ur$)[170]7
2040 [139] bo%(0,m)[179][177]0 [167] 2080
2050 [153]" empty pit, try again";:t[178]ti
2060 [139] ti[179]t[170]90 [167] 2060
2065 [153]"on":[153]" on"
2070 [137] 1960
2080 [142]
2090 [143]---display move---
2100 [139] l[178]0 [167] pit[178]m:[141] 3480:[137] 2140
2110 [129] i[178]1 [164] 14
2120 bo%(l,i)[178]bo%(l[171]1,i):[130] i
2130 m[178]i(l)
2140 pit[178]m:cap[178]0:hnd[178]bo%(l,m):bo%(l,m)[178]0
2150 [139] l[178]0 [167] [141] 2580
2160 ar[178]0:[139] (pit[179]7 [175] pit[170]hnd[177]13) [176] (pit[177]7 [175] pit[170]hnd[177]20) [167] ar[178]1
2170 [129] i[178]1 [164] hnd
2180 pit[178]pit[170]1
2190 [139] m[179]7 [175] pit[178]14 [167] 2180
2200 [139] m[177]7 [175] pit[178]7 [167] 2180
2210 [139] pit [178]15 [167] pit[178]1
2220 bo%(l,pit)[178]bo%(l,pit)[170]1
2230 [139] l[178]0 [167] [141] 2580
2240 [130] i
2250 [139] ar[178]0 [167] 2310
2260 [139] m[179]7 [175] pit[177]6 [167] 2310
2270 [139] m[177]7 [175] (pit[179]7 [176] pit[178]14) [167] 2310
2280 hnd[178]bo%(l,pit):bo%(l,pit)[178]0
2290 [139] l[178]0 [167] [141] 3480:[141] 2580
2300 [137] 2160
2310 [143]---check for capture---
2320 [139] m[179]7 [167] k[178]7
2330 [139] m[177]7 [167] k[178]14
2340 [139] m[179]7 [175] pit [179]8 [167] 2420
2350 [139] m[177]7 [175] pit [177]7 [167] 2420
2360 [139] bo%(l,pit)[179]2 [176] bo%(l,pit)[177]3 [167]2420
2370 cap[178]cap[170]bo%(l,pit):bo%(l,pit)[178]0
2380 [139] l[178]0 [167] [141] 3480:[141] 2580
2390 pit[178]pit[171]1
2400 [139] pit[178]7 [176] pit[178]0 [167] 2420
2410 [137] 2360
2420 pit[178]k:bo%(l,k)[178]bo%(l,k)[170]cap
2430 [139] l[178]0 [167] [141] 2580
2440 [141] 2460
2450 [142]
2460 [143]---check for win---
2470 [139] k[178]7 [167] k[178]8:k1[178]1:k2[178]7
2480 [139] k[178]14 [167] k[178]1:k1[178]8:k2[178]14
2490 w$[178]"y"
2500 nm[178]0
2510 [129] i[178]k [164] k[170]5
2520 [139] bo%(l,i)[179][177]0 [167] w$[178]"n":nm[178]nm[170]1
2530 [130] i
2540 [139] w$[178]"n" [167] 2570
2550 [129] i[178]k1 [164] k1[170]5
2560 bo%(l,k2)[178]bo%(l,k2)[170]bo%(l,i):[130] i
2570 [142]
2580 [143]---update pit----
2590 x[178]pit%(pit,1):y[178]pit%(pit,2)
2600 [141] 1340
2610 n[178]bo%(0,pit)
2620 [139] pit[179][177]7 [175] pit[179][177]14 [167] [153]erase$:[141] 1340
2630 [139] n[177]12 [176] pit[178]7 [176] pit[178]14 [167] [153]""n:[137] 2670
2640 [139] n[178]0 [167] 2670
2650 b[178]n[170][181]((n[171]1)[173]4)[172]5
2660 [153][200](beans$,b)
2670 [142]
2680 [143]---find computer move---
2690 [141] 3030:[143] initialize
2700 [139] level[178]0 [167] 2940
2710 [139] nm[178]1 [167] 2940
2720 [129] i1[178]6 [164] 1 [169] [171]1
2740 i(1)[178]i1: l[178]1:[141] 2090:[141]2460
2750 [139] hnd[178]0 [167] l1%(i1)[178][171]inf:[137] 2930
2760 [139] level[178]1 [176] w$[178]"y" [167] [141] 3320:[137] 2930
2770 f2[178]0
2780 [129] i2[178]6 [164] 1 [169] [171]1:i(2)[178]i2[170]7
2800 [139] f2[178]1 [167] 2920
2810 l[178]2:[141] 2090
2820 [139] hnd[178]0 [167] l2%(i1,i2)[178]inf: [137] 2920
2830 [139] level[178]2 [176] w$[178]"y" [167] [141] 3370:[137] 2920
2840 f3[178]0
2850 [129] i3[178]6 [164] 1 [169] [171]1:i(3)[178]i3
2870 [139] f3[178]1 [167] 2910
2880 l[178]3:[141] 2090
2890 [139] hnd[178]0 [167] 2910
2900 [141] 3440
2910 [130] i3:[141] 3600
2920 [130] i2:[141] 3570
2930 [130] i1
2940 max[178]l1%(1):m%(1)[178]1:c[178]1
2950 [129] i[178]2 [164] 6
2960 [139] l1%(i)[177]max [167] max[178]l1%(i):m%(1)[178]i:c[178]1
2970 [139] l1%(i)[178]max [167] c[178]c[170]1:m%(c)[178]i
2980 [130] i
2990 m[178][181]([187](1)[172]c)[170]1
3000 m[178]m%(m)
3010 [139] bo%(0,m)[178]0 [167] 2990
3020 [142]
3030 [143]---initialize tree---
3040 l0[178][171]inf
3050 [129] i1[178]1 [164] 6
3060 l1%(i1)[178]inf
3070 [129] i2[178]1 [164] 6
3080 l2%(i1,i2)[178][171]inf
3090 [130] i2: [130] i1
3100 [142]
3110 [139] m[177]7 [167] k[178]14
3120 [143]--a win!---
3130 scre [178] bo%(0,7)[171]bo%(0,14)
3140 [153]""
3150 [139] scre[177]0 [167] [153]" i win by"scre"points!
3160 if scre<0 then print" drats! you win by"abs(scre)"points!"
3170 if scre=0 then print" what do you know, a tie!
3180 [153]" cmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdcmdplay again? ";
3190 ul[178]1:us$[178]"ynh":[141]35
3200 [142]
3210 [143]---diagnostic routine---
3220 [153]"load"
3230 [153]:[153]"l0="l0
3240 [153]"level 1 tree
3250 for i= 1 to 6:printl1%(i);:next i
3260 if level=1 then 3300
3270 print:print"level 2 tree
3280 [129] i[178]1 [164] 6:[129] j[178]1 [164] 6
3290 [153]l2%(i,j);:[130] j:[153]:[130] i
3300 [141] 1360
3310 [141] 1690:[142]
3320 [143]---level=1----
3330 e[178]bo%(l,7)[171]bo%(l,14)
3340 [139] hnd[178]0 [167] e[178][171]inf:[143] not legal move
3350 l1%(i(1))[178]e
3360 [142]
3370 [143]---level 2---
3380 e[178]bo%(l,7)[171]bo%(l,14)
3390 [139] hnd[178]0 [167] e[178]inf
3400 l2%(i(1),i(2)[171]7)[178]e
3410 [139] e[179]l1%(i(1))[167] l1%(i(1))[178]e
3420 [139] l1%(i(1))[179]l0 [167] f2[178]1
3430 [142]
3440 [143]---level 3---
3450 e[178]bo%(l,7)[171]bo%(l,14)
3460 [139] e[177]l2%(i(1),i(2)[171]7) [167] l2%(i(1),i(2)[171]7)[178]e:[139] e[177][178]l1%(i(1))[167] f3[178]1
3470 [142]
3480 [143]---blink move---
3490 d[178]pit%(pit,2)[172]40[170]pit%(pit,1)[170]us
3495 [137]3560
3500 [129] i[178]0 [164] 2
3510 [129] j [178] 0 [164] 3
3520 d1[178][194](d[170]j[170]40[172]i):[139] d1[177]128 [167] 3550
3530 [151] d[170]j[170]i[172]40,d1[170]128
3540 [130] j:[130] i
3550 [129] i[178]1 [164] 500:[130] i
3560 [142]
3570 [143] moving up from level 2
3580 [139] l1%(i(1))[177]l0 [167] l0[178]l1%(i(1))
3590 [142]
3600 [143] moving up from level 3
3610 [139] l2%(i(1),i(2)[171]7)[177][178]l1%(i(1)) [167] 3640
3620 l1%(i(1))[178]l2%(i(1),i(2)[171]7)
3630 [139] l1%(i(1))[179] l0 [167] f2[178]1
3640 [142]