« Back to Blog   

Recreating Solitaire in BASIC (Or At Least Trying To...)
May 1, 2020
By Alec M.

Note: To avoid confusion of the “pun intended/pun not intended” variety, the author of this post has opted not to use the word “basically...”

We’re celebrating BASIC! BASIC is a historical programming language designed for educational purposes. Before there was a mouse and graphical user interface (GUI), BASIC was one of the very first ways a student might interact with a computer. I have a little anecdotal story to reinforce BASIC’s utility.

Back in December, I discovered that Solitaire was missing from the desktop of the Windows 3.1 computer currently on display at Living Computers. Deleting programs from our computers is not encouraged. Unfortunately, it’s not entirely uncommon. Much to my surprise, I couldn’t find Solitaire on any other computer we had at the time either. Solitaire is very much a guest favorite, especially the early Windows versions. The engineers would get it back up and running eventually, but I felt a profound sadness at the lack of Solitaire--not only in the museum, but in my life in general!

A lesser person might’ve walked away from this problem, but as a technology enthusiast, I couldn’t pass up an opportunity to painfully learn how to craft a solution for a problem that doesn’t really need solving (there’s a word for that--it’s called problematizing). Surely, with all the vintage systems and historical resources available to me, I could build my own game of Solitaire in BASIC. At first the idea was somewhere up there in daydream territory, but I knew I had a good foundation to work off of courtesy of our DEC PDP 8/e.

The 8/e has a version of the card game War written in BASIC, and I hoped I could expand on some of that code. In fact it did give me an idea on how to A) simulate drawing from a random deck of cards, and also B) be able to compare the values of those cards.
MicrosoftTeams-image-(1).png
And by “gave me an idea” I mean I copied and pasted the code directly. I typed it up into an Apple II. If there are any differences between 8/e BASIC versus Apple II BASIC, they must not be major, as I don’t recall there being any problems in migrating the code from one system to the other (another strength of the BASIC language).
 
Of course, all I had at this point was a card drawing simulator. I dove into arrays to be able to display the core of the standard solitaire layout:
basic3.jpg
(I will point out here that I’m fully aware that there is no “1 of diamonds.”)

If you’re disappointed to read that this was about as far as I got in the project, imagine how disappointed I am! The last thing I managed before shelving the project was moving columns from one column to another. This involved keeping track of four values for each column: the number of face up cards, the number of face down cards, the value of the highest card in each column, and the value of the lowest card in each column.

Between those four values, I could do most all of the checks to see if the move was legal and to tell the program what cards to move and where to put them. It then updates the values and even flips a new card. I didn’t implement a check for the color of the cards.

I was on a roll until I realized that the ten of clubs would be labelled “10C.” That’s a full character longer than any other label I had for cards, and would completely screw up the formatting.
 
This is precisely where I left the project on the shelf. But it left me with a shining new understanding of and appreciation for BASIC as a programming language. If you’re looking to crack open a new programming language for fun, I strongly recommend BASIC. It was the learning language for thousands upon thousands of students throughout the 60s, 70s, and 80s, and it’s an easy way to sit down at a lot of Living Computers’ vintage systems and immediately begin programming. It’s available on many of our remote online systems too, meaning you can connect to one of our computers from home and program on real vintage hardware.

Please share any fun or inspired BASIC projects you might’ve worked on in the past or want to  take on in the future! You might’ve noticed that I, myself, am not sharing any of my code. That’s because it had no notes, and it took me an embarrassing amount of time just to reconstruct how it worked. But we would love to see your BASIC coding skills in action! Connect to our remote online systems, flex your BASIC skills, and share you creations with us on Twitter, Instagram, or Facebook!

Related Content:

BASIC Ain’t Basic: Adapting Programs from One Vintage System to Another
[MS@45] Did You Know: Solitaire was Microsoft's Cherry on Top
[MS@45] Tour Trailer: Altair BASIC
About the Author
Alec M.
Museum Guide
Alec spent four years travelling Washington as a science educator before settling down at Living Computers Museum + Labs. At the museum you'll probably find him troubleshooting robots, digging into assembly language, or occasionally playing chess against some vintage technology.
About the Author
Alec M.
Museum Guide
Alec spent four years travelling Washington as a science educator before settling down at Living Computers Museum + Labs. At the museum you'll probably find him troubleshooting robots, digging into assembly language, or occasionally playing chess against some vintage technology.

Category Tags