Hacker News new | past | comments | ask | show | jobs | submit login
1K ZX Chess (wikipedia.org)
43 points by sjcsjc on Sept 4, 2018 | hide | past | favorite | 22 comments

It's hard to reconcile this:

> It was the smallest implementation of chess on any computer until its record was broken in January 2015 by the PC-compatible BootChess.

with this:

> 1K ZX Chess uses only 672 bytes of RAM,[2] but implements chess rules except for castling, promotion, and en passant, including a computer opponent.

If you don't include castling, promotion, and en passant, the game isn't chess anymore, or at least it hasn't been for a couple hundred years.

I believe boot chess also does not implement two of those three, which makes it a fine comparison. Promotion is something I expect most people know, castling is something they might know, but en passant is hardly common. I wouldn't be at all surprised if the number of people who play chess without knowing that rule exceed those who play by FIDE rules.

Whatever the case, it is still a variant of chess, so I see no problem calling it chess.

Promotion shouldn't be compared to castling/en-passant here.

A game without castling or en passant would be similar enough in spirit that we could call it a "chess variant". Removing promotion, on the other hand, would result in a wildly different game.

I actually suspect it'd be impossible to win against any non-beginners, making it more similar to tic-tac-toe than to chess.

En passant comes up a lot more often when you don't know the rule.

But ... that's like moaning that Bannister broke the four minute mile but collapsed at the finish line.

1K is a hellava achievement

It would be more like moaning that he broke the four minute mile but collapsed fifty feet before the finish line. Should it be counted if you didn’t finish?

This program is awesome, but it’s not quite chess.

Nonsense. Bannister ran a mile. I've made lots of programs that were under 1K. They weren't chess, either.

I don't like how negative this comment is, but the logic is flawless. I have also made a lot of "<1K not-chess" games.

See also http://nanochess.org/chess4.html (discussions and links to 2K and 1K Javascript implementations).

"Take note that the 1018 octets of my Javascript code include an artificial intelligence and also the user's interface and chessboard visualization"

There was Psion Chess for the expanded ZX81 (16 KB RAM.) I still have the cassette. The instructions on the cover explain how to castle and state that it recognize en passant. No mention about promotions but they should be supported.

Load time "3.5 mins approx." I remember that I lost every signore game against it but it wasn't very fun because it used fast mode and I couldn't see the screen when it was thinking.

There's also an implementation of chess in 1K of JS:


Microchess on the KIM-1 says hi. ZX Chess is still smaller, and actually has a display, but this wasn't a lot bigger and appeared on other 6502-based systems.


> It was the smallest implementation of chess on any computer until its record was broken in January 2015 by the PC-compatible BootChess.[4]

It would be interesting to compare x86 and Z80 code density, that is, how much you can do per bit of machine code.

Not a 'scientific' comparison, but handwritten 8-bit machine code compresses much less than x86/64 machine code (using gzip --best):

- a compiled C executable for x86/64 compresses to about 38% of its original size (199 KB down to 77 KB)

- a WASM blob of the same code compresses to about 32% (171 KB down to 56 KByte)

In comparison some 8-bit ROMs:

- ZX Spectrum 128 ROM (Z80): 16384 bytes compresses to 12189 (74.3%)

- C64 Kernel ROM (6502): 8192 bytes compresses to 6735 (82.2%)

So 8-bit code seems to be a lot 'denser' than today's machine code, and 6502 is denser than Z80 :)

That's interesting! Do you think this is because 64-bit code simply doesn't use a lot of its instruction set space (where more opcodes and instruction modes and variants are undefined and therefore not routinely used in executables), or because some of the people hand-writing 8-bit assembly actively use more opcodes than a typical compiler would, or some other factors?

Or are there are a lot of pointers in 64-bit code that contain a huge number of zeroes? :-)

I guess it's a combination of compiled vs handwritten code (maybe certain patterns show up more often in compiled code, while handwritten 8-bit code tries hard to remove any redundancies because of the limited available space), and bigger data types (especially 64-bit pointers).

Very interesting! Another thing to consider however is how much work each instruction can do. In that regard x86 may have a big edge.

x86 was originally based on Z80 so it should be extremely similar (for 16-bit code at least).

A chess program without castling, promotion, and en passant is incomplete. It is not chess, it is a work in process.

Let's see you do better ;)

I mean he is right, and it's even said in the article. It is an amazing piece of software, nobody's arguing against that, but it's not chess.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact