Tagged: basic computer games
More than a game: the Game of Life
Conway’s Game of Life has long fascinated me. Thirty years ago I wrote some Z80 machine code to run it on a Sinclair ZX80 and when I wrote BINSIC, my reimplentation of Sinclair ZX81 BASIC, Life was the obvious choice for a demonstration piece of BASIC (and I had to rewrite it from scratch when I discovered that the version in Basic Computer Games was banjaxed).
But Life is much more than a game – it continues to be the foundation of ongoing research into computability and geometry - as the linked article in the New Scientist reports.
For me, it’s just fun though. When I wrote my first version of it back in 1981 I merely used the rubric in Basic Computer Games – there was no description of gliders or any of the other fascinating patterns that the game throws up – so in a sense I “discovered” them independently, with all the excitement that implies: it is certainly possible to spend hours typing in patterns to see what results they produce and to keep coming back for more.
- “Life.bas” should run on any system that will support the Java SDK – for instance it will run on a Raspberry Pi – follow the instructions on the BINSIC page. A more up to date version may be available in the Github repository at any given time (for instance, at the time of writing, the version in Git supports graphics plotting, the version in the JAR file on the server only supports text plotting). On the other hand, at any given time the version in Git may not work at all: thems the breaks. If you need assistance then just comment here or email me adrianmcmenamin at gmail.
Related articles
- BINSIC plotting working (cartesianproduct.wordpress.com)
- Relive the ZX81 experience on your desktop (cartesianproduct.wordpress.com)
- A glider on an aperiodic cellular automaton exists! (aperiodical.com)
- Running BASIC on the Raspberry Pi (cartesianproduct.wordpress.com)
- Google Hides a “Game of Life” Easter Egg on the Search Page (news.softpedia.com)
BINSIC almost done
BINSIC, my BASIC-as-a-DSL, is almost complete now, though I am rather ashamed at the first big program I used to test it – I just grabbed it off an archive of content from the legendary Basic Computer Games and did not look too closely at what it was about.
8 PRINT "You are a pilot in a Second World War bomber." 10 PRINT "Which side -- Italy(1), Allies(2), Japan(3), Germany(4)" 12 INPUT A 20 IF A > 0 AND A < 5 THEN GOTO 25 22 PRINT "TRY AGAIN..." 24 GOTO 10 25 IF A = 1 THEN GOTO 30 26 IF A = 2 THEN GOTO 110 27 IF A = 3 THEN GOTO 200 28 IF A = 4 THEN GOTO 220 30 PRINT "YOUR TARGET -- Albania(1), Greece(2), North Africa(3)" 35 INPUT B 40 IF B>0 AND B<4 THEN GOTO 45 42 PRINT "TRY AGAIN..." 43 GOTO 30 45 PRINT "" 46 IF B = 1 THEN GOTO 50 47 IF B = 2 THEN GOTO 80 48 IF B = 3 THEN GOTO 90 50 PRINT "SHOULD BE EASY -- YOU'RE FLYING A NAZI-MADE PLANE." 60 GOTO 280 80 PRINT "BE CAREFUL!!!" 85 GOTO 280 90 PRINT "Going for the oil, eh?" 95 GOTO 280 110 PRINT "AIRCRAFT -- Liberator(1), B-29(2), B-17(3), Lancaster(4)" 115 INPUT G 120 IF G>0 AND G<5 THEN GOTO 125 122 PRINT "TRY AGAIN..." 123 GOTO 110 125 PRINT "" 126 IF G = 1 THEN GOTO 130 127 IF G = 2 THEN GOTO 150 128 IF G = 3 THEN GOTO 170 129 IF G = 4 THEN GOTO 190 130 PRINT "You have got 2 tons of bombs flying for Ploesti." 135 GOTO 280 150 PRINT "You are dumping the A-bomb on Hiroshima." 155 GOTO 280 170 PRINT "You are chasing the Bismark in the North Atlantic." 175 GOTO 280 190 PRINT "You are targeting the Ruhr." 195 GOTO 280 200 PRINT 201 PRINT "You are flying a KAMIKAZE mission over the USS Lexington." 205 PRINT "Your first Kamikaze mission? (Y OR N)" 206 INPUT F$ 207 IF F$ = "N" THEN LET S = 0 208 IF F$ = "N" THEN GOTO 358 210 PRINT "" 212 IF RND > 0.65 THEN GOTO 325 215 GOTO 380 220 PRINT "A NAZI, EH? Oh well. Are you going for Russia(1)," 230 PRINT "England(2), or France(3)" 231 INPUT M 232 IF M>0 AND M<4 THEN GOTO 235 233 PRINT "TRY AGAIN..." 234 GOTO 220 235 PRINT "" 240 IF M = 1 THEN GOTO 250 242 IF M = 2 THEN GOTO 260 243 IF M = 3 THEN GOTO 270 250 PRINT "YOU'RE NEARING STALINGRAD." 255 GOTO 280 260 PRINT "NEARING LONDON. BE CAREFUL, THEY'VE GOT RADAR." 265 GOTO 280 270 PRINT "NEARING VERSAILLES. DUCK SOUP. THEY'RE NEARLY DEFENSELESS." 280 PRINT 285 PRINT "HOW MANY MISSIONS HAVE YOU FLOWN" 287 INPUT D 290 IF D < 160 THEN GOTO 300 292 PRINT "MISSIONS, NOT MILES..." 295 PRINT "150 missions is high even for old-timers." 297 PRINT "NOW THEN, "; 298 GOTO 285 300 PRINT 302 IF D < 100 THEN GOTO 310 305 PRINT "THAT'S PUSHING THE ODDS!" 307 GOTO 320 310 IF D < 25 THEN PRINT "FRESH OUT OF TRAINING, EH?" 320 PRINT 322 IF D < 160 * RND THEN GOTO 330 325 PRINT "DIRECT HIT!!!! ", INT(100 * RND), " KILLED." 327 PRINT "MISSION SUCCESSFUL." 328 GOTO 390 330 PRINT "MISSED TARGET BY ", INT(2+30 * RND), " MILES!" 335 PRINT "Now you are REALLY in for it !!" 336 PRINT 340 PRINT "Does the enemy have GUNS(1), MISSILES(2), or BOTH(3)" 342 INPUT R 345 IF R > 0 AND R < 4 THEN GOTO 350 347 PRINT "TRY AGAIN..." 348 GOTO 340 350 PRINT 351 LET T=0 352 IF R = 2 THEN GOTO 360 355 PRINT "What's the per cent hit rate of enemy gunners (10 TO 50)?" 356 INPUT S 357 IF S < 10 THEN PRINT "YOU LIE, BUT YOU'LL PAY..." 358 IF S < 10 THEN GOTO 380 359 PRINT 360 PRINT 362 IF R > 1 THEN LET T=35 365 IF S+T > 100 * RND THEN GOTO 380 370 PRINT "You made it through tremendous FLAK!" 375 GOTO 390 380 PRINT "* * * * BOOM * * * *" 384 PRINT "YOU HAVE BEEN SHOT DOWN....." 386 PRINT "Dearly beloved, we are gathered here today to pay our" 387 PRINT "last tribute...." 390 PRINT 391 PRINT 392 PRINT "Another mission? (Y or N)" 393 INPUT U$ 395 IF U$ = "Y" THEN GOTO 8 400 PRINT "CHICKEN !!!" 410 END
Thirty years ago today…
According to my diary I spent my spare time mucking about coding: loading the BASIC version of “Lunar Lander” – from Basic Computer Games – on to my ZX80. So much for putting away childish things.
Related articles
- Breadboard 81 (cartesianproduct.wordpress.com)
- More computing nostalgia (cartesianproduct.wordpress.com)
- Twenty, Thirty, and Sixty Years Ago (blogs.windriver.com)
Found my copy of “Basic Computer Games”
This book – Basic Computer Games – is now, justly, regarded as classic and my brother (don’t tell him I have got it) and I spent many evenings and weekends typing in the code from it into our ZX80 and later a Spectrum.
Pristine copies are said to sell for many hundreds of pounds, though so many were sold at the time that second-hand copies are very cheap.
Right now I have a coursework exercise of writing a game – what I used to call exie-ohsies, but in England is called “noughts and crosses” and in the US “tic-tac-toe” – in the Groovy programming language.
There is a tic-tac-toe program in the book and I wonder if it would be practical to reimplement that in Groovy (suitably acknowledged of course)?
Update: having looked more closely at the assignment I don’t think the BASIC code will fit too well. A pity, because it might have been fun.
Never used a punch card
But I have seen them in use - at my (high) school in London in 1979/1980 people doing the computer science ‘O’ level had to punch these out for BASIC programs and send them off site to see if they would run.
Back then any sort of permanent storage seemed like a luxury – my first “micro”, a Sinclair ZX80 was meant to store programs on tape (I now understand the science of the whistles, it’s only taken me some 30 years to get round to that) but the machine was very fussy about the link and so some times it was quicker – if no less frustrating – to simply retype the programs: even the longer ones, though the ZX80 had only 1K of memory without an expansion pack, from this book (our bible at the time) – Basic Computer Games
Thirty years ago, for Christmas 1980, my parents bought me a new cassette player and the world of permanent storage began to open up.
Happy new year to all.
