8 ms·
The greatest program ever written
- michael_dorfman 17y agoNot to knock Mr. Horne's achievement, but Peter Jennings wrote Microchess for the KIM-1 (a 6502-based machine with 1K of RAM) back in 1976. Source code here: http://users.telenet.be/kim1-6502/microchess/microchess.html 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.
- michael_dorfman 17y agoIn fact, just to show what we're talking about, here it is 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 0F009B450C01010031869024C7703 There you go: a fully functional Chess program, with AI.
- Goladus 17y agoTo actually run that on the PC I'm using right now, I would presumably need to also download an emulator for the machine it was designed for, which is presumably larger than 1K. Just saying.
- kqr2 17y agoLink to the Full ZX-81 Chess in 1K article by David Horne: http://users.ox.ac.uk/~uzdm0006/scans/1kchess/ 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%2F1KZXChess%28Artic%29.tzx.zip%400&title=White+queen+pawn+moved+from+1K+ZX+Chess http://www.zx81stuff.org.uk/zx81/emulate.php?tzx=0%2F1KZXChe...
- iuguy 17y agoWhen I saw the ZX81 reference I thought surely he meant 3d monster maze by Malcom Evans which was the first 3d game for a home computer (although it did need 16k of RAM).
- zandorg 17y agoTry 3d Deathchase - it's better than Doom!
- tezza 17y agoI grew up coding assembly for 6502... and you can fit a lot in 1k. 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
- pvg 17y agoI don't see how these assumptions really help - 'greatest program ever written' is a bit bombastic but working chess program in a few hundred bytes of z80 code is still quite impressive. 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.
- tezza 17y agoIt sounds like you're helping my point... thanks. 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] -------------------- [1] http://www.giantbomb.com/zx-spectrum/60-16/ http://www.giantbomb.com/zx-spectrum/60-16/
- pvg 17y agoI suppose if 'just about everything you said to support your point is wrong' is 'helping you', there's probably not much left to discuss.
- 17y ago
- nadam 17y agoI don't want to sound negative, but 'greatest program ever written' is really an overstatement. He has created this program, because he needed to fit into 1k. If it was needed nowadays, hundreds of programmers could achieve this result. (I would be so happy to code these kind of things at my working place instead of the bloated overcompilcated softwares...) 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.
- zandorg 17y agoGet them playing each other and then pick a winner that way.
- sophacles 17y agoIsn't this like saying "Orville and Wilbur wright really didn't do anything that great. Thousands of hobbiests could easily build an airplane that is safer, faster and more maneuverable than the wright flyer, and in their garages on weekends!". 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.
- tedunangst 17y agoI haven't read a blog post titled "The Wright brothers built the best plane ever" recently.
- ekiru 17y agoThe Wright Brothers made the first powered heavier-than-air aircraft capable of sustained controlled flight. 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.
- rivo 17y agoI remember when I was six, my dad programmed a chess game on the Sinclar ZX81. He used to play real-life chess a lot so naturally, this was his first use for this little box. It was slow as hell and he had to pause screen rendering to make it faster. If you call simple backtracking "AI" then I think my dad wrote that "greatest program ever" too without knowing David Horne. (And my dad is definitely no urban myth, either...)
- charltones 17y agoAre you sure the ZX81 he was using didn't have a 16Kb ram pack attached? Most people I know (me included) had one, since it was hard to do anything without it.
- dirtbox 17y agoVery true, but I had this game, it was one of the few that ran without the rampak. I think I used the pak primarily for Bomber and 3D Monster Maze. Good times!
- stcredzero 17y agoThe greatest program ever written The Best HN Hyperbole. (For today!)
- deleted 17y ago[deleted]
- abdulhaq 17y agoC Chess program in less that 1200 chars: http://home.hccnet.nl/h.g.muller/max-src2.html http://home.hccnet.nl/h.g.muller/max-src2.html
- niyazpk 17y agoI think we should compare the size of the assembly code generated for this with the original. Other than reducing the readability, I cannot think of any advantage offered by the mere compression of the source code.
- NathanKP 17y agoThe code referenced in the article is located at: http://users.ox.ac.uk/~uzdm0006/scans/1kchess/ http://users.ox.ac.uk/~uzdm0006/scans/1kchess/
- blintson 17y agoI'm writing a javascript chess game write now and I'm currently at 200 lines + 50 of HTML. The source code of mine is larger than the byte code of his program. I am a moron.
- moron4hire 17y agosource code can often be larger than byte code. 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 http://members.gamedev.net/capn_midnight/chess/chess.html
- deleted 17y ago[deleted]
- sophacles 17y agoTotally off-topic: Does anyone else miss the kuro5hin peak days? I can't seem to find any single community to capture the soul of what it was. HN and Reddit are close, but something is lacking. Anyone know of such places?
- deleted 17y ago[deleted]
- sjs382 17y agoI don't think either comes close to capturing the spirit of K5. Remember the "Dorm Wars" and "Fast Times at Phillips 66" serials? 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.
- sophacles 17y agoYeah, those are exactly the sort of thing I'm talking about. Topic oriented communities are great, hence I really like HN; it's full of smart people who will discuss things well, but its all computers all the time. The thing about k5 was the whole "renaissance man" vibe.
- Perceval 17y agoThe unique thing about k5 was that all the content was written by the users. Every other community on the web is just a link-n-blurb site with a discussion forum bolted on: Slashdot, Digg, Reddit, HN, MetaFilter, and on down the line. Only at k5 do you have long form, decently well-written pieces on any variety of subjects.
- sophacles 17y agoThanks, I have no idea how I was unable to connect "renaissance man vibe" with "users wrote all the content". But you are absolutely correct!
- 17y ago
- diego_moita 17y agoI respect the acomplishment but I can think about a lot of other computer systems/programs with way more cultural, economic and scientific impact than this program. E.g.: Unix, Java, Sabre, VisiCalc, Mars Rover and Hubble controlling software, etc.
- ThinkWriteMute 17y agoThis page would never show up in a search engine that de-lists ad-sense pages.
- Dav3xor 17y agoI suppose the theoretical limit is 1 bit -- if you define the program in terms of a virtual machine that takes 1 instruction -- "play a game of chess".