home *** CD-ROM | disk | FTP | other *** search
/ CBM Funet Archive / cbm-funet-archive-2003.iso / cbm / c64 / games / Maija.prg (.txt) < prev    next >
Encoding:
Commodore BASIC  |  2003-01-05  |  8.2 KB  |  343 lines

  1. 1 fora=1to2:nexta
  2. 10 print"[147]";tab(13);"maija":printtab(13)"[196][196][196][196][196]"
  3. 20 i=rnd(-ti):print:print:print
  4. 30 print" saannot ovat maijapelin tavanomaiset":print" saannot."
  5. 40 print" seuraavat korvaukset luvallisia:"
  6. 50 print" a=[193] , s=[211] , z=[218] ja x=[216] ."
  7. 60 print" nosto=^ ."
  8. 70 print" lyonnit muodossa [211]12 jne.":print
  9. 400 deffnl(x)=int((x-1)/13+.0005)+1
  10. 410 deffnk(x)=x-13*fnl(x)+13
  11. 430 deffns(x)=int(80*rnd(x))-10
  12. 440 dimz%(5,4),l(4),ms(4),a%(52),v%(4),p%(13)
  13. 442 p%(0)=1:fori=1to13:p%(i)=2*p%(i-1):nexti
  14. 450 data"[193]","[216]","[218]","[211]"
  15. 500 rem sekoitus
  16. 510 fori=1to52
  17. 520 x=fns(0):ifx<1orx>52then520
  18. 540 ifa%(x)=0thena%(x)=i:goto570
  19. 550 x=x+1:ifx=53thenx=1
  20. 560 goto540
  21. 570 nexti
  22. 575 rem valtti
  23. 580 x=fns(0):ifx<1orx>52then580
  24. 585 ifa%(x)<14then580
  25. 600 rem valtti pohjalle
  26. 620 j=a%(x)
  27. 630 ifx=52then670
  28. 640 fori=xto51:a%(i)=a%(i+1):next
  29. 660 a%(52)=j
  30. 670 vl=fnl(a%(52)):rem valtin maa
  31. 680 fori=1tovl:readv$:nexti
  32. 690 a1=1:rem pakan jako/a1 1 vapaa kortti
  33. 700 print"moneksiko pelaajaksi kone jakautuu?"
  34. 710 print"(1-5 sallittuja) ";
  35. 720 gosub6000:f=asc(o$)-48:iff<1orf>5thengosub6050:goto710
  36. 740 printo$:print"pelaatko itse? (k=kylla) ";
  37. 750 gosub6000:ifo$<>"k"theno$="e"
  38. 760 printo$:ifo$="k"thenf=-f
  39. 765 a1=1:forp=(sgn(f)+1)/2toabs(f):gosub6200:nextp
  40. 766 p=0:gosub6100
  41. 770 print"kuka aloittaa? (0=sina,1-5 mina) ";
  42. 780 gosub6000:g=asc(o$)-48
  43. 790 ifg<0org>abs(f)or(g=0andf>0)thengosub6050:goto770
  44. 800 printo$
  45. 810 gosub6500
  46. 815 iff>0thenprint"valtti=";v$:gosub6600
  47. 820 ifp0<2then1000
  48. 830 h=g+1
  49. 850 ifh=abs(f)+1thenh=0
  50. 860 ifh=0andf>0thenh=1
  51. 870 ifz%(h,0)=0thenh=h+1:goto850
  52. 880 gosub1200:gosub6300:ifz%(g,0)=0andp0<3then1000
  53. 890 gosub4000:gosub6300
  54. 900 g=h:ifnl=1theng=h+1
  55. 910 ifg=abs(f)+1theng=0
  56. 920 ifg=0andf>0theng=1
  57. 930 ifz%(g,0)=0theng=g+1:goto910
  58. 940 goto810
  59. 1000 forp=0toabs(f):ifz%(p,0)=0then1050
  60. 1010 ifp=0thenprint"sina havisit![134]":goto1050
  61. 1020 print"#";mid$(str$(p),2);" havisi![134]"
  62. 1050 nextp:goto9800
  63. 1200 rem g lyo
  64. 1210 ml=0:ifg=0then3620
  65. 1220 fori=1to4:l(i)=0:ms(i)=0:nexti
  66. 1230 fori=1to4:forj=2to13
  67. 1240 ifz%(g,i)andp%(j)thenl(i)=l(i)+1:ms(i)=ms(i)+j
  68. 1250 nextj:ifz%(g,i)and2thenl(i)=l(i)+1:ms(i)=ms(i)+14
  69. 1260 nexti
  70. 1270 fori=1to4:ifl(i)<>0thenms(i)=ms(i)/l(i)
  71. 1280 nexti
  72. 1290 rem s-jarj
  73. 1300 fori=1to4
  74. 1310 q=90:forj=1to4
  75. 1320 ifms(j)<=qandms(j)>0thenr=j:q=ms(j)
  76. 1330 nextj:ms(r)=-1:v%(i)=r:nexti
  77. 1340 rem ^ v%() maat huonoin-paras
  78. 1350 rem maiden maara mm
  79. 1360 mm=0:fori=1to4:ifl(i)<>0thenmm=mm+1
  80. 1365 nexti
  81. 1370 l9=0:ml=0:z=z%(g,1):p1=4096:onmmgoto3300,2900,2230,2170
  82. 2170 rem 4m
  83. 2180 ml=1
  84. 2190 ifl(1)=1and(zandp1)then2212
  85. 2200 i1=1
  86. 2202 ll=v%(i1):ifll=vltheni1=i1+1:goto2202
  87. 2210 goto3500
  88. 2212 i1=1
  89. 2214 ll=v%(i1):ifll=1orll=vltheni1=i1+1:goto2214
  90. 2220 goto3500
  91. 2230 rem 3m
  92. 2235 ifa1>54-2*p0then2260
  93. 2240 ifl(1)>1and(zandp1)andl(vl)>0then2282
  94. 2242 ifl(1)>1and(zandp1)andl(vl)=0then2282
  95. 2244 ifl(1)>0and(notzandp1)andl(vl)>0then2282
  96. 2246 ifl(1)=1and(zandp1)andl(vl)>0then2300
  97. 2248 ifl(1)>0and(notzandp1)andl(vl)=0then2300
  98. 2250 ifl(1)=1and(zandp1)andl(vl)=0then2300
  99. 2252 goto2272
  100. 2260 ifl(1)>1and(zandp1)andl(vl)>0then2360
  101. 2262 ifl(1)>1and(zandp1)andl(vl)=0then2370
  102. 2264 ifl(1)>1and(notzandp1)andl(vl)>0then2272
  103. 2266 ifl(1)=1and(zandp1)andl(vl)>0then2360
  104. 2268 ifl(1)>1and(notzandp1)andl(vl)=0then2330
  105. 2270 ifl(1)=1and(zandp1)andl(vl)=0then2370
  106. 2272 rem
  107. 2274 i1=1
  108. 2276 ll=v%(i1):if(ll)=0orll=vltheni1=i1+1:goto2276
  109. 2280 goto3500
  110. 2282 rem
  111. 2284 ml=1:i1=1
  112. 2286 ll=v%(i1):if(ll)=0orll=vltheni1=i1+1:goto2286
  113. 2292 goto3500
  114. 2300 rem
  115. 2305 i1=1
  116. 2306 ll=v%(i1):if(ll)=0orll=1orll=vltheni1=i1+1:goto2306
  117. 2320 goto3500
  118. 2330 rem
  119. 2335 i1=1
  120. 2336 ll=v%(i1):if(ll)=0theni1=i1+1:goto2336
  121. 2350 goto3500
  122. 2360 rem
  123. 2365 ll=1:goto3500
  124. 2370 rem
  125. 2371 i1=1
  126. 2380 ll=v%(i1):if(ll)=0orll=1theni1=i1+1:goto2380
  127. 2390 goto3500
  128. 2900 rem 2m
  129. 2910 ifa1>54-2*p0then2950
  130. 2915 ifl(1)>1and(zandp1)andl(vl)>0then3010
  131. 2920 ifl(1)>0and(notzandp1)andl(vl)>0then3010
  132. 2925 ifl(1)=1and(zandp1)andl(vl)>0then3030
  133. 2930 ifl(1)>0and(notzandp1)andl(vl)=0then2330
  134. 2935 ifl(1)=1and(zandp1)andl(vl)=0then2370
  135. 2940 ifl(1)=0andl(vl)>0then2272
  136. 2941 goto2330
  137. 2950 ifl(1)>1and(zandp1)andl(vl)>0then2360
  138. 2955 ifl(1)>0and(notzandp1)andl(vl)>0then3030
  139. 2960 ifl(1)=1and(zandp1)andl(vl)>0then2360
  140. 2965 ifl(1)>0and(notzandp1)andl(vl)=0then2981
  141. 2970 ifl(1)=1and(zandp1)andl(vl)=0then2360
  142. 2975 ifl(1)=0andl(vl)>0then3030
  143. 2981 rem
  144. 2990 i1=4
  145. 2995 ll=v%(i1):if(ll)=0theni1=i1+1:goto2995
  146. 3005 goto3500
  147. 3010 rem
  148. 3020 ml=1:ll=1:goto3500
  149. 3030 rem
  150. 3035 ll=vl:goto3500
  151. 3300 rem 1m
  152. 3310 ifl(1)>1and(zandp1)anda1<54-p0thenml=1
  153. 3320 ifl(1)>0thenll=1:goto3500
  154. 3330 ifl(vl)>0anda1<48thenll=vl:l9=1:goto3500
  155. 3331 ifl(vl)>0thenll=vl:goto3500
  156. 3340 i1=1
  157. 3345 ll=v%(i1):ifl(ll)=0theni1=i1+1:goto3345
  158. 3370 rem
  159. 3500 rem koneen (g) lyomat
  160. 3502 l1=0:p2=0:forii=1to13
  161. 3504 ifz%(g,ll)andp%(ii)thenl1=l1+p%(ii):p2=p2+1
  162. 3506 nextii:ifl9=0then3510
  163. 3507 ifl1<>2thenl1=l1-(l1and2)
  164. 3508 forii=2to13:ifl1andp%(ii)thenl1=p%(ii):p2=1:ii=13
  165. 3509 nextii
  166. 3510 ifp2>1andll=1andml=1and(l1and4096)thenl1=l1-4096:p2=p2-1
  167. 3520 ifa1>40-5*p0then3556
  168. 3530 rem arvokortit alussa pois
  169. 3540 ifp2>1and(l1and2)thenl1=l1-2:p2=p2-1
  170. 3545 ifp2>1and(l1and8192)thenl1=l1-8192:p2=p2-1
  171. 3550 ifp2>1and(l1and4096)thenl1=l1-4096:p2=p2-1
  172. 3555 ifp2>1and(l1and2048)thenl1=l1-2048:p2=p2-1
  173. 3556 ifp2<=z%(h,0)then3565
  174. 3557 ifa1=53andmm=1andp0=2then3562
  175. 3558 ifl1and2thenl1=l1-2:p2=p2-1:goto3556
  176. 3559 i1=13
  177. 3560 ifnotl1andp%(i1)theni1=i1-1:goto3560
  178. 3561 l1=l1-p%(i1):p2=p2-1:goto3556
  179. 3562 i1=2
  180. 3563 ifnotl1andp%(i1)theni1=i1+1:goto3563
  181. 3564 l1=l1-p%(i1):p2=p2-1:goto3556
  182. 3565 z%(g,0)=z%(g,0)-p2
  183. 3570 z%(g,ll)=z%(g,ll)-(z%(g,ll)andl1)
  184. 3575 p=g:gosub6200:rem nostaa g:lle
  185. 3580 rem ilmoittaa koneen lyonnit
  186. 3581 ifh=0thenp=0:gosub6100:gosub6600:print
  187. 3585 print"#";g;":n lyonti:";
  188. 3590 restore:forii=1toll:reado$:nextii
  189. 3600 fori1=1to13:ifl1andp%(i1)thenprinto$;mid$(str$(i1),2);",";
  190. 3605 nexti1:print"[136] "
  191. 3610 return:rem koneelle
  192. 3620 rem sina lyot
  193. 3622 p=0:gosub6100:gosub6600:print
  194. 3625 print"peruutus= _"
  195. 3630 print"mita maata lyot ";
  196. 3635 gosub6000:gosub6400:printo$:ifo$="_"then3630
  197. 3640 ll=0:restore:fori1=1to4:reada$:ifa$=o$thenll=i1
  198. 3650 nexti1:ifll=0thengosub6050:goto3630
  199. 3660 p2=0:fori1=1to13:ifz%(g,ll)andp%(i1)thenp2=p2+1
  200. 3670 nexti1:ifp2=0thengosub6050:goto3630
  201. 3680 l1=0:goto3710
  202. 3690 fori1=1to13:ifl1andp%(i1)thenz%(g,0)=z%(g,0)+1:z%(g,ll)=z%(g,ll)+p%(i1)
  203. 3700 nexti1:goto3630
  204. 3710 input"montako lyot";a$
  205. 3711 ifa$="_"thenprint"[145]peruutat         ":goto3690
  206. 3712 print"[145]lyot "a$" kpl.         "
  207. 3720 a3=val(a$)
  208. 3730 ifa3<1ora3>p2ora3>z%(h,0)ora3<>int(a3)thengosub6050:goto3710
  209. 3740 fori=1toa3:print"lyontisi #";i;"=";o$;:inputa$
  210. 3741 ifa$="_"thenprint"[145]                      ":print"[145]peruutat":goto3690
  211. 3742 print"[145]"spc(12)"            ":print"[145]"spc(13)"="o$a$
  212. 3750 v=0:fori1=1to13:ifmid$(str$(i1),2)=a$thenv=i1
  213. 3760 nexti1:ifv=0or(l1andp%(v))thengosub6050:goto3690
  214. 3765 ifnotz%(g,ll)andp%(val(a$))thengosub6050:goto3690
  215. 3770 l1=l1+p%(v):z%(g,ll)=z%(g,ll)-p%(v):z%(g,0)=z%(g,0)-1:nexti
  216. 3780 p=g:gosub6200
  217. 3800 return:rem 2:lle
  218. 4000 rem kaato
  219. 4001 nl=0
  220. 4010 ifg=0thenprint"sina lyot";:goto4015
  221. 4012 print"#";g;"lyo";
  222. 4015 print"...";:ifh=0thenprint"sina kaadat":goto4020
  223. 4017 print"#";h;"kaataa"
  224. 4020 ifh=0then5000
  225. 4030 rem kone kaataa
  226. 4040 a3=5*p0+20
  227. 4045 restore:fori=1toll:reado$:nexti
  228. 4050 ifll=vlanda1<a3then4600
  229. 4060 fori=1to13
  230. 4070 ifnotl1andp%(i)then4350
  231. 4075 if(ll=1andi=12)or(ll=vlandi=1)then4350
  232. 4080 ifll=vlthen4180
  233. 4090 forq=3to14:j=q-13*int(q/14)
  234. 4100 if(notl1andp%(i))or(notz%(h,ll)andp%(j))then4170
  235. 4110 ifll=1andj=12then4170
  236. 4120 ifj<>1andj<ithen4170
  237. 4130 if(j=1orj>10)anda1<a3andz%(h,0)<11then4170
  238. 4140 ifi=1then4170
  239. 4150 l1=l1-p%(i):z%(h,ll)=z%(h,ll)-p%(j):z%(h,0)=z%(h,0)-1
  240. 4160 printo$;i;"........";o$;j
  241. 4170 nextq
  242. 4180 forq=2to14:j=q-13*int(q/14)
  243. 4190 if(notl1andp%(i))or(notz%(h,vl)andp%(j))then4340
  244. 4200 i1=j:ifj=1theni1=14
  245. 4205 if(j=1orj>10)anda1<a3then4340
  246. 4210 ifrnd(0)<.95anda1<2*i1+22+.5*z%(h,0)then4340
  247. 4320 ifll=vlandj<iandj<>1then4340
  248. 4330 l1=l1-p%(i):z%(h,vl)=z%(h,vl)-p%(j):z%(h,0)=z%(h,0)-1
  249. 4335 printo$;i;"........";v$;j
  250. 4340 nextq
  251. 4350 nexti
  252. 4600 rem nostot ja kirjaus
  253. 4610 fori=1to13
  254. 4620 ifnotl1andp%(i)then4650
  255. 4630 z%(h,ll)=z%(h,ll)+p%(i):z%(h,0)=z%(h,0)+1:nl=1
  256. 4640 printo$;i;"......... ^"
  257. 4650 nexti:p=h:gosub6200
  258. 4660 return:rem 0,1
  259. 5000 rem #2
  260. 5010 print"peruutus= _"
  261. 5020 i2=0:fori=1to13:ifl1andp%(i)theni2=i2+1
  262. 5030 nexti:rem i2 lyotyjen maara
  263. 5040 restore:fori=1toll:reada$:nexti
  264. 5050 print"#";g;":n lyonti";
  265. 5070 print".....kaatosi"
  266. 5080 k1=0:k2=0:k3=0:fori=1toi2:printa$;
  267. 5090 i1=0:forj=1to13:ifl1andp%(j)theni1=i1+1
  268. 5100 ifi1=itheni1=j:j=13
  269. 5102 nextj
  270. 5110 printi1;"              ";:inputo$
  271. 5111 o2$=mid$(o$,2):o$=left$(o$,1):gosub6400
  272. 5115 print"[145]"spc(14)"           ":print"[145]"spc(20)o$o2$
  273. 5120 ifo$="_"then5050
  274. 5125 ifo$="^"thenk3=k3+p%(i1):goto5300
  275. 5140 o=0:forj=1to13:ifo2$=mid$(str$(j),2)theno=j
  276. 5150 nextj:ifo=0then5800
  277. 5160 v=0:restore:forj=1to4:reado2$:ifo2$=o$thenv=j
  278. 5170 nextj:ifv=0then5800
  279. 5180 if(v<>vland(k1andp%(o)))or(v=vland(k2andp%(o)))then5800
  280. 5190 if(ll=1andi1=12)or(ll=vlandi1=1)then5800
  281. 5195 ifnotz%(h,v)andp%(o)then5800
  282. 5200 ifll<>vandv<>vlthen5800
  283. 5205 ifll=vando=1then5280
  284. 5210 ifo<i1andv<>vlthen5800
  285. 5220 ifi1=1andv<>vlthen5800
  286. 5230 ifll=vlandv=vlando<i1then5800
  287. 5240 ifv=1ando=12then5800
  288. 5280 ifv<>vlthenk1=k1+p%(o)
  289. 5290 ifv=vlthenk2=k2+p%(o)
  290. 5300 nexti
  291. 5310 rem kirjaus
  292. 5320 fori=1to13
  293. 5330 ifk1andp%(i)thenz%(h,ll)=z%(h,ll)-p%(i):z%(h,0)=z%(h,0)-1
  294. 5340 ifk2andp%(i)thenz%(h,vl)=z%(h,vl)-p%(i):z%(h,0)=z%(h,0)-1
  295. 5350 ifk3andp%(i)thenz%(h,ll)=z%(h,ll)+p%(i):z%(h,0)=z%(h,0)+1:nl=1
  296. 5360 nexti:p=h:gosub6200:goto5900
  297. 5800 gosub6050:goto5050
  298. 5900 return:rem 2
  299. 6000 geto$:ifo$=""then6000
  300. 6010 return
  301. 6050 print"virhe[134]":return
  302. 6100 rem p:n kortit
  303. 6101 ifz%(p,0)=0thenreturn
  304. 6106 ifp=0thenprint"korttisi:":goto6110
  305. 6108 print"#";p;":n kortit:"
  306. 6110 print"[196][196][196][196][196][196][196][196][196][196][196]valtti=";v$
  307. 6115 restore:fori1=1to4:reado$:printo$;": ";
  308. 6120 fori2=1to13:ifz%(p,i1)andp%(i2)thenprinto$;mid$(str$(i2),2);",";
  309. 6130 nexti2:print"[136] ":nexti1
  310. 6135 print"[196][196][196][196][196][196][196][196][196][196][196]"
  311. 6140 return
  312. 6200 rem jakaa p:lle kortit
  313. 6215 ifa1=53thenreturn
  314. 6220 a2=a1+5-z%(p,0):ifa2>53thena2=53
  315. 6230 ifa2-1<a1thenreturn
  316. 6240 fori1=a1toa2-1:z%(p,0)=z%(p,0)+1
  317. 6250 i2=fnl(a%(i1)):z%(p,i2)=z%(p,i2)+p%(fnk(a%(i1)))
  318. 6260 nexti1:a1=a2
  319. 6270 return
  320. 6300 forp=(sgn(f)+1)/2toabs(f)
  321. 6310 ifz%(p,0)>0or(t0andp%(p))then6340
  322. 6315 t0=t0+p%(p)
  323. 6320 ifp=0thenprint"paasit pois![134]":goto6340
  324. 6330 print"#";mid$(str$(p),2);" paasi pois![134]"
  325. 6340 nextp:return
  326. 6400 ifo$="a"theno$="[193]"
  327. 6410 ifo$="s"theno$="[211]"
  328. 6420 ifo$="z"theno$="[218]"
  329. 6430 ifo$="x"theno$="[216]"
  330. 6450 return
  331. 6500 p0=0:forii=0toabs(f):ifz%(ii,0)<>0thenp0=p0+1
  332. 6510 nextii:return
  333. 6600 forp=0toabs(f):ifz%(p,0)=0then6650
  334. 6610 ifp=0thenprint"sinulla";:goto6630
  335. 6620 print"#";p;":lla";
  336. 6630 printz%(p,0)
  337. 6650 nextp
  338. 6660 print"pakassa";53-a1;"korttia":return
  339. 7000 rem vl-korjaus
  340. 9800 rem
  341. 9810 forp=0toabs(f):gosub6100:nextp
  342. 9900 end
  343.