An updated version of the classic "Basic Computer Games" book, with well-written examples in a variety of common programming languages
Go to file
2024-06-02 13:34:40 -07:00
.github/workflows check all rust build 2022-06-07 23:43:22 +08:00
01_Acey_Ducey Merge pull request #894 from GKnirps/cargo_lock 2023-08-28 16:14:36 -07:00
02_Amazing Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
03_Animal Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
04_Awari Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
05_Bagels Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
06_Banner Revert "Port 06_Banner to Rust" 2023-11-26 10:11:24 +08:00
07_Basketball removed uneeded line 2023-04-20 12:33:38 -05:00
08_Batnum Port 08_Batnum to Rust 2023-12-02 03:39:54 +08:00
09_Battle Port 09_Battle to Rust 2023-12-29 06:38:02 +08:00
10_Blackjack Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
11_Bombardment Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
12_Bombs_Away Port 12_Bombs_Away to Rust 2024-04-19 20:03:25 +08:00
13_Bounce small fixes to make code look better 2023-04-21 00:37:09 -05:00
14_Bowling Implemented 14_Bowling for MiniScript. 2023-07-20 21:48:12 -07:00
15_Boxing Added MiniScript version of 15_Boxing. 2023-07-23 21:30:37 -07:00
16_Bug Add print gap 2022-07-14 00:41:36 +10:00
17_Bullfight Added MiniScript version of 17_Bullfight. 2023-07-25 09:08:00 -07:00
18_Bullseye Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
19_Bunny Evenwins (Python): Refactored 2022-04-02 09:01:47 +02:00
20_Buzzword Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
21_Calendar Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
22_Change Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
23_Checkers Added MiniScript version of 23_Checkers. 2023-07-26 15:07:15 -07:00
24_Chemist Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
25_Chief Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
26_Chomp Add inner game loop 2022-07-17 18:53:29 +10:00
27_Civil_War Added MiniScript version of 27_Civil_War. 2023-07-30 21:18:59 -07:00
28_Combat Added MiniScript version of 28_Combat. 2023-07-31 08:04:25 -07:00
29_Craps Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
30_Cube Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
31_Depth_Charge Python: Add type annotations 2022-04-02 09:30:56 +02:00
32_Diamond Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
33_Dice Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
34_Digits Added MiniScript version of 34_Digits. 2023-08-01 08:19:51 -07:00
35_Even_Wins Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
36_Flip_Flop Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
37_Football Football (Python): Added 2022-04-10 12:17:22 +02:00
38_Fur_Trader Added MiniScript verions of 37_Football and 38_Fur_Trader. 2023-08-04 21:46:43 -07:00
39_Golf Added MiniScript version of 39_Golf. 2023-08-07 16:55:18 -07:00
40_Gomoko gomoko: fix "intelligent move" coordinates 2023-08-09 21:36:10 +02:00
41_Guess Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
42_Gunner added 42-gunner for perl 2023-05-15 12:16:12 -05:00
43_Hammurabi Add Perl implementation for Hammurabi 2023-10-22 22:35:43 +02:00
44_Hangman 44_Hangman ruby: randomize seed and use the shuffled array for puzzle order. 2022-05-03 18:46:57 -07:00
45_Hello Added MiniScript version of 45_Hello. 2023-08-17 16:05:43 -07:00
46_Hexapawn Added MiniScript version of 46_Hexapawn. 2023-08-17 21:27:07 -07:00
47_Hi-Lo Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
48_High_IQ Use docstrings 2022-04-02 08:10:01 +02:00
49_Hockey Added MiniScript version of 49_Hockey. 2023-08-22 07:50:57 -07:00
50_Horserace Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
51_Hurkle Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
52_Kinema Python: Type annotations 2022-04-02 10:56:43 +02:00
53_King Added MiniScript version of 53_King. Also updated the king_variable_update.bas 2023-09-12 16:03:29 -07:00
54_Letter Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
55_Life Added MiniScript version of 55_Life. 2023-09-12 16:03:29 -07:00
56_Life_for_Two Added MiniScript versions of 55_Life and 56_Life_for_Two. 2023-09-12 16:03:29 -07:00
57_Literature_Quiz Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
58_Love Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
59_Lunar_LEM_Rocket Revert "Fix bug in Lunar: wrong capsule weight." 2024-05-31 14:15:52 -04:00
60_Mastermind Added MiniScript version of 60_Mastermind. 2023-09-13 09:44:56 -07:00
61_Math_Dice Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
62_Mugwump Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
63_Name Create name.lua 2022-09-28 10:28:31 -07:00
64_Nicomachus Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
65_Nim Added MiniScript version of 65_Nim. 2023-09-14 13:09:44 -07:00
66_Number Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
67_One_Check Finish game 2022-08-19 08:41:11 +10:00
68_Orbit Fixed some minor issues with weekday.ms. 2023-09-16 13:52:40 -07:00
69_Pizza Port 69_Pizza to Rust 2023-10-22 20:00:32 +02:00
70_Poetry A couple of minor tweaks to already-ported-to-MiniScript projects. 2023-09-18 07:58:50 -07:00
71_Poker Added MiniScript implementation of 71_Poker. 2023-09-30 17:02:12 -07:00
72_Queen 72. Queen ported to Java 2024-03-24 16:12:10 +00:00
73_Reverse Python: Type annotations 2022-04-02 10:56:43 +02:00
74_Rock_Scissors_Paper Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
75_Roulette Added MiniScript version of 75_Roulette. 2023-10-02 09:40:53 -07:00
76_Russian_Roulette Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
77_Salvo Added MiniScript version of 77_Salvo. 2023-10-03 13:03:47 -07:00
78_Sine_Wave Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
79_Slalom Added MiniScript version of 79_Slalom. 2023-10-03 16:10:16 -07:00
80_Slots Added MiniScript version of 80_Slots. 2023-10-04 15:12:39 -07:00
81_Splat Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
82_Stars Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
83_Stock_Market Python: Type annotations 2022-04-02 10:56:43 +02:00
84_Super_Star_Trek Update README.md 2023-12-08 13:32:21 -08:00
85_Synonym Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
86_Target updated README 2023-05-15 01:16:01 -05:00
87_3-D_Plot Python: Add type annotations 2022-03-20 19:16:39 +01:00
88_3-D_Tic-Tac-Toe Added MiniScript version of 88_3-D_Tic-Tac-Toe. 2023-10-18 13:53:57 -07:00
89_Tic-Tac-Toe Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
90_Tower update train and tower Lua 2023-10-10 11:17:51 +01:00
91_Train fix train.ua random bounds 2023-10-10 11:21:04 +01:00
92_Trap Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
93_23_Matches Add rust implementation for 23 Matches 2023-08-30 22:07:52 +02:00
94_War Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
95_Weekday Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
96_Word Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
00_Alternate_Languages Merge pull request #907 from nrezmerski/patch-1 2024-06-02 13:34:40 -07:00
00_Common Merge pull request #723 from drewjcooper/csharp-25-chief 2022-04-16 13:22:15 -07:00
00_Utilities update markdown_todo_rust 2022-10-07 16:41:07 -07:00
basic-computer-games-gradle@367112cc06 bullfight added 2022-11-20 09:05:14 +11:00
.coveragerc Don't compute code coverage on test files 2022-03-19 11:57:25 +01:00
.gitignore Un-ignore Cargo.lock 2023-08-28 21:06:35 +02:00
.nojekyll disable jekyll in gh-pages 2022-03-17 20:16:51 +01:00
.pre-commit-config.yaml CI: Prevent large files from being added 2022-03-26 05:52:41 +01:00
HOW_TO_RUN_THE_GAMES.md Update HOW_TO_RUN_THE_GAMES.md 2022-10-29 00:49:21 +11:00
index.html fix(#700): fix terminal emulator on mobile 2022-04-13 22:16:46 +02:00
LICENSE Initial commit 2021-01-30 13:28:23 -08:00
pyproject.toml Clean Code: Python 2022-03-18 14:59:08 +01:00
README.md Port 09_Battle to Rust 2023-12-29 06:38:02 +08:00

What are we doing?

Were updating the first million selling computer book, BASIC Computer Games, for 2022 and beyond!

Where can we discuss it?

Please see the discussion here for a worklog and conversation around this project.

Project structure

I have moved all the original BASIC source code into a folder for each project in the original book (first volume). Note that Lyle Kopnicky has generously normalized all the code (thanks Lyle!) to run against Vintage Basic circa 2009:

Ive included all the games here for your tinkering pleasure. Ive tested and tweaked each one of them to make sure theyll run with Vintage BASIC, though you may see a few oddities. Thats part of the fun of playing with BASIC: it never works quite the same on two machines. The games will play better if you keep CAPS LOCK on, as they were designed to be used with capital-letter input.

Each project has subfolders corresponding to the languages wed like to see the games ported to. This is based on the 2022 TIOBE index of top languages that are memory safe and general purpose scripting languages per this post:

  1. C#
  2. Java
  3. JavaScript
  4. Kotlin
  5. Lua
  6. Perl
  7. Python
  8. Ruby
  9. Rust
  10. VB.NET

📢 Note that in March 2022 we removed Pascal / Object Pascal and replaced it with Rust as we couldnt determine if Pascal is effectively memory safe. Weve also added Lua, as it made the top 20 in TIOBE (as of 2022) and it is both memory safe and a scripting language. The Pascal ports were moved to the alternate languages folder.

⚠️ Please note that we have decided, as a project, that we do not want any IDE-specific or build-specific files in the repository. Please refrain from committing any files to the repository that only exist to work with a specific IDE or a specific build system.

Alternate Languages

If you wish to port one of the programs to a language not in our list that is, a language which is either not memory safe, or not a general purpose scripting language, you can do so via the 00_Alternate_Languages folder. Place your port in the appropriate game subfolder, in a subfolder named for the language. Please note that these ports are appreciated, but they will not count toward the donation total at the end of the project.

Project goals

Feel free to begin converting these classic games into the above list of modern, memory safe languages. In fact, courtesy of @mojoaxel, you can even view the JavaScript versions in your web browser at

https://coding-horror.github.io/basic-computer-games/

But first, a few guidelines:

  • These are very old games. They date from the mid-70s so theyre not exactly examples of what kids (or anyone, really?) would be playing these days. Consider them more like classic programming exercises to teach programming. Were paying it forward by converting them into modern languages, so the next generation can learn from the programs in this classic book and compare implementations across common modern languages.

  • Stay true to the original program. These are mostly unsophisticated, simple command line / console games, so we should strive to replicate the command line / console output and behavior illustrated in the original book. See the README in the project folder for links to the original scanned source input and output. Try running the game in your browser. Avoid the impulse to add features; keep it simple, except for modern conventions, see next item 👇

  • Please DO update for modern coding conventions. Support uppercase and lowercase. Use structured programming. Use subroutines. Try to be an example of good, modern coding practices!

  • Use lots of comments to explain what is going on. Comment liberally! If there were clever tricks in the original code, decompose those tricks into simpler (even if more verbose) code, and use comments to explain whats happening and why. If there is something particularly tricky about a program, edit the Porting Notes section of the readme.md to let everyone know. Those GOTOs can be very pesky..

  • Please dont get too fancy. Definitely use the most recent versions and features of the target language, but also try to keep the code samples simple and explainable the goal is to teach programming in the target language, not necessarily demonstrate the cleverest one-line tricks, or big system "enterprise" coding techniques designed for thousands of lines of code.

  • Please don't check in any build specific or IDE specific files. We want the repository to be simple and clean, so we have ruled out including any IDE or build system specific files from the repository. Git related files are OK, as we are using Git and this is GitHub. 😉

Emulation and Bugfixes

We want the general behavior of the original programs to be preserved, however, we also want to update them, specifically:

  • allow both UPPERCASE and lowercase input and display
  • incorporate any bugfixes to the original programs; see the readme.md in the game folder
  • improved error handling for bad or erroneous input

Please note that on the back of the Basic Computer Games book it says Microsoft 8K Basic, Rev 4.0 was the version David Ahl used to test, so that is the level of compatibility we are looking for.  QBasic on the DOS emulation is a later version of Basic but one that retains downwards compatibility so far in our testing. To verify behavior, try running the programs in your browser with JS BASIC, effectively Applesoft BASIC.

Have fun!

Thank you for taking part in this project to update a classic programming book one of the most influential programming books in computing history for 2022 and beyond!

NOTE: per the official blog post announcement, I will be donating $5 for each contributed program in the 10 agreed upon languages to Girls Who Code.

Current Progress

toggle for game by language table
Name csharp java javascript kotlin lua perl python ruby rust vbnet
01_Acey_Ducey x x x x x x x x x x
02_Amazing x x x x x x x x
03_Animal x x x x x x x x x x
04_Awari x x x x x x x x
05_Bagels x x x x x x x x x x
06_Banner x x x x x x x x
07_Basketball x x x x x x x
08_Batnum x x x x x x x x
09_Battle x x x x x x
10_Blackjack x x x x x x x
11_Bombardment x x x x x x x x
12_Bombs_Away x x x x x x x
13_Bounce x x x x x x x
14_Bowling x x x x x x
15_Boxing x x x x x x
16_Bug x x x x x x
17_Bullfight x x x x x
18_Bullseye x x x x x x x
19_Bunny x x x x x x x
20_Buzzword x x x x x x x x x
21_Calendar x x x x x x x x
22_Change x x x x x x x
23_Checkers x x x x x x
24_Chemist x x x x x x x
25_Chief x x x x x x x x
26_Chomp x x x x x x
27_Civil_War x x x x x
28_Combat x x x x x x
29_Craps x x x x x x x x x
30_Cube x x x x x x x
31_Depth_Charge x x x x x x x
32_Diamond x x x x x x x x x
33_Dice x x x x x x x x x
34_Digits x x x x x x
35_Even_Wins x x x x x x
36_Flip_Flop x x x x x x x x
37_Football x x x x
38_Fur_Trader x x x x x x
39_Golf x x x x
40_Gomoko x x x x x x
41_Guess x x x x x x x x
42_Gunner x x x x x x
43_Hammurabi x x x x x
44_Hangman x x x x x x x
45_Hello x x x x x x x x
46_Hexapawn x x x
47_Hi-Lo x x x x x x x x x
48_High_IQ x x x x x
49_Hockey x x x x
50_Horserace x x x x
51_Hurkle x x x x x x x x
52_Kinema x x x x x x x
53_King x x x x x
54_Letter x x x x x x x x
55_Life x x x x x x x x
56_Life_for_Two x x x x x x
57_Literature_Quiz x x x x x x x
58_Love x x x x x x x
59_Lunar_LEM_Rocket x x x x x
60_Mastermind x x x x x x x
61_Math_Dice x x x x x x x x
62_Mugwump x x x x x x x
63_Name x x x x x x x x
64_Nicomachus x x x x x x x
65_Nim x x x x x x
66_Number x x x x x x x
67_One_Check x x x x x x
68_Orbit x x x x x x x x
69_Pizza x x x x x x x
70_Poetry x x x x x x x
71_Poker x x x x
72_Queen x x x x x x
73_Reverse x x x x x x x
74_Rock_Scissors_Paper x x x x x x x x x
75_Roulette x x x x x x x
76_Russian_Roulette x x x x x x x x x
77_Salvo x x x x
78_Sine_Wave x x x x x x x x x
79_Slalom x x x x
80_Slots x x x x x x x
81_Splat x x x x x x x
82_Stars x x x x x x x x
83_Stock_Market x x x x x
84_Super_Star_Trek x x x x x x
85_Synonym x x x x x x x
86_Target x x x x x x
87_3-D_Plot x x x x x x x
88_3-D_Tic-Tac-Toe x x x x
89_Tic-Tac-Toe x x x x x x x x
90_Tower x x x x x x x
91_Train x x x x x x x x
92_Trap x x x x x x x x
93_23_Matches x x x x x x x x
94_War x x x x x x x x x
95_Weekday x x x x x x x
96_Word x x x x x x x x