Author Topic: Updating old BASIC games  (Read 3582 times)

0 Members and 1 Guest are viewing this topic.

Offline johnblood

  • Newbie
  • Posts: 15
    • View Profile
Updating old BASIC games
« on: March 02, 2021, 01:57:58 pm »
So, I was looking through Lobste.rs, and I came across something interesting. Jeff Atwood, creator of StackExchange and Discourse, created a repo (https://github.com/coding-horror/basic-computer-games) with almost 100 BASIC games that he wants to convert to other popular languages (including Java, Python, Ruby, Perl, Pascal, C# and JavaScript). Before I came up with my current project, I was planning to learn BASIC by converting old BASIC games to QB64. Unfortunately, I could not find clear pictures. This repo has all the games nicely typed out. Something else to play with. I hope someone else enjoys/finds this useful.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Updating old BASIC games
« Reply #1 on: March 02, 2021, 02:46:16 pm »
oh yeah, typed up for copy/paste, is nice.

First one I checked:
Code: QB64: [Select]
  1. 10 PRINT TAB(26);"ACEY DUCEY CARD GAME"
  2. 20 PRINT TAB(15);"CREATIVE COMPUTING  MORRISTOWN, NEW JERSEY"
  3. 30 PRINT"ACEY-DUCEY IS PLAYED IN THE FOLLOWING MANNER "
  4. 40 PRINT"THE DEALER (COMPUTER) DEALS TWO CARDS FACE UP"
  5. 50 PRINT"YOU HAVE AN OPTION TO BET OR NOT BET DEPENDING"
  6. 60 PRINT"ON WHETHER OR NOT YOU FEEL THE CARD WILL HAVE"
  7. 70 PRINT"A VALUE BETWEEN THE FIRST TWO."
  8. 80 PRINT"IF YOU DO NOT WANT TO BET, INPUT A 0"
  9. 100 N=100
  10. 110 Q=100
  11. 120 PRINT "YOU NOW HAVE";Q;"DOLLARS."
  12. 130 PRINT
  13. 140 GOTO 260
  14. 210 Q=Q+M
  15. 220 GOTO 120
  16. 240 Q=Q-M
  17. 250 GOTO 120
  18. 260 PRINT"HERE ARE YOUR NEXT TWO CARDS: "
  19. 270 A=INT(14*RND(1))+2
  20. 280 IF A<2 THEN 270
  21. 290 IF A>14 THEN 270
  22. 300 B=INT(14*RND(1))+2
  23. 310 IF B<2 THEN 300
  24. 320 IF B>14 THEN 300
  25. 330 IF A>=B THEN 270
  26. 350 IF A<11 THEN 400
  27. 360 IF A=11 THEN 420
  28. 370 IF A=12 THEN 440
  29. 380 IF A=13 THEN 460
  30. 390 IF A=14 THEN 480
  31. 400 PRINT A
  32. 410 GOTO 500
  33. 420 PRINT"JACK"
  34. 430 GOTO 500
  35. 440 PRINT"QUEEN"
  36. 450 GOTO 500
  37. 460 PRINT"KING"
  38. 470 GOTO 500
  39. 480 PRINT"ACE"
  40. 500 IF B<11 THEN 550
  41. 510 IF B=11 THEN 570
  42. 520 IF B=12 THEN 590
  43. 530 IF B=13 THEN 610
  44. 540 IF B=14 THEN 630
  45. 550 PRINT B
  46. 560 GOTO 650
  47. 570 PRINT"JACK"
  48. 580 GOTO 650
  49. 590 PRINT"QUEEN"
  50. 600 GOTO 650
  51. 610 PRINT"KING"
  52. 620 GOTO 650
  53. 630 PRINT"ACE"
  54. 640 PRINT
  55. 650 PRINT
  56. 660 INPUT"WHAT IS YOUR BET";M
  57. 670 IF M<>0 THEN 680
  58. 675 PRINT"CHICKEN!!"
  59. 676 PRINT
  60. 677 GOTO 260
  61. 680 IF M<=Q THEN 730
  62. 690 PRINT"SORRY, MY FRIEND, BUT YOU BET TOO MUCH."
  63. 700 PRINT"YOU HAVE ONLY ";Q;" DOLLARS TO BET."
  64. 710 GOTO 650
  65. 730 C=INT(14*RND(1))+2
  66. 740 IF C<2 THEN 730
  67. 750 IF C>14 THEN 730
  68. 760 IF C<11 THEN 810
  69. 770 IF C=11 THEN 830
  70. 780 IF C=12 THEN 850
  71. 790 IF C=13 THEN 870
  72. 800 IF C=14 THEN 890
  73. 810 PRINT C
  74. 820 GOTO 910
  75. 830 PRINT"JACK"
  76. 840 GOTO 910
  77. 850 PRINT"QUEEN"
  78. 860 GOTO 910
  79. 870 PRINT"KING"
  80. 880 GOTO 910
  81. 890 PRINT "ACE"
  82. 900 PRINT
  83. 910 IF C>A THEN 930
  84. 920 GOTO 970
  85. 930 IF C>=B THEN 970
  86. 950 PRINT"YOU WIN!!!"
  87. 960 GOTO 210
  88. 970 PRINT"SORRY, YOU LOSE"
  89. 980 IF M<Q THEN 240
  90. 990 PRINT
  91. 1000 PRINT
  92. 1010 PRINT"SORRY, FRIEND, BUT YOU BLEW YOUR WAD."
  93. 1020 INPUT"TRY AGAIN (YES OR NO)";A$
  94. 1030 IF A$="YES" THEN 110
  95. 1040 PRINT"O.K., HOPE YOU HAD FUN!"
  96. 1050 END
  97.  

And it works and I get a good laugh on 2nd hand! (see attached)

@johnblood

I did this with Eliza and Tiny Basic back in 2014 to get up to speed with sB (SmallBASIC interpreter before MS made their version Small Basic.)
« Last Edit: March 02, 2021, 03:11:09 pm by bplus »

Offline johnno56

  • Forum Resident
  • Posts: 1270
  • Live long and prosper.
    • View Profile
Re: Updating old BASIC games
« Reply #2 on: March 02, 2021, 03:10:56 pm »
I have quite a few "ebooks" with "old" games.... David Ahl programs were among my fist programs.... I still have an actual hard copy of his 1978 book....

Line numbers and text. The many, many, many hours of keying in those listings.... All those years ago... and I 'still' can't type... lol  There is something said for those old games. The ability to stir the imagination. Simplicity of plain text and fitting them into limited memory. 4, 16, 32 and 64k of ram.

I only hope that, during the "conversion", that the "feel" of the games are not lost.

"I hope someone else enjoys / finds this useful."... You're "preaching to the choir."

J
Logic is the beginning of wisdom.

Offline johnblood

  • Newbie
  • Posts: 15
    • View Profile
Re: Updating old BASIC games
« Reply #3 on: March 02, 2021, 03:46:00 pm »

I only hope that, during the "conversion", that the "feel" of the games are not lost.


I hope so. I may fork the repo and just convert the BASIC to QB64 for practice.

@bplus  :)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Updating old BASIC games
« Reply #4 on: March 03, 2021, 02:02:16 pm »
@johnblood

You know I think it would be easier just to start over from scratch once you get the gist of what the game does.

Here it took about an hour to get the game going and another 2/3 hour to make pretty.
Code: QB64: [Select]
  1. _Title "Acey Ducey" 'b+ 2021-03-03 see how long it takes to write game from scratch 12:15
  2. ' 1 hr to get it going + 2/3 to make it pretty,
  3. ' thing is there is no end to making pretty, I could add comma's to player's total for next beautification.
  4. Cards$ = "23456789XJQKA" ' I guess Ace is highest
  5. player& = 100 ' player
  6. round& = 0 ' round
  7.     round& = round& + 1
  8.     CPR 2, "Acey Ducey   Round #" + ts$(round&)
  9.     card1& = Int(Rnd * 13) + 1 ' not exactly playing from a full deck here, could draw 5 aces in a row
  10.     card2& = Int(Rnd * 13) + 1 ' ok it's like 13 cards shuffled before each draw
  11.     cardWinLose& = Int(Rnd * 13) + 1
  12.     CPR 5, "First Card: " + Mid$(Cards$, card1&, 1)
  13.     CPR 6, "  2nd Card: " + Mid$(Cards$, card2&, 1)
  14.     CPR 8, "Player you have: $" + ts$(player&)
  15.     CPR 10, " Of that amount, please enter how much you would like to bet"
  16.     Locate 11, 11
  17.     Input " that the next card is = or between those two cards"; bet&
  18.     If bet& > player& Then bet& = player&
  19.     CPR 13, " Win | Lose Card: " + Mid$(Cards$, cardWinLose&, 1)
  20.     If cardWinLose& > card1& And cardWinLose& > card2& Or cardWinLose& < card1& And cardWinLose& < card2& Then
  21.         CPR 15, "Player Lost $" + ts$(bet&)
  22.         player& = player& - bet&
  23.     Else
  24.         CPR 15, "Player Won $" + ts$(bet&)
  25.         player& = player& + bet&
  26.     End If
  27.     CPR 20, "Zzz... press any"
  28.     Sleep
  29.     _KeyClear
  30.     Cls
  31. Loop Until player& <= 0
  32. CPR 23, " Player you are bankrupt, good day!"
  33.  
  34. Sub CPR (Row, S$) 'Center Print Row
  35.     Locate Row, (_Width - Len(S$)) / 2: Print S$
  36. Function ts$ (N As Long)
  37.     ts$ = _Trim$(Str$(N))
  38.  
  39.  

I found a really cool loop hole that will make you a ton of fake money legally (sorta).

  [ You are not allowed to view this attachment ]  

Today's quiz, how did I do that? ;-))

Edit: fixed wording
« Last Edit: March 03, 2021, 02:10:50 pm by bplus »

Offline johnblood

  • Newbie
  • Posts: 15
    • View Profile
Re: Updating old BASIC games
« Reply #5 on: March 03, 2021, 02:13:58 pm »
You know I think it would be easier just to start over from scratch once you get the gist of what the game does.

Here it took about an hour to get the game going and another 2/3 hour to make pretty.

My goal of eating up your free time is working. Ha-ha-ha-ah-ha.

Joking aside. Nice job. I'm not at that level yet. :)

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Updating old BASIC games
« Reply #6 on: March 03, 2021, 02:16:56 pm »
My goal of eating up your free time is working. Ha-ha-ha-ah-ha.

Joking aside. Nice job. I'm not at that level yet. :)

Man this stuff is fun way to eat time! I think this will be next app for SB1 Interpreter :)

Plus you might pick up hints for coding, seeing how others might convert old code or start from scratch and do same functionally.

« Last Edit: March 03, 2021, 02:21:47 pm by bplus »

Offline johnblood

  • Newbie
  • Posts: 15
    • View Profile
Re: Updating old BASIC games
« Reply #7 on: March 03, 2021, 02:41:07 pm »
I think this will be next app for SB1 Interpreter :)

@bplus  What's that?
« Last Edit: March 03, 2021, 02:47:27 pm by johnblood »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: Updating old BASIC games
« Reply #8 on: March 03, 2021, 04:20:33 pm »
SB1 is my idea of what GW Basic would look like wo line numbers and a few less "" for strings, except even GW had better string evaluator.

I don't think it had ElseIF?

The project is in Programs board under name Shorthand Basic. If you are just getting up to speed with QB64, save it for later because it might mess with learning QB64 basic's first.