home *** CD-ROM | disk | FTP | other *** search
/ Compute! Gazette 1986 September / 1986-09.d64 / jujitsu (.txt) < prev    next >
Commodore BASIC  |  2022-09-20  |  3KB  |  118 lines

  1. 100 dim hu(13),su(13),ca$(13),cl(13),cl$(13):print"[147]"
  2. 110 def fnr(x)=int(rnd(1)*x)
  3. 120 poke 53281,0:poke 53280,0
  4. 130 aa$="a23456789tjqk":z=rnd(-ti):s=54272
  5. 140 for a=50000 to a+81:read b:poke a,b:next
  6. 160 for i=1 to 13
  7. 170 cl(i)=i
  8. 180 ca$(i)=mid$(aa$,i,1):cl$(i)=mid$(aa$,i,1):next
  9. 190 rem * shuffle deck *
  10. 200 for i=1 to 13
  11. 210 x=fnr(13)+1:y=fnr(13)+1
  12. 220 h$=cl$(x):cl$(x)=cl$(y):cl$(y)=h$
  13. 230 h=cl(x):cl(x)=cl(y):cl(y)=h:next
  14. 240 rem * start main loop *
  15. 250 for r=1 to 13
  16. 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]"
  17. 270 print"[145]      [218]   j  u  j  i  t  s  u   [218]       "
  18. 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]"
  19. 290 print"[145][211][155] your hand:"
  20. 300 for i=1 to 13
  21. 310 if hu(i)=1 then 330
  22. 320 print ca$(i);" ";
  23. 330 next:print
  24. 340 print"[193][155] my hand:"
  25. 350 for i=1 to 13
  26. 360 if su(i)=1 then 380
  27. 370 print ca$(i);" ";
  28. 380 next:print
  29. 390 print"[216][155] clubs played:"
  30. 400 for i=1 to r-1:if r=1 then 420
  31. 410 print cl$(i);" ";
  32. 420 next:print
  33. 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]"
  34. 440 rem * show card and bid *
  35. 450 print"[155]what do you bid for the "cl$(r)"[216][155] ?"
  36. 460 poke 198,0
  37. 470 get a$:if a$="" then 470
  38. 480 if a$="a" or a$="t" or a$="j" or a$="q" or a$="k" then 500
  39. 490 if a$<"2" or a$>"9" then 470
  40. 500 for i=1 to 13:if a$=mid$(aa$,i,1) then hb=i:i=13:goto 520
  41. 510 next
  42. 520 if hu(hb)=1 then gosub 1180:print"[145][145]":goto 450
  43. 530 sys 50000
  44. 540 rem * computer calculates bid *
  45. 550 if r>=7 then 670
  46. 560 if cl(r)>=8 and rnd(1)<.38 then sb=fnr(13)+1:goto 640
  47. 570 m=5:if cl(r)<4 then m=3
  48. 580 mm=fnr(4)
  49. 590 if cl(r)<=4 then sb=cl(r)+fnr(m)
  50. 600 if cl(r)>=5 then sb=cl(r)+fnr(m)+mm
  51. 610 if cl(r)>10 then sb=cl(r)+fnr(m)+1
  52. 620 if sb>13 then sb=13
  53. 630 c=c+1:if c=20 then c=0:goto 880
  54. 640 if su(sb)=1 then 580
  55. 650 c=0:goto 940
  56. 660 rem * check high heart and spade *
  57. 670 for i=13 to 1 step-1:if hu(i)=1 then 690
  58. 680 hh=i:i=1
  59. 690 next
  60. 700 for i=13 to 1 step-1:if su(i)=1 then 720
  61. 710 sh=i:i=1
  62. 720 next
  63. 730 if r=13 then sb=sh:goto 940
  64. 740 if hh>=sh and hs+cl(r)>=46 then sb=sh:goto 940
  65. 750 rem * consider remaining clubs *
  66. 760 for i=1 to 13:if i=r then next
  67. 770 ct=ct+cl(i):next
  68. 780 for i=1 to 13:if i=r then 800
  69. 790 if cl(i)>ch then ch=cl(i)
  70. 800 next
  71. 810 if r=12 and ch>cl(r) then 880
  72. 820 if hh=sh and cl(r)>ch then sb=sh:goto 920
  73. 830 if hh>sh and cl(r)>ch then 880
  74. 840 if hh<sh and cl(r)>ch then sb=sh:goto 920
  75. 850 if r>=10 and cl(r)<=8 and hh<=sh and ct/(13-r)>=8 then 880
  76. 860 ct=0:ch=0:goto 570
  77. 870 rem * go for low card *
  78. 880 for i=1 to 13
  79. 890 if su(i)=1 then 910
  80. 900 sb=i:i=13
  81. 910 next
  82. 920 ct=0:ch=0
  83. 930 rem * see who gets trick *
  84. 940 print tab(8)"you bid "spc(3)ca$(hb)"[211][155]":hu(hb)=1
  85. 950 print tab(8)"i bid "spc(5)ca$(sb)"[193][155]":su(sb)=1:print
  86. 960 if hb=sb then print tab(12)"it's a tie":gosub 1010:nextr
  87. 970 if sb>hb then printtab(8)"spades win the trick":ss=ss+cl(r):gosub1010:nextr
  88. 980 print tab(8)"hearts win the trick":hs=hs+cl(r):gosub 1010:nextr
  89. 1000 rem * calculate and display score *
  90. 1010 print tab(8)"hearts score ="hs
  91. 1020 print tab(8)"spades score ="ss
  92. 1030 for i=1 to 3000:next
  93. 1040 if hs>=46 or ss>=46 then 1080
  94. 1050 cl(r)=0:if r=13 then 1080
  95. 1060 return
  96. 1070 rem * display final results *
  97. 1080 print"[147]"
  98. 1090 if ss=hs then co=4:print tab(14)"[156]tie game":goto 1120
  99. 1100 if ss>hs then co=6:print tab(13)"computer wins":goto 1120
  100. 1110 co=2:print tab(15)"you win"
  101. 1120 print"[155]"tab(12)"play again (y/n)"
  102. 1130 poke 198,0
  103. 1140 geta$:if a$<>"y" and a$<>"n" then 1140
  104. 1150 if a$="n" then end
  105. 1160 run
  106. 1180 poke s,150:poke s+1,5:poke s+5,0:poke s+6,240:poke s+24,15:poke s+4,17
  107. 1190 for i=0 to 500:next:poke s+24,0:return
  108. 1200 data 32,133,195,169,9,141,5,212
  109. 1210 data 169,30,141,15,212,169,130,141
  110. 1220 data 1,212,169,15,141,24,212,169
  111. 1230 data 40,141,4,212,169,7,141,163
  112. 1240 data 195,32,145,195,169,31,141,4
  113. 1250 data 212,169,20,141,163,195,32,145
  114. 1260 data 195,32,133,195,96,162,0,138
  115. 1270 data 157,0,212,232,224,24,208,248
  116. 1280 data 96,165,162,24,109,163,195,141
  117. 1290 data 162,195,165,162,205,162,195,208,249,96
  118.