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.
- 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 – my reimplementation of ZX80 or ZX81 (Timex Sinclair 1000 or 1500 for US readers) BASIC is now available for download in binary form – look at the page on the site: Binsic Is Not Sinclair Instruction Code.
It comes with Conway’s Game of Life for the authentic black and white text based feel too.
(Source code is also available here)
BINSIC – Binsic Is Not Sinclair Instruction Code – my effort to re-implement Sinclair ZX80/ZX81 BASIC as a domain specific language via Groovy (and eventually a runnable Java JAR file), is making more progress.
Right now it supports:
IF ... THEN ... ELSE
GOSUB ... RETURN
FOR ... TO ... STEP ... NEXT
DIM A(x, y, z) (and array derefencing)
Still one or two difficult areas to get through and I have had to make one compromise – unlike on the ZX80 one cannot have a variable and an array with the same letter designation – just too difficult to implement on Java/Groovy.
But, it’s getting there…
There have been (conservatively) 16 “Moore generations” since 1980 – that is to say computing speed should have increased by – approximately 4 million times.
But computation requirements grow to fill the computing power available and BINSIC now runs at about the same speed, when executing the same code, as my ZX80 did when hacking its way through BASIC programs 32 years ago.
It’s a strange sight to see, because it is so evocative of that period.
The code runs slowly largely, I think, because of the way that I have chosen to handle
GOTO statements (not that I could think of any other way) – essentially the whole or at least a substantial part, of the program is reparsed every time a
GOTO is issued.
Anyway, it adds to the sense of realism!
- Line numbers problem solved, after a fashion (cartesianproduct.wordpress.com)
- Basic instinct: how we used to code (go.theregister.com)
- 10 amazing old tech reviews from BYTE Magazine (royal.pingdom.com)
- Building a 1980s microcomputer with a Parallax Propeller (hackaday.com)
- Parking Signs, An Evolution of Parking Signs from 1910 to Present (myparkingsign.com)
So, here’s a tougher regular expressionproblem – one I have not yet worked out myself.
BASIC‘s essential looping structure is a
FOR (STEP) ... NEXT loop. In ZX80/ZX81 BASIC (the dialect I am aiming to emulate with the BINSIC DSL) this is of the form
FOR v = num TO num STEP num... NEXT v, where
v is a single letter counter variable and
num a valid numerical expression.
Groovy does not implement a
FOR loop as such but it is not difficult to cover the simple and common case of a
STEP 1 loop (though other values might be more difficult), but the tricky bit is that BASIC
FOR ... NEXT loops can be nested. So what regular expression will grab the insides of a loop?
Update: The best thing about blogging is that sometimes it helps to clarify the problem. And it has done so here even as I wrote this. I don’t need to worry about the nested loops at all – all I need to do is substitute some code for the
FOR statement and replace the
NEXT with a
}. This has the added advantage of saving poor BASIC coders from disordering their
- A regex puzzle to start your weekend (cartesianproduct.wordpress.com)
- The Lazy Man’s URL Parsing (joezimjs.com)
- JsFiddle for Regular Expressions [RegExpPlanet Review] (theexceptioncatcher.com)
- Regular expression for finding a word (daniweb.com)
The graphic you can see here is the partially recovered code of a program I wrote thirty years ago – “hexmon” – to display chunks of ZX80 memory in hexadecimal format (at least I think that’s what it did).
I am determined to fully recover it – but as you can see it works well so far and the machine code string in the middle looks particularly good – especially as I can see it ends with
C9 which I know is the Z80 “return” command.
LD HL, 402Bh
LD B, 0Ah
LD A (HL)
LD (IX + 0), A
I think it became part of a bigger “Hexmon” program to display chunks of internal memory on screen.
- A macro-assembler in 96 lines (1300 bytes of object code) (atariwiki.strotmann.de)
- Mining for optimal assembly sequences (thecodecavern.co.uk)
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.
It used to have articles which were a bit more scientific and investigatory than others – I particularly remember one talking about how to describe n-dimensional space in a program.
I particularly remember these covers/issues – some of which still look great to me today, thirty years on. I desperately wanted to run the US presidential election program here too, but it used elements of the BASIC language that I simply could not work out how to substitute for from the ZX80′s limited vocabulary (back then most things were targeted at the variety of BASIC found on a Commodore PET).
Hmmm… Fast Fourier Transforms….
And finally – I remember thinking this was a stunning image:
Not everything about computing is on the internet.
Sometime around this point thirty years ago my brother and I went to a computer exhibition in London – “Breadboard 81″
There are a couple of references to it findable through Google. But not much.
It was a fantastic experience – but perhaps also the end of an era: the computer that feature most of all was the “UK 101″ – a kit based effort with a real keyboard (unlike the ZX80 Conor and I were using).
It is impossible to describe the thrill one could get from being able to see, use and program (in either BASIC or assembler/machine code) any of these devices: everyone was a pioneer and everyone was equal. (Though this book this book captures the feel of the era that was dying even as it peaked.)
Perhaps there are others who will read this who were also there and who can share their memories of this moment… reminding me of where it even was would be a start? Olympia?