Author Topic: BASEBALL - TEXT VERSION  (Read 1093 times)

0 Members and 1 Guest are viewing this topic.

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
BASEBALL - TEXT VERSION
« on: July 07, 2020, 10:46:44 am »
This program came with the Altair 8800, 8K BASIC.

I remember this game because as a graduation present, my parents bought me an Altair 8800. I loved working with that computer, and it helped me to understand how to code in machine code, which came in handy when I was a systems programmer and had to solve problems on an IBM 360/67 mainframe. The lights and switches worked just like the ones on the Altair 8800, but 360 showed a lot more registers. memory, and instruction sets.

So I have gone back and got a Altair Clone, so you will see some oldies but goodies here.

I plan to add graphics to this game once I unspaghettify the code (I also have a QB64 version of Microsoft's Remove Line Numbers program, which I will also post here.

I first got this code to run on my iPad using TechBASIC (a modified version GSoft BASIC, but designed to work with sensors and Arduino and PI boards), that made the conversion to QB64 easier, as GSoft BASIC ran on the Apple IIgs.

Also, in modifying the code for QB64, I am also attaching to this post the Veranda ttf Font File, as I use it in the code. You can look at the Screen section and replace that with any font you like.

Here is the program.

Code: QB64: [Select]
  1. _TITLE "BASEBALL (TEXT VERSION)"
  2.  
  3. REM "BASEBALL SIMULATION PROGRAM (TEXT MODE)
  4. REM "A VERSION OF THIS PROGRAM RAN ON THE ALTAIR 8800 8K BASIC (1977)
  5. REM "WRITTEN BY JOEL LIND & KEN BIRKMAN - NYU - JULY 1973
  6. REM "STOLEN AND ENHANCED DECEMBER 1973 BY R. D. KURLAND - NYU
  7. REM "RESTOLEN AND CONVERTED TO RUN IN TECHBASIC (JULY 7, 2020) BY GEORGE MCGINN
  8. REM "CONVERTED FROM TECHBASIC TO QB64 (JULY 7, 2020) BY GEORGE MCGINN
  9.  
  10. '***************************************************
  11. ' SETUP SCREEN FORMAT & SIZE, FONT TYPE & SIZE
  12. '***************************************************
  13.  
  14. '*** Setup Screen Format and Size
  15. SCREEN _NEWIMAGE(800, 700, 32)
  16.  
  17. '*** Setup and load Font Type, Format and Size
  18. fontpath$ = "Veranda.tff"
  19. font& = _LOADFONT(fontpath$, 16, "")
  20.  
  21.  
  22. 130 DIM B(7), P$(9), W$(7), J$(8), K$(4)
  23. 140 FOR I = 1 TO 7: B(I) = 0: NEXT
  24. 150 BA = 0: T9 = 0: R9 = 0: S = 0: O = 0: B1 = 0: B2 = 0: T = 0
  25. 160 Z1 = 1: Z2 = 1
  26. 170 PRINT "WELCOME TO EBBETT'S FIELD"
  27. 180 PRINT "WHAT DO YOU WANT TO CALL YOUR TEAM ";
  28. 190 INPUT A$
  29. 200 FOR I = 1 TO 7: READ W$(I): NEXT
  30. 210 FOR I = 1 TO 9: READ P$(I): NEXT
  31. 220 FOR I = 1 TO 4: READ K$(I): NEXT
  32. 230 FOR I = 1 TO 8: READ J$(I): NEXT
  33. 240 PRINT "FINE. THE "; A$; " NEED A MANAGER. WHAT'S YOUR NAME ";
  34. 250 INPUT B$
  35. 260 PRINT "WHAT DO YOU WANT TO CALL MY TEAM, "; B$;
  36. 270 INPUT C$
  37. 280 PRINT
  38. 290 PRINT "OPENING DAY, THE "; A$; " VERSUS THE "; C$
  39. 300 PRINT
  40. 310 PRINT "LET'S FLIP A COIN. THE WINNER IS THE HOME TEAM."
  41. 320 PRINT "HEADS OR TAILS ";
  42. 330 INPUT D$: D$ = UCASE$(D$)
  43. 340 IF D$ <> "HEADS" AND D$ <> "TAILS" THEN GOTO 320
  44. 350 FOR I = 1 TO TYM
  45. 360 Y = RND(1)
  46. 370 NEXT I
  47. 380 H = 1
  48. 390 Y = RND(1)
  49. 400 Y$ = "HEADS"
  50. 410 IF Y > .5 THEN Y$ = "TAILS"
  51. 420 IF D$ = Y$ THEN 490
  52. 430 H = 0
  53. 440 PRINT "YOU LOST THE TOSS. THE "; A$; " ARE UP FIRST."
  54. 450 PRINT
  55. 460 PRINT
  56. 470 A = 0
  57. 480 GOTO 610
  58. 490 PRINT "YOU WIN THE TOSS. "; A$; " TAKE THE FIELD, AND ";
  59. 500 PRINT C$; " ARE AT BAT."
  60. 510 A = 1
  61. 520 R9 = 0
  62. 530 T = T + 1
  63. 540 IF T < 18 THEN GOSUB 5140
  64. 550 IF T < 18 THEN 710
  65. 560 IF T > 18 THEN 590
  66. 570 GOSUB 3500
  67. 580 GOTO 710
  68. 590 GOSUB 3290
  69. 600 GOTO 710
  70. 610 REM START AN INNING - WE ARE OUT ON THE FIELD
  71. 620 T = T + 1
  72. 630 R9 = 0
  73. 640 IF T < 18 THEN 690
  74. 650 IF T > 18 THEN 680
  75. 660 GOSUB 3500
  76. 670 GOTO 690
  77. 680 GOSUB 3290
  78. 690 REM IF T>2 THEN 710
  79. 700 GOSUB 5070
  80. 710 S = 0: BA = 0
  81. 720 PRINT
  82. 730 IF O = 0 THEN PRINT "NO OUTS"
  83. 740 IF O = 1 THEN PRINT "THERE IS 1 OUT"
  84. 750 IF O > 1 THEN PRINT "THERE ARE "; O; " OUTS"
  85. 760 P = B(1) + B(2) + B(3)
  86. 770 IF P <> 3 THEN 800
  87. 780 PRINT "BASES LOADED"
  88. 790 GOTO 900
  89. 800 IF P = 0 THEN 900
  90. 810 Y$ = "RUNNER ON "
  91. 820 IF P > 1 THEN Y$ = "RUNNERS ON "
  92. 830 PRINT Y$;
  93. 840 IF B(1) = 0 THEN 870
  94. 850 PRINT "FIRST";
  95. 860 IF P > 1 THEN PRINT " AND ";
  96. 870 IF B(2) = 1 THEN PRINT "SECOND";
  97. 880 IF P > 1 AND B(1) = 0 THEN PRINT " AND ";
  98. 890 IF B(3) = 1 THEN
  99.     PRINT "THIRD"
  100.     PRINT " "
  101. 900 IF A = 0 THEN 920
  102. 910 GOTO 3030
  103. 920 PRINT "BATTER UP"
  104. 930 IF BA <> 3 OR S <> 2 THEN 960
  105. 940 PRINT "FULL COUNT"
  106. 950 GOTO 970
  107. 960 IF BA > 0 OR S > 0 THEN PRINT "THE COUNT IS "; BA; " AND "; S
  108. 970 PRINT
  109. 980 IF A = 1 THEN 3030
  110. 990 PRINT "WHAT WILL YOUR BATTER DO, "; B$;
  111. 1000 INPUT C
  112. 1010 IF C > 0 AND C < 5 THEN GOTO 1050
  113. 1020 PRINT "HUH?  ";
  114. 1030 GOSUB 5070
  115. 1040 GOTO 990
  116. 1050 Y2 = RND(1)
  117. 1060 IF Y2 < .56 OR Y2 > .5625 THEN GOTO 1120
  118. 1070 PRINT "WILD PITCH!"
  119. 1080 N = 1
  120. 1090 GOSUB 3540
  121. 1100 B(1) = 0
  122. 1110 GOTO 1210
  123. 1120 IF Y2 > .772 AND Y2 < .775 THEN 4880
  124. 1130 ON C GOTO 1140, 1450, 2600, 4450, 5500
  125. 1140 C = 1
  126. 1150 GOSUB 5240
  127. 1160 IF A = 0 THEN Z1 = Z1 + 1
  128. 1170 Y = RND(1)
  129. 1180 IF BA <> 3 OR S <> 0 THEN 1200
  130. 1190 IF Y < .7 THEN GOTO 1310 ELSE GOTO 1210
  131. 1200 IF Y < .5 THEN 1310
  132. 1210 BA = BA + 1
  133. 1220 Y = INT(RND(1) * 8 + 1)
  134. 1230 IF Y = 9 THEN 1220
  135. 1240 PRINT J$(Y); " - BALL "; BA
  136. 1250 IF BA <> 4 THEN 930
  137. 1260 PRINT "WALK"
  138. 1270 GOSUB 4950
  139. 1280 Y = RND(1)
  140. 1290 GOTO 710
  141. 1300 PRINT "HIGH POP - FOUL DOWN THE "; Y$; " FIELD LINE"
  142. 1310 S = S + 1
  143. 1320 IF C = 2 OR C = 5 THEN GOTO 1370
  144. 1330 Y = INT(RND(1) * 4 + 1)
  145. 1340 IF Y = 5 THEN 1330
  146. 1350 PRINT K$(Y); ", CALLED STRIKE "; S
  147. 1360 GOTO 1380
  148. 1370 PRINT "SWINGING STRIKE "; S
  149. 1380 IF C = 5 AND S <> 3 THEN 4450
  150. 1390 IF S <> 3 THEN 930
  151. 1400 PRINT "STRUCK OUT"
  152. 1410 O = O + 1
  153. 1420 IF O = 3 THEN 2850
  154. 1430 IF C = 5 THEN 4450
  155. 1440 GOTO 710
  156. 1450 C = 2
  157. 1460 Y = INT(RND(1) * 10 + 1)
  158. 1470 IF Y = 10 THEN 1450
  159. 1480 IF A = 0 THEN Z2 = Z2 + 1
  160. 1490 IF C <> 5 THEN GOSUB 5240
  161. 1500 IF S <> 2 AND Z2 / Z1 > 7 AND A = 0 THEN 1520
  162. 1510 IF S <> 2 OR Z2 / Z1 < 25 THEN 1590
  163. 1520 Y = INT(RND(1) * 20 + 1)
  164. 1530 IF Y > 7 THEN 1550
  165. 1540 ON Y GOTO 1610, 1310, 1310, 1310, 1310, 1680, 1610
  166. 1550 IF Y > 13 THEN 1570
  167. 1560 ON Y - 7 GOTO 1680, 1310, 1740, 1850, 1740, 1850
  168. 1570 IF Y > 18 THEN 1600
  169. 1580 ON Y - 13 GOTO 1980, 1980, 2040, 2570, 1640, 2570
  170. 1590 IF Y < 3 THEN 1310
  171. 1600 ON Y - 2 GOTO 1610, 1680, 1740, 1850, 1980, 2040, 2570
  172. 1610 PRINT "FOULED INTO THE STANDS-OUT OF PLAY"
  173. 1620 IF S <> 2 THEN S = S + 1
  174. 1630 GOTO 930
  175. 1640 Y = RND(1)
  176. 1650 Y$ = "RIGHT"
  177. 1660 IF Y < .5 THEN Y$ = "LEFT"
  178. 1670 GOTO 1620
  179. 1680 Y = INT(RND(1) * 20 + 1)
  180. 1690 IF Y > 18 THEN 1720
  181. 1700 PRINT "FOULED BACK INTO THE STANDS"
  182. 1710 GOTO 1620
  183. 1720 PRINT "POPPED IT UP - CAUGHT BY CATCHER"
  184. 1730 GOTO 1410
  185. 1740 PRINT "INFIELD GROUNDER"
  186. 1750 E2 = RND(1)
  187. 1760 IF E2 < .37 OR E2 > .41 THEN 1820
  188. 1770 PRINT "1 BASE ERROR!!"
  189. 1780 N = 1
  190. 1790 C = 4
  191. 1800 GOSUB 3540
  192. 1810 GOTO 710
  193. 1820 GOSUB 4100
  194. 1830 IF O = 3 THEN 2850
  195. 1840 GOTO 710
  196. 1850 PRINT "GROUNDER - COULD BE TROUBLE - "
  197. 1860 Y = RND(1)
  198. 1870 IF Y > .75 THEN 1950
  199. 1880 Y$ = "UP THE MIDDLE"
  200. 1890 IF Y < .5 THEN Y$ = "THROUGH THE HOLE INTO RIGHT FIELD"
  201. 1900 IF Y < .25 THEN Y$ = "THROUGH THE HOLE INTO LEFT FIELD"
  202. 1910 PRINT "A SINGLE "; Y$; "!"
  203. 1920 N = 1
  204. 1930 GOSUB 3540
  205. 1940 GOTO 710
  206. 1950 PRINT "INFIELDER UP WITH IT!"
  207. 1960 GOSUB 4800
  208. 1970 IF O = 3 THEN GOTO 2850 ELSE GOTO 710
  209. 1980 Y = RND(1)
  210. 1990 Y$ = "LEFT"
  211. 2000 IF Y < .6 THEN Y$ = "CENTER"
  212. 2010 IF Y < .3 THEN Y$ = "RIGHT"
  213. 2020 PRINT "FLY-OUT TO "; Y$; " FIELD"
  214. 2030 GOTO 1410
  215. 2040 Z = RND(1)
  216. 2050 Y$ = "CENTER"
  217. 2060 IF Z < .6 THEN Y$ = "RIGHT"
  218. 2070 IF Z < .3 THEN Y$ = "LEFT"
  219. 2080 PRINT "LONG FLY TO DEEP "; Y$; " FIELD - LOOKS GOOD! "
  220. 2090 Z = RND(1)
  221. 2100 IF Z < .9 THEN 2130
  222. 2110 PRINT Y$; "FIELDER CAUGHT IT AT THE WALL!"
  223. 2120 GOTO 2180
  224. 2130 IF Z < .8 THEN 2160
  225. 2140 PRINT "A DIVING CATCH!"
  226. 2150 GOTO 2180
  227. 2160 IF Z < .7 THEN 2290
  228. 2170 PRINT Y$; "FIELDER CAUGHT IT ON THE WARNING TRACK!"
  229. 2180 O = O + 1
  230. 2190 IF O = 3 THEN 2850
  231. 2200 FOR I = 3 TO 1 STEP -1
  232. 2210 IF B(I) = 1 THEN 2240
  233. 2220 NEXT I
  234. 2230 GOTO 710
  235. 2240 B(I + 1) = B(I)
  236. 2250 B(I) = 0
  237. 2260 PRINT "LEAD RUNNER TAGS UP - AND ADVANCES 1 BASE!"
  238. 2270 GOSUB 3830
  239. 2280 GOTO 710
  240. 2290 IF Z < .5 THEN 2360
  241. 2300 PRINT "BATTER HOLDS WITH A SINGLE."
  242. 2310 N = 2
  243. 2320 GOSUB 3540
  244. 2330 B(2) = 0
  245. 2340 B(1) = 1
  246. 2350 GOTO 710
  247. 2360 IF Z < .15 THEN 2480
  248. 2370 PRINT "DOUBLE!"
  249. 2380 Y = RND(1)
  250. 2390 IF Y > .5 THEN 2430
  251. 2400 N = 2
  252. 2410 GOSUB 3540
  253. 2420 GOTO 710
  254. 2430 N = 3
  255. 2440 GOSUB 3540
  256. 2450 B(3) = 0
  257. 2460 B(2) = 1
  258. 2470 GOTO 710
  259. 2480 IF Z < .1 THEN 2530
  260. 2490 PRINT "TRIPLE!"
  261. 2500 N = 3
  262. 2510 GOSUB 3540
  263. 2520 GOTO 710
  264. 2530 PRINT "IT'S OVER THE WALL -- A H*O*M*E R*U*N!!!"
  265. 2540 N = 4
  266. 2550 GOSUB 3540
  267. 2560 GOTO 710
  268. 2570 Y = INT(RND(1) * 7 + 1)
  269. 2580 PRINT "LINED OUT TO "; P$(Y)
  270. 2590 GOTO 1410
  271. 2600 GOSUB 5240
  272. 2610 PRINT "BATTER BUNTS... "
  273. 2620 Y = RND(1)
  274. 2630 IF Y < .6 THEN 2750
  275. 2640 IF B(3) = 0 THEN 2660
  276. 2650 IF Y < .8 THEN 2830
  277. 2660 PRINT "THROWN OUT AT FIRST."
  278. 2670 O = O + 1
  279. 2680 IF O = 3 THEN 2850
  280. 2690 IF B(1) + B(2) + B(3) = 0 THEN 710
  281. 2700 PRINT "SACRIFICE - ";
  282. 2710 N = 1
  283. 2720 GOSUB 3540
  284. 2730 B(1) = 0
  285. 2740 GOTO 710
  286. 2750 IF Y < .2 THEN 2830
  287. 2760 IF Y < .4 THEN 2790
  288. 2770 PRINT "BATTER MISSES PITCH"
  289. 2780 GOTO 1310
  290. 2790 PRINT "BEATS IT OUT! SINGLE!"
  291. 2800 N = 1
  292. 2810 GOSUB 3540
  293. 2820 GOTO 710
  294. 2830 GOSUB 4100
  295. 2840 IF O <> 3 THEN 710
  296. 2850 PRINT "3 OUTS. THE SIDE IS RETIRED";
  297. 2860 I = B(1) + B(2) + B(3)
  298. 2870 IF I = 0 THEN PRINT "."
  299. 2880 IF I = 1 THEN PRINT ", LEAVING 1 MAN ON BASE"
  300. 2890 IF I > 1 THEN PRINT ", LEAVING "; I; " MEN ON BASE"
  301. 2900 PRINT
  302. 2910 PRINT
  303. 2920 PRINT "*************"
  304. 2930 D = T / 2 - INT(T / 2)
  305. 2940 PRINT "AFTER ";
  306. 2950 IF T > 1 THEN PRINT INT(T / 2); " ";
  307. 2960 IF D > .3 THEN PRINT "1/2 ";
  308. 2970 Y$ = "INNINGS"
  309. 2980 IF T < 3 THEN Y$ = "INNING"
  310. 2990 PRINT Y$; " OF PLAY, THE SCORE IS"
  311. 3000 GOSUB 3960
  312. 3010 O = 0: B(1) = 0: B(2) = 0: B(3) = 0
  313. 3020 IF A = 0 THEN GOTO 510 ELSE GOTO 470
  314. 3030 REM MY TEAM IS AT BAT
  315. 3040 Y = RND(1)
  316. 3050 IF B(1) + B(2) + B(3) = 0 THEN 3140
  317. 3060 REM IF O=2 AND S=2 AND B=3 THEN 4850
  318. 3070 IF B(3) = 1 THEN 3110
  319. 3080 IF B(2) = 0 THEN 3100
  320. 3090 IF .45 < Y AND .46 > Y THEN 4450
  321. 3100 IF .45 < Y AND .47 > Y THEN 4450
  322. 3110 IF O = 2 THEN 3140
  323. 3120 IF O < 2 AND Y < .333 AND B(3) = 1 THEN 2600
  324. 3130 IF .45 < Y AND .55 > Y THEN 2600
  325. 3140 IF S = 0 THEN 3240
  326. 3150 IF BA <> 3 THEN GOTO 3180
  327. 3160 IF Y < .6 THEN GOTO 1450
  328. 3170 GOTO 1140
  329. 3180 IF Y > .3 THEN GOTO 1450
  330. 3190 IF S <> 2 THEN GOTO 1140
  331. 3200 IF BA = 0 AND Y < .1 THEN GOTO 1140
  332. 3210 IF BA = 0 THEN GOTO 1450
  333. 3220 IF Y < .2 THEN GOTO 1140
  334. 3230 GOTO 1450
  335. 3240 IF BA = 3 THEN GOTO 3270
  336. 3250 IF Y < .6 THEN GOTO 1140
  337. 3260 GOTO 1450
  338. 3270 IF Y < .9 THEN GOTO 1140
  339. 3280 GOTO 1450
  340. 3290 IF T <> 19 THEN GOTO 3330
  341. 3300 IF R1 <> R2 THEN GOTO 3340
  342. 3310 PRINT
  343. 3320 PRINT "*** GOING INTO EXTRA INNINGS ***"
  344. 3330 IF R1 = R2 THEN RETURN
  345. 3340 IF (T - 1) / 2 <> INT(T - 1) / 2 THEN RETURN
  346. 3350 PRINT "THE BALLGAME IS OVER."
  347. 3360 PRINT "*************"
  348. 3370 PRINT "FINAL SCORE:"
  349. 3380 T9 = 1
  350. 3390 GOSUB 3960
  351. 3400 IF R1 > R2 THEN 3470
  352. 3410 PRINT "NICE TRY, "; B$
  353. 3420 PRINT "YOU SHOULD KNOW BETTER THAN TO TRY TO"
  354. 3430 PRINT "OUT-MANAGE A COMPUTER.  MAYBE BASEBALL"
  355. 3440 PRINT "JUST ISN'T YOUR SPORT...WHY DON'T YOU TRY GOLF?"
  356. 3450 REM CHAIN GOLF
  357. 3460 STOP
  358. 3470 PRINT "CONGRATULATIONS, "; B$
  359. 3480 PRINT "YOU'VE BEATEN ME, BUT I WILL HAVE MY REVENGE."
  360. 3490 STOP
  361. 3500 REM 9TH INNING
  362. 3510 IF A = 0 THEN 3530
  363. 3520 IF R2 > R1 THEN GOTO 3350 ELSE RETURN
  364. 3530 IF R1 > R2 THEN GOTO 3350 ELSE RETURN
  365. 3540 REM ADVANCE N BASES (SET N BEFORE GOSUB)
  366. 3550 N2 = B(1) + B(2) + B(3)
  367. 3560 IF C = 5 THEN N = N + 1
  368. 3570 N3 = N
  369. 3580 IF N2 = 0 THEN 3650
  370. 3590 REM FIND LAST RUNNER: MAKE SURE HE ISN‘T TRYING TO ADVANCE
  371. 3600 REM PAST HOME PLATE.
  372. 3610 FOR I = 1 TO 3
  373. 3620 IF B(I) = 1 THEN 3640
  374. 3630 NEXT I
  375. 3640 IF 4 - I < N THEN N3 = 4 - I
  376. 3650 FOR I = 3 + N TO N + 1 STEP -1
  377. 3660 B(I) = B(I - N)
  378. 3670 NEXT I
  379. 3680 B(N) = 1
  380. 3690 IF N = 1 THEN 3740
  381. 3700 FOR P = 1 TO 3
  382. 3710 IF (N - P) > 1 THEN B(N - P) = 0
  383. 3720 IF (N - P) <= 1 THEN B(1) = 0
  384. 3730 NEXT P
  385. 3740 FOR P = 1 TO 7
  386. 3750 IF P = N THEN 3780
  387. 3760 NEXT P
  388. 3770 GOTO 3830
  389. 3780 IF C = 4 OR N2 = 0 THEN 3830
  390. 3790 Y$ = "RUNNERS ADVANCE "
  391. 3800 IF N2 = 1 THEN Y$ = "RUNNER ADVANCES "
  392. 3810 PRINT Y$; N3;
  393. 3820 IF N3 = 1 THEN
  394.     PRINT " BASE"
  395.     PRINT " BASES"
  396. 3830 IF B(4) + B(5) + B(6) + B(7) = 0 THEN RETURN
  397. 3840 REM AT LEAST 1 RUN HAS SCORED.
  398. 3850 N2 = B(4) + B(5) + B(6) + B(7)
  399. 3860 IF A = 0 THEN 3890
  400. 3870 R2 = R2 + N2
  401. 3880 GOTO 3900
  402. 3890 R1 = R1 + N2
  403. 3900 B(4) = 0: B(5) = 0: B(6) = 0: B(7) = 0
  404. 3910 IF N2 = 1 THEN PRINT "** 1 RUN SCORED"
  405. 3920 IF N2 > 1 THEN PRINT "** "; N2; " RUNS SCORED"
  406. 3930 PRINT
  407. 3940 PRINT
  408. 3950 PRINT "******** NEW SCORE:"
  409. 3960 IF H = 1 THEN 4000
  410. 3970 IF LEN(A$) > LEN(C$) THEN PRINT A$; TAB(LEN(A$) + 3); R1
  411. 3980 IF LEN(A$) <= LEN(C$) THEN PRINT A$; TAB(LEN(C$) + 3); R1
  412. 3990 IF H = 1 THEN 4030
  413. 4000 IF LEN(A$) > LEN(C$) THEN PRINT C$; TAB(LEN(A$) + 3); R2
  414. 4010 IF LEN(A$) <= LEN(C$) THEN PRINT C$; TAB(LEN(C$) + 3); R2
  415. 4020 IF H = 1 THEN 3970
  416. 4030 PRINT "*************"
  417. 4040 PRINT
  418. 4050 PRINT
  419. 4060 IF T9 = 1 THEN 4090
  420. 4070 IF A = 1 AND T > 17 AND INT(T / 2) = T / 2 AND R2 > R1 THEN 3350
  421. 4080 IF A = 0 AND T > 17 AND INT(T / 2) = T / 2 AND R1 > R2 THEN 3350
  422. 4090 RETURN
  423. 4100 REM LEAD RUNNER OUT (FIELDER‘S CHOICE THEN ONE BASE ADVANCE)
  424. 4110 N = 1
  425. 4120 I = 4
  426. 4130 IF B(4) = 0 AND B(3) = 1 AND B(2) = 1 AND B(1) = 1 THEN 4220
  427. 4140 I = 3
  428. 4150 IF B(3) = 0 AND B(2) = 1 AND B(1) = 1 THEN 4220
  429. 4160 I = 2
  430. 4170 IF B(2) = 0 AND B(1) = 1 THEN 4220
  431. 4180 REM NO ONE FORCED
  432. 4190 O = O + 1
  433. 4200 PRINT "BATTER THROWN OUT"
  434. 4210 RETURN
  435. 4220 B(I - 1) = 0
  436. 4230 F = RND(1)
  437. 4240 IF O = 2 OR F > .3 THEN 4290
  438. 4250 O = O + 2
  439. 4260 PRINT "DOUBLE PLAY!"
  440. 4270 IF O = 3 THEN RETURN
  441. 4280 GOTO 4910
  442. 4290 O = O + 1
  443. 4300 PRINT "RUNNER ON BASE "; I - 1; " IS OUT ON FIELDER'S CHOICE"
  444. 4310 IF O = 3 THEN RETURN
  445. 4320 GOSUB 3540
  446. 4330 RETURN
  447. 4340 REM FORCED RUNNERS ADVANCE 1 BASE, OTHERS HOLD
  448. 4350 FOR I = 1 TO 3
  449. 4360 IF B(I) = 0 THEN 4400
  450. 4370 NEXT I
  451. 4380 N = 1
  452. 4390 GOTO 3540
  453. 4400 REM NO ONE ON BASE I
  454. 4410 FOR I2 = I TO 1 STEP -1
  455. 4420 B(I2) = 1
  456. 4430 NEXT I2
  457. 4440 RETURN
  458. 4450 REM LEAD RUNNER STEALS
  459. 4460 FOR I = 3 TO 1 STEP -1
  460. 4470 IF B(I) = 1 THEN 4510
  461. 4480 NEXT I
  462. 4490 PRINT "NO ONE ON BASE, DUMMY!"
  463. 4500 GOTO 990
  464. 4510 REM I IS LEAD RUNNER‘S BASE
  465. 4520 IF C <> 5 THEN GOSUB 5240
  466. 4530 IF RND(1) / I < .3 THEN 4680
  467. 4540 IF B(1) + B(2) + B(3) > 1 THEN 4570
  468. 4550 PRINT "RUNNER STEALS A BASE"
  469. 4560 GOTO 4580
  470. 4570 PRINT "RUNNERS STEAL A BASE"
  471. 4580 N = 1
  472. 4590 C2 = C
  473. 4600 C = 4
  474. 4610 GOSUB 3540
  475. 4620 C = C2
  476. 4630 B(1) = 0
  477. 4640 IF C = 5 AND S <> 3 THEN 930
  478. 4650 IF C = 5 THEN 710
  479. 4660 Y = RND(1)
  480. 4670 IF Y > .5 THEN GOTO 1210 ELSE GOTO 1310
  481. 4680 PRINT "RUNNER THROWN OUT STEALING"
  482. 4690 O = O + 1
  483. 4700 B(I) = 0
  484. 4710 IF O = 3 THEN GOTO 2850
  485. 4720 N = 1
  486. 4730 GOSUB 3540
  487. 4740 B(1) = 0
  488. 4750 IF C = 5 AND S <> 3 THEN GOTO 930
  489. 4760 IF C = 5 THEN GOTO 710
  490. 4770 Y = RND(1)
  491. 4780 IF BA = 3 THEN GOTO 1310
  492. 4790 IF Y > .5 THEN GOTO 1210 ELSE GOTO 1310
  493. 4800 REM RUNNERS ADVANCE ONE BASE, BATTER THROWN OUT
  494. 4810 N = 1
  495. 4820 IF O = 2 THEN 4850
  496. 4830 GOSUB 3540
  497. 4840 B(1) = 0
  498. 4850 O = O + 1
  499. 4860 PRINT "BATTER THROWN OUT"
  500. 4870 RETURN
  501. 4880 PRINT "HIT BATSMAN (OUCH!)"
  502. 4890 GOSUB 4950
  503. 4900 GOTO 710
  504. 4910 N = 1
  505. 4920 GOSUB 3540
  506. 4930 B(1) = 0
  507. 4940 RETURN
  508. 4950 REM BATTER WALKED
  509. 4960 FOR I = 1 TO 3
  510. 4970 IF B(I) = 0 THEN 5010
  511. 4980 NEXT I
  512. 4990 N = 1
  513. 5000 GOTO 3540
  514. 5010 IF I = 1 THEN 5050
  515. 5020 FOR I0 = I TO 2 STEP -1
  516. 5030 B(I0) = B(I0 - 1)
  517. 5040 NEXT I0
  518. 5050 B(1) = 1
  519. 5060 RETURN
  520. 5070 PRINT "WHEN YOUR'RE UP:"
  521. 5080 PRINT "1-BATTER TAKES PITCH"
  522. 5090 PRINT "2-BATTER SWINGS AWAY"
  523. 5100 PRINT "3-BATTER BUNTS"
  524. 5110 PRINT "4-LEAD RUNNER STEALS"
  525. 5120 REM PRINT "5-HIT AND RUN"
  526. 5130 RETURN
  527. 5140 REM PITCHING ROUTINE
  528. 5150 PRINT "YOUR PITCHER MAY THROW:"
  529. 5160 PRINT "1-FAST BALL"
  530. 5170 PRINT "2-CURVE"
  531. 5180 PRINT "3-SLIDER"
  532. 5190 PRINT "4-SINKER"
  533. 5200 PRINT "5-CHANGE-UP"
  534. 5210 PRINT "6-KNUCKLEBALL"
  535. 5220 PRINT "7-SCREWBALL"
  536. 5230 RETURN
  537. 5240 IF A = 0 THEN 5370
  538. 5250 IF R9 = 1 THEN 5300
  539. 5260 PRINT "WHAT WILL YOUR PITCHER THROW? ";
  540. 5270 INPUT W
  541. 5280 IF W < 0 THEN R9 = 1
  542. 5290 IF R9 = 0 THEN GOTO 5320 ELSE PRINT "RANDOM PITCHES FOR REST OF INNING"
  543. 5300 W = INT(RND(1) * 8 + 1)
  544. 5310 IF W = 8 THEN 5300
  545. 5320 IF W > 0 AND W < 8 THEN 5470
  546. 5330 PRINT "UH-UH, "; B$; ".  ";
  547. 5340 GOSUB 5150
  548. 5350 PRINT
  549. 5360 GOTO 5260
  550. 5370 REM I MUST SELECT A PITCH
  551. 5380 W1 = RND(1)
  552. 5390 W = 1
  553. 5400 IF W1 < .75 THEN W = 2
  554. 5410 IF W1 < .55 THEN W = 3
  555. 5420 IF W1 < .45 THEN W = 4
  556. 5430 IF W1 < .35 THEN W = 5
  557. 5440 IF W1 < .15 THEN W = 6
  558. 5450 IF W1 < .08 THEN W = 7
  559. 5460 GOTO 5470
  560. 5470 PRINT W$(W);
  561. 5480 PRINT "...";
  562. 5490 RETURN
  563. 5500 REM HIT-AND-RUN
  564. 5510 IF B(1) + B(2) + B(3) = 0 THEN 4490
  565. 5520 GOSUB 5240
  566. 5530 PRINT "HIT AND RUN!"
  567. 5540 C = 5
  568. 5550 GOTO 1460
  569. 5560 DATA FAST BALL,CURVE BALL,SLIDER,SINKER,CHANGE-UP,KNUCKLEBALL
  570. 5570 DATA SCREWBALL
  571. 5580 DATA RIGHT,LEFT,CENTER,FIRST,SECOND,THIRD,SHORTSTOP,PITCHER,CATCHER
  572. 5590 DATA RIGHT OVER THE PLATE,CAUGHT THE OUTSIDE CORNER
  573. 5600 DATA OVER THE INSIDE CORNER,OVER AT THE KNEES
  574. 5610 DATA HIGH,LOW,INSIDE,OUTSIDE,HIGH AND TIGHT,LOW AND OUTSIDE
  575. 5620 DATA LOW AND INSIDE,HIGH AND OUTSIDE
  576. 5630 END
  577.  
* Verdana.ttf (Filesize: 181.82 KB, Downloads: 172)
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: BASEBALL - TEXT VERSION
« Reply #1 on: July 07, 2020, 10:40:01 pm »
Wow! Great job! Reminds me of using line numbers in the 80's with Apple Basic and Texas Instruments. I should try to dig up old games from the magazine COMPUTE! to see if I could convert any. This is a fun game. Thanks! Oh, if anyone wants to look themselves, all of the COMPUTE! issues are in PDF form on archive.org

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: BASEBALL - TEXT VERSION
« Reply #2 on: July 07, 2020, 10:44:38 pm »
Oh one thing I did notice, is that you don't have any _LIMIT commands on it. QB64 uses a lot of processing power if you don't add any _LIMIT commands on programs. They slow it down. For example, a lot of programs could have _LIMIT 300 or so. Some more, some less depending how fast you want your program to go or how much processing power it needs.

Here is the info on that command if you are interested: http://www.qb64.org/wiki/LIMIT

Offline George McGinn

  • Global Moderator
  • Forum Regular
  • Posts: 210
    • View Profile
    • Resume
Re: BASEBALL - TEXT VERSION
« Reply #3 on: July 08, 2020, 07:26:25 pm »
Thanks SierraKen,


I’m glad that you enjoyed the game, I do too.


I usually Forget to do that whenever I convert an old program to QB64, as most of the time I convert the program to my iPad using techBASIC and then once I get it working there I bring it over to QB64 where I generally have to make minor changes but I do forget to put the _LIMIT in it.

TechBASIC is based on the Apple IIgs GSoft BASIC.
____________________________________________________________________
George McGinn
Theoretical/Applied Computer Scientist
Member: IEEE, IEEE Computer Society
Technical Council on Software Engineering
IEEE Standards Association
American Association for the Advancement of Science (AAAS)

Offline SierraKen

  • Forum Resident
  • Posts: 1454
    • View Profile
Re: BASEBALL - TEXT VERSION
« Reply #4 on: July 08, 2020, 10:06:14 pm »
Awesome :). Lots of cool stuff is probably still out there online to dig up. Have you looked into the 1990's "All Basic Code - ABC" snippets? Back then people sent their QBasic and other language code to this one guy and he made a program to see and copy/paste from. I think all of it is still out there. I saw it about a year ago somewhere.

Here it is. They have reformatted it all to copy/paste straight from the website: http://www.qbasicnews.com/abc/
« Last Edit: July 08, 2020, 10:12:16 pm by SierraKen »