---
created_at: '2015-03-05T16:09:03.000Z'
title: David Horne's 1K Chess on the ZX81 (2001)
url: http://thad.frogley.info/archive/the_greatest_program.html
author: jermo
points: 380
story_text: 
comment_text: 
num_comments: 147
story_id: 
story_title: 
story_url: 
parent_id: 
created_at_i: 1425571743
_tags:
- story
- author_jermo
- story_9151552
objectID: '9151552'

---
[Source](http://thad.frogley.info/archive/the_greatest_program.html "Permalink to 
The greatest program ever written
")

# 
The greatest program ever written


# The greatest program ever written

I'm a programmer. I write games. Games programmers get a lot of respect, but none of them, not me, not Carmak, and not Abrash. None of them deserve the honour which I want to bestow on David Horne. This is because David Horne wrote the greatest program ever written: 1k chess on the ZX81. 

David Horne is not [an urban myth][1]. David Horne achieved what many would even now consider impossible. He wrote a chess game, with AI, that ran on a poorly documented, buggy machine that contained only 1k of memory. 

The [Sinclar ZX81][2]. 

Think about that amount of memory for a moment. 1 kilobyte. 1024 bytes. Can you write down the rules of chess in less than one thousand characters? That's a tricky task in itself. Fire up you favourite compiler, and build a minimal application. I'm guessing that its more than 1k in size, and it doesn't do anything yet. 

But wait a second. 1k was the capacity of the machine. How much was actually available? The answer, as you will find if you follow the link at the end of the article, is a meagre six hundred and seventy two bytes! This article takes up more space than that. 

And it had AI. Not very tough AI mind you, but AI none the less. So not only could is display the board, verify the you're moves according to the rules, and detect a win or a draw, but it could select moves for itself and play them. 

All this and more. He not only conceived and executed the idea that a game of chess could be packed into so few bytes, but he published the source code, along with a detailed explanation of how it was done in the February 1983 issue of `Your Computer' magazine. This article is essential reading, a trip down memory lane for those of us old enough to remember those furious, exciting 8 bit days, when the limitations defined the experience of programming, and an important piece of history for those brave young hackers who take for granted the luxuries of life, like compilers, swap space, and keyboards that click. 

So, David Horne, if your out there - this is for you. I, and I'm sure, my fellow programmers, bestow upon you this honour: You, sir, created [The Greatest Program Ever Written][3]. 

_Originally posted to kuro5hin on Aug 10, 2001_, here: <http://www.kuro5hin.org/story/2001/8/10/12620/2164>, & Subsequently discussed on reddit, here: [www.reddit.com/r/programming/comments/2y1hex/the_greatest_program_ever_written/][4]. 

You may also enjoy: [An introduction to C++ Traits][5], "[Using typedefs to write maintainable code][6]" or "[Iterators][7]". 

[1]: http://www.pbm.com/~lindahl/mel.html
[2]: http://www.honneamise.u-net.com/zx81/zx81faq.html
[3]: http://users.ox.ac.uk/~uzdm0006/scans/1kchess/
[4]: http://www.reddit.com/r/programming/comments/2y1hex/the_greatest_program_ever_written/
[5]: http://thad.frogley.info/cpp_traits_intro.html
[6]: http://thad.frogley.info/using_typedefs.html
[7]: http://thad.frogley.info/iterators.html

