141 points · by niyazpk · 16y ago · 56 comments
the 1k is aided and abetted by the architecture of the computer.
* Reading keyboard is reading a register/known address, not loading the keyboard library, allocating a structure and jumping into an OS routine.
* Clear screen is writing zeros to a known address space
* Drawing is writing a 1 to a known address space
* Yours is the only process on the machine
* Text compresses well with Huffman
With those assumptions a lot more can fit in the 1K
Reading keyboard is reading a register/known address, not loading the keyboard library, allocating a structure and jumping into an OS routine
Or calling a ROM routine. Reading the keyboard directly at the lowest level would probably just make the program bigger
Clear screen is writing zeros to a known address space
Generally, another ROM routine call.
Drawing is writing a 1 to a known address space
Not really. Just about all these machines had color. The Apple ][ had a fun non-linear video buffer layout, to boot.
Text compresses well with Huffman
Not a lot of text in a chess program.
Generally, another ROM routine call.
Thats @tezza's point. (Edit For Clarity): Since its just one instruction, you can shrink the size of your program, making fitting it into a small space less impressive (though, not unimpressive).
Not a lot of text in a chess program.
Fair enough, so that one doesn't help, but the other two do.
For reference to my original post: I wasn't trying to deny that this program is amazing... it is.
I was intending to illustrate that you could do a lot more with 1k historically than you can nowadays, and that some of the worst offenders to bulking out a process don't apply on older computers in assembly.
That doesn't take away from the brilliance of AI in 1k, but rather I think the focus should be on that and not the chessy bit.
The ZX81 did not have colors.
ROM routines is a jump into known addresses... so no extra impact on the 1K. Parameters are read from registers.
Color of 4bit? only a slight increase. Often acheivable in 1 instruction. Limit of 2 colors in 8x8 block on ZX81[1]
--------------------
A high quality 3D FPS that is a mere 97,280 bytes through the magic of procedural generation.
Source code here: http://users.telenet.be/kim1-6502/microchess/microchess.html
I had the PET 2001 version (running in 7K of RAM) back in the day, and it played quite well, all things considered.
D8A2FF9AA2C886B2201F1F206A1FC5F3F0F685F3C90CD00FA21FB5709550CA10F986DCA9CCDO12C90ED00720B202A9EED007C914D00B20A20385FB85FA85F9D0BFC90FD006204B034C9D0l4C960110000304000702O50l06101711161215141373747077727571766067616662656463F0FF0l1011OFEFF1DFElEEF2120E1F210B0A0606040404O40202020202020202A6B5305
CA5B0F308EO08D004C5E6F02EF6E3C901D002F6E3501EA00FA5B1D96000
F0038810F8B9A000D5E4900494E695E4180875E595E528E004F00330316
0A5E885DDA90085B5204B0320B20220000220B202A90885B52009022031
034C8017E0F9DO0BA560C5B1D004A90085B46050FDA007A5B1D96000F00
588F0F110F6B9A000D5E2900295E2C6B5A9FBC5B5F003202503E6B560C9
08B01220EA03A21FB550C5FAF003CA10F786FB86BO4C000000A210A9009
5DECA10FBA91085B0C6B0100l60201E03A4B0A20886B6C0081041C00610
2EC004101FC00lF009100E208E02D0FBF0D9209C02DOFBF0D2A20486B62
09C02D0FBF0C7209C02A5B6C904D0F7F0BCA21086B6208E02A5B6C908D0
F7F0ADA20686B620CA025005300320000l201E03C6B6A5B6C9O5F0EB20C
A02708F308D20000lA5B129FOC920FOEE4C0D0220CA023003200001201E
03C6B66020CA02900250F930070820000l2850F0201E03C6B660A20F38B
460A977F550956094503550CA10EB60A5B1A6B618758F85B12988D042A5
B1A220CA300ED550D0F9E0103033A97F69017001B8A5B53024C90810204
808A9F985B585B4204B0320B202200902202E03286885B5A5B4300438A9
FF6018A90060A9FF18B860A6B0B55085B160204B0320B20220090220820
2BA86B3A6B29A6885B66885B0AA68955068AA6885B195504C7003BA86B3
A6B29AA5B148A8A21FD550F003CA10F9A9CC95508A48A6B0B5509450488
A48A5B648BA86B2A6B39A60A6E4E4A0D004A900F00AA6E3D006A6EEDO02
A9FFA20486B5C5FA900CF00A85FAA5B085FBA5B185F94C1F1FA6DC1017A
5F9D5DCD00FCAB5DC85FBCAB5DC85F9CA86DCD01A85DCA20C86B586FAA2
14200202A20486B5200002A6FAE00F9012A6FBB55085FA86B0A5F985B12
04B034C0000A9FF60A20406F926FACAD0F905F985F985B1600000000000
0018A98065EB65EC65ED65El65DF38E5F0E5F1E5E2E5E0E5DEE5EFE5E3B
002A9004A18694065EC65ED38E5E44A18699065DD65DD65DD65DD65El38
E5E4E5E4E5E5E5E5E5E0A6B1E033F016E034F012E022F00EE025F00AA6B
0F009B450C01010031869024C7703There you go: a fully functional Chess program, with AI.
If someone would create a prize (a prize like the netflix prize or the Hutter prize) with $100k or something, to create the smallest chess program, I suppose hundreds of contestants would fit into 1k. But the competition would be high, and the winners would be probably very sophisitcated algorithms, which might deserve the 'greatest program ever written' title. But without competition it is easy to be the best.
It is the nature of tech to build on what was done before. It's hard to remember that something that now might be laughable, was at one point considered impossible.
The subject of the article is a person who wrote a chess program. Not the first chess program. Not the first successful chess program. A chess program. Nonetheless, it is still an impressive feat to fit a chess program with AI into 1k. But it is not comparable to the Wright Brothers' airplanes.
http://users.ox.ac.uk/~uzdm0006/scans/1kchess/
And here's a ZX-81 emulator to play the actual game:
http://www.zx81stuff.org.uk/zx81/emulate.php?tzx=0%2F1KZXChe...
I'd love to find a place like K5 again. Rusty killed it with the $5 registration fee for new accounts. The dupe accounts, multiple personalities, and role playing were part of the charm.
That being said, it was great at its peak. Combination of a blog community, debating club and much more.
It was funny reading the article, since I recognized a few names and immediately thought, "Holy Shit, that guy's still there?"
Then I saw the date.
My first attempt at a javascript chess game was almost 7 years ago. 159 lines of javascript and html. Unfortunately, it's nothing more than a pieces-on-board sim. It doesn't do anything to control play or prevent cheating. It was college, it was fun http://members.gamedev.net/capn_midnight/chess/chess.html
E.g.: Unix, Java, Sabre, VisiCalc, Mars Rover and Hubble controlling software, etc.
Other than reducing the readability, I cannot think of any advantage offered by the mere compression of the source code.
Good times!
The Best HN Hyperbole. (For today!)