Updating "101 Basic Computer Games" for 2022 and beyond

Wow! This is so cool – and it’s exactly why I started this project! I don’t have a strong opinion on the actual approach you choose, but definitely capture all this in code comments, because it’s fascinating.

1 Like

In my C++ version of Super Star Trek (link in the readme.md in the repo), I pretty much just threw out the Basic implementation, and just made sure the results were the same (i.e., giving the same course and speed, you’ll end up in the same place in both versions, etc.)

3 Likes

Heh. Good to know. I’ll definitely check it out.

I guess it all comes down to where the line is drawn. Doing a direct translation from BASIC to any structured, functional, and/or OOP language.(I’ve only contributed Python so far, but would be glad to do C++ as a well) requires making choices about how to replicate behavior in a fashion that makes sense for the target language. Doing decent translations between human languages requires a similar skill. For example, a lot of expressions are culturally based and make zero sense when translated word for word. If we are looking to replicate the behavior of the computer player in tic tac toe, then we’d presumably need to faithfully recreate the algorithm though.

So far my attempt reminds me of higher level language code disassembles I’ve seen where functions are named for their line numbers.

2 Likes

I’m chuckling and nodding as I’m reading your article. “NIghtmare of Spaghetti Code” indeed.

2 Likes

So just to be clear: if the BASIC code is using a for loop to loop through an array searching for a hit, we should rewrite this as a filter method? We can rewrite this? We should not rewrite this?

2 Likes

Also, should we leave the little deviously clever programming hacks they did? Like overwriting their temporary MasterMind guess array values with non-ASCII characters to avoid duplication when counting the “blacks” and “whites”? Because writing some (verbose, complex) mapping function to achieve the same result sounds dumb even as I type it here.

2 Likes

I’d say definitely rewrite the for-loop, if that’s the best way to accomplish the task.

On the other hand, I’d keep the programming hacks — if they remain optimal across languages.

2 Likes

This is such an awesome idea, and I’m really glad to have been able to contribute a couple of conversions. I got started programming as a child by copying games exactly like these out of magazines.

My last conversion (Blackjack, C#) was made considerably more difficult because of clever tricks. I understand why they would have been used in the original language, but I didn’t see any value in preserving them, especially when modern languages have much simpler and clearer ways of achieve the same goal.

For example:
Line 2220 S(I)=Z(I)*(3*(-(P(D1,2)>=10))-1)

This appears in the routine where the dealer offers blackjack insurance after dealing themselves an ace face up. If the dealer’s concealed card (P(D1,2)) is worth 10, this statement resolves to Z(I)*2, where if it’s not, it resolves to Z(i)*-1.

This works because BASIC represents true as -1 and false as 0, and they can be used interchangeably with integers. Not only would converting this as is to C# preserve a confusing relic with little value, it would also be difficult. The language deliberately prevents mixing boolean expressions with mathematical operations because it is normally not intentional.

I am definitely in favour of replacing these constructs with modern language capabilities and the latest techniques.

This does lead me to a question… The hardest part of my last conversion was understanding the original game. Now that I’ve spent this effort, I think it could be helpful for me to share my notes. What’s the best way for me to do that? It would be ideal to mark up the original BAS file with GitHub comments, but I don’t think we can do that outside of a PR. What about an MD file in each game directory?

2 Likes

For what it’s worth, I’ve gotten a decent way toward translating Super Star Trek into JavaScript via the most stupidly literal means possible. Could have started from scratch but I kind of wanted to soak my head in the old code a bit.

A neat thing is that just tonight I managed to get it running in a browser-based terminal, albeit with some bugs to fix:

https://lmorchard.github.io/basic-computer-games/84%20Super%20Star%20Trek/javascript/index.html

2 Likes

A couple of different covers:

2 Likes

Ahh those are lovely! The other one from the first run is this:

image

1 Like

First thought when seeing the red and white was some spin-off from The Cat in the Hat.

1 Like

Kind of disservice to Basic don’t you think. Why not translate the code to actual Basic languages in use today. Such as:

Freebasic
Oyxgen
PureBasic
Thinbasic
PowerBasic

All of the above are in active use and fully supported. Powerbasic today is as good a any C compiler of today.

Just to add another thought. BASIC in the old days was a procedural language. While most today use Object oriented languages, procedural coding is still in use and not obsolete. They are two totally two different styles. Translations to other languages if you must, will be much easier if one uses a procedural style of coding.

2 Likes

I would argue VB.NET covers this, and it is a classic Microsoft BASIC to boot.

I think to have a ruleset everyone can agree on, we’re going to narrow this to the top 20 TIOBE languages that are memory safe and scripting appropriate, right now by my reading…

Languages in TIOBE top 20 as of February 2021:

  1. C :x:
  2. Java
  3. Python
  4. C++ :x:
  5. C#
  6. Visual Basic
  7. JavaScript
  8. PHP :-1:
  9. SQL :-1:
  10. Assembly :x:
  11. R :-1:
  12. Groovy :question:
  13. Go :x:
  14. Ruby
  15. Swift :-1:
  16. Matlab :-1:
  17. Delphi / Object Pascal
  18. Classic VB :-1:
  19. Perl
  20. Objective-C :x:

The ones with red X are not memory safe and therefore not applicable:

:x: C, C++, Assembly, Go, Objective-C

By scripting appropriate I mean languages meant for classic BASIC style I want to run a generalized, all purpose script at the command line style programming:

:-1: PHP, SQL, R, Swift, Matlab, Classic VB

That leaves us with 8 languages:

Java, Python, C#, VB.NET, JavaScript, Ruby, Delphi / Object Pascal, Perl

Groovy is a superset of Java, based on my research, so I’m consolidating that one into just Java. This also applies to other “clone” languages, we’re going with the language that is in the TIOBE top 20, even if the clone (or superset) language is compatible.

:loudspeaker: March 2022 – After some discussion, we’ve replaced Pascal (which we can’t guarantee memory safety for, and that’s an explicit goal of this project) with Rust, and added Lua since it cracked the top 20 in TIOBE.

2 Likes

Hey Jeff,

When you say that PHP isn’t scripting appropriate, I don’t really see how it can’t run a generalized, all purpose script at the command line.
Mind you I don’t want to have PHP included, I’m just a bit thrown by your claim.
PHP CLI is as powerful as Python and has been used to do some async programming, even if I haven’t looked at the code to see how hacky it is :wink:
But again, disclaimer: I’m not pushing for it to be included!!! I REPEAT, not pushing for it to be included!

Cheers,
Gus

2 Likes

Well, we gotta draw the line somewhere, and the idea that someone would say

  • I have a task I need accomplished at the command line
  • I shall use PHP to accomplish this command line task

… is pretty unlikely to me … compared to say, every other scripting language on the list :wink:

If someone wants to start a PHP fork and link it from README.MD they are free to do so!

1 Like

Hi Jeff,

Ok, I’ll agree on the basis that it’s not the first tool you get out of your toolbox to solve a problem.
And again, I was not pushing for it to be present :stuck_out_tongue:

Cheers,
Gus

2 Likes

The copy of “BASIC Computer Games: Microcomputer Edition” (Workman Publishing, 1978) says “101 great games…”

The repo seems to have 96 games.

The TRS-80 Edition claims an incredible 102 games.

I’m curious where the differences are.

2 Likes

So, I looked through the table of contents of my book, and it seems to line up with the GitHub repo.

One thing that’s probably a source of difference is that “Lunar LEM Rocket” is actually 3 different (very similar) programs in the book. I see that “59 Lunar LEM Rocket” has lunar.bas, lem.bas, and rocket.bas.

2 Likes

In one of my pull request, I created a visual studio solution for the .NET projects in the repo. In one of the last 85 commits, it was deleted. Was that a deliberate change, or did it just inadvertent?

1 Like