Here is a copy of 1K Chess for the Sinclair ZX81.
Developed by Artic and released by Sinclair Research in 1982, it was one of the few playable
programs that would happily run on an un-expanded Sinclair ZX81.
This is because a standard ZX81 has only 1KB of RAM, which is a pathetic amount of memory
to run anything of substance.
To display a full screen alone would consume 793 bytes, however through creative genius,
David Horne, the programmer of this game, has managed to pack a playable version of
chess into just 672 bytes.
We're not talking a 2 player game here either, this is chess against the computer.
Yep, that 672 bytes also contains the code for an AI opponent, and for most of us, it
puts up a pretty good fight.
The program was also included in a 3 part series of Your Computer magazine, from December
1982 to February '83.
These listings were where many of us sourced games from in the 80s.
Here you can see the BASIC program listing, which consists of only 4 lines of basic, but
with two of those occupied by chunks of machine code, handily stored under a REM statement.
Here's the machine code listing, which looks even more daunting, and it kinda is, but it's
also a work of beauty, and an incredible exercise in what can be created in such a limited space.
So in one of my late night musings, I pondered whether this little program would be able
to beat a more modern game of chess.
Now of course, this isn't really the ZX81 vs. a modern computer, it's a 1KB 1982 chess
engine vs. a more capable chess engine.
We could get hugely bogged down in that notion alone, given there are so many chess engines
of differing abilities, but I wanted to keep things simple.
This isn't a scientific test by any means.
Windows, is a platform I use everyday, so why not pit Windows Chess against 1K chess?
Of course Windows 10 is devoid of games, even minesweeper, but Windows 7 came with a number,
including Chess Titans.. and thanks to ElDiabl0 from mydigitallife.net we can grab the Windows
7 game collection and run them on 10, with ease.
So, here we are.
On the left is Chess Titans, set at the standard difficulty level of 2 (pretty low).
On the right is 1K Chess, ready and willing to fight.
Given the limited space, 1K chess always opens with a White Queen Pawn move, or if you load
side B of the tape, a White King Pawn move.
This is side A, so we have our first move.
I can then translate this move onto the Chess Titans board and we're away.
On the face of it, things were looking pretty even, with both sides playing defensively.
But then the game had to stop, and not because someone won, but because of limitations in
1K chess.
Although Titans is programmed with all the chess rules, 1K doesn't allow for pawn promotion,
or castling.
Therefore this pairing isn't an ideal one.
I could keep playing games until I get one where Titans doesn't attempt to castle, but
I felt it was fairer (and easier) to find a game which allows you to disable these elements.
That game came in the form of an engine, known as StockFish.
It's an open source engine and it packs one hell of a punch.
I mean, it's the best chess engine out there, and can easily beat human opponents.
So as for our 1K chess, yeah, things are looking a little grim.
Here's game one running on the Arena front end, with Stockfish running as-is, out of
the box, playing as if it were a 5 minute tournament match.
You can see the Stockfish calculations down here, where-as 1K chess actually runs through
its possible moves on the board, mainly to conserve memory.
The program is broken into a number of elements.
We have an STR routine which scans the board and finds which squares are occupied and by
which colour, the Piece routine then creates pointers to possible moves and then the Move
& Pawn routines narrow that down into a legal list.
The Check routine scans for a possible check.
Finally the Score routine scores each move based on where it can take a piece, whether
the current position of a piece is under attack, whether the new position can be attacked,
then whether a check is possible and finally whether the original position is defended.
Scores for each move are compared and added to the scores for each chess piece, and the
highest scoring move is made.
It's a pretty basic formula which doesn't offer much room for planning ahead, and so
it doesn't take long for 1K chess to be on the backfoot, and out of the game.
Game two is with Stockfish set on a much lower skill level, and although things look promising
for 1K chess to start with, that ends when you realise that things weren't actually looking
promising to start with at all.
So 1K chess is no match for this new engine, but then of course it isn't.
Still, the fact that you can even play against a 1K chess program is still frankly phenomenal,
and that's really the main point of this video; To illuminate the incredulity of 1K chess
and show that even in the most dire of circumstances, and faced with enormous restrictions, amazing
things can occur.
Talking of amazing, in 2015, 1K chess was actually beaten by a PC Booter program; BootChess
to become the smallest AI chess program at just 487 bytes.
Now that would be a fairer match, and one I'll likely do on my extra channel in the
near future.
If you get a moment, I'd recommend booting up 1K chess and giving it a blast, or better
yet, type it out from the Your Computer listings.
Thanks for watching.