Ask HN: Refactoring a BASIC Blackjack Game from the 70s
http://www.vintage-basic.net/bcg/blackjack.bas
Anyway, reasonably complex, supports up to seven players has insurance, splits and double downs.
If you ever wanted to get a taste of the weirdness of BASIC coding this is a good 322 line (commented) example:
In defense of the code: - part is that there was no multi-line IF conditionals so you had to get creative - micros being so memory limited usually had a 2 character limit on variable names - there was a lot of twisted logic sometimes to get a game crammed into a small memory footprint
I'm gonna re-factor it into PHP, but thought it was a good example to discuss here: BASIC, refactoring such code, etc.
Source site with more BASIC game listings - http://www.vintage-basic.net/games.html
What do you think?
18 comments
[ 2.8 ms ] story [ 49.8 ms ] threadyeah, I could remaster the logic a lot simpler with with all the modern syntax. Maybe should draft out the original logic and rebuild from there, certainly a lot of variables and odd jumps to sort out.
Ive seen some articles on a more realistic card shuffle routine, etc. Also the games book suggests going for a three deck cardset would be more accurate as well..
At the time many folks were graduating from cassette/paper tape to floppy disk, so random text file usage was kind of a new thing to many micro owners, text files were there but mainly used to store program variable data. Other concepts like compression, graphics formats, remote updating, distributed data, etc. were in their infancy.
I would think someone going back there would have an advantage, they may have to learn the old languages then build a whole lot of tools, but they would know more advanced end results which is a lot better then trial and error to reach those points originally.
https://en.wikipedia.org/wiki/The_Mother_of_All_Demos
I wrote code (pre-STL) for linked lists, sorted arrays, array lookups, and everything. And without modern languages (like C#!), I had to fight with not screwing up pointers.
Recommend you port it to Python, as a command line / console app. Command line would make it simpler to keep the "spirit" of the original.
But at some time, my C64's tape recorder broke. And I couldn't save the programs I wrote. So, programming to me was, waking up in the morning, start writing some program and playing with it, and in the evening when I switched off the power button everything would be gone. But I loved to play with my C64 :)
At those days, sometimes I even wrote very long programs. But I must admit that, when I see those 322 lines, it really frightened me now! It's looks like a million line C or Java codebase to me. I have no intention to refactor that code at all.. But I agree it would be fun.