home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Compute! Gazette 1986 September
/
1986-09.d64
/
jujitsu
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-09-20
|
3KB
|
118 lines
100 dim hu(13),su(13),ca$(13),cl(13),cl$(13):print"[147]"
110 def fnr(x)=int(rnd(1)*x)
120 poke 53281,0:poke 53280,0
130 aa$="a23456789tjqk":z=rnd(-ti):s=54272
140 for a=50000 to a+81:read b:poke a,b:next
160 for i=1 to 13
170 cl(i)=i
180 ca$(i)=mid$(aa$,i,1):cl$(i)=mid$(aa$,i,1):next
190 rem * shuffle deck *
200 for i=1 to 13
210 x=fnr(13)+1:y=fnr(13)+1
220 h$=cl$(x):cl$(x)=cl$(y):cl$(y)=h$
230 h=cl(x):cl(x)=cl(y):cl(y)=h:next
240 rem * start main loop *
250 for r=1 to 13
260 print"[147][156][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210][210]"
270 print"[145] [218] j u j i t s u [218] "
280 print"[145][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183][183]"
290 print"[145][211][155] your hand:"
300 for i=1 to 13
310 if hu(i)=1 then 330
320 print ca$(i);" ";
330 next:print
340 print"[193][155] my hand:"
350 for i=1 to 13
360 if su(i)=1 then 380
370 print ca$(i);" ";
380 next:print
390 print"[216][155] clubs played:"
400 for i=1 to r-1:if r=1 then 420
410 print cl$(i);" ";
420 next:print
430 print"[156][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175][175]"
440 rem * show card and bid *
450 print"[155]what do you bid for the "cl$(r)"[216][155] ?"
460 poke 198,0
470 get a$:if a$="" then 470
480 if a$="a" or a$="t" or a$="j" or a$="q" or a$="k" then 500
490 if a$<"2" or a$>"9" then 470
500 for i=1 to 13:if a$=mid$(aa$,i,1) then hb=i:i=13:goto 520
510 next
520 if hu(hb)=1 then gosub 1180:print"[145][145]":goto 450
530 sys 50000
540 rem * computer calculates bid *
550 if r>=7 then 670
560 if cl(r)>=8 and rnd(1)<.38 then sb=fnr(13)+1:goto 640
570 m=5:if cl(r)<4 then m=3
580 mm=fnr(4)
590 if cl(r)<=4 then sb=cl(r)+fnr(m)
600 if cl(r)>=5 then sb=cl(r)+fnr(m)+mm
610 if cl(r)>10 then sb=cl(r)+fnr(m)+1
620 if sb>13 then sb=13
630 c=c+1:if c=20 then c=0:goto 880
640 if su(sb)=1 then 580
650 c=0:goto 940
660 rem * check high heart and spade *
670 for i=13 to 1 step-1:if hu(i)=1 then 690
680 hh=i:i=1
690 next
700 for i=13 to 1 step-1:if su(i)=1 then 720
710 sh=i:i=1
720 next
730 if r=13 then sb=sh:goto 940
740 if hh>=sh and hs+cl(r)>=46 then sb=sh:goto 940
750 rem * consider remaining clubs *
760 for i=1 to 13:if i=r then next
770 ct=ct+cl(i):next
780 for i=1 to 13:if i=r then 800
790 if cl(i)>ch then ch=cl(i)
800 next
810 if r=12 and ch>cl(r) then 880
820 if hh=sh and cl(r)>ch then sb=sh:goto 920
830 if hh>sh and cl(r)>ch then 880
840 if hh<sh and cl(r)>ch then sb=sh:goto 920
850 if r>=10 and cl(r)<=8 and hh<=sh and ct/(13-r)>=8 then 880
860 ct=0:ch=0:goto 570
870 rem * go for low card *
880 for i=1 to 13
890 if su(i)=1 then 910
900 sb=i:i=13
910 next
920 ct=0:ch=0
930 rem * see who gets trick *
940 print tab(8)"you bid "spc(3)ca$(hb)"[211][155]":hu(hb)=1
950 print tab(8)"i bid "spc(5)ca$(sb)"[193][155]":su(sb)=1:print
960 if hb=sb then print tab(12)"it's a tie":gosub 1010:nextr
970 if sb>hb then printtab(8)"spades win the trick":ss=ss+cl(r):gosub1010:nextr
980 print tab(8)"hearts win the trick":hs=hs+cl(r):gosub 1010:nextr
1000 rem * calculate and display score *
1010 print tab(8)"hearts score ="hs
1020 print tab(8)"spades score ="ss
1030 for i=1 to 3000:next
1040 if hs>=46 or ss>=46 then 1080
1050 cl(r)=0:if r=13 then 1080
1060 return
1070 rem * display final results *
1080 print"[147]"
1090 if ss=hs then co=4:print tab(14)"[156]tie game":goto 1120
1100 if ss>hs then co=6:print tab(13)"computer wins":goto 1120
1110 co=2:print tab(15)"you win"
1120 print"[155]"tab(12)"play again (y/n)"
1130 poke 198,0
1140 geta$:if a$<>"y" and a$<>"n" then 1140
1150 if a$="n" then end
1160 run
1180 poke s,150:poke s+1,5:poke s+5,0:poke s+6,240:poke s+24,15:poke s+4,17
1190 for i=0 to 500:next:poke s+24,0:return
1200 data 32,133,195,169,9,141,5,212
1210 data 169,30,141,15,212,169,130,141
1220 data 1,212,169,15,141,24,212,169
1230 data 40,141,4,212,169,7,141,163
1240 data 195,32,145,195,169,31,141,4
1250 data 212,169,20,141,163,195,32,145
1260 data 195,32,133,195,96,162,0,138
1270 data 157,0,212,232,224,24,208,248
1280 data 96,165,162,24,109,163,195,141
1290 data 162,195,165,162,205,162,195,208,249,96