Smallest ever chess program: 487 bytes

Who gives a hoot about chess?

If you really want to impress me, do something about those Steam downloads, Bioshock Infinite is 36.6GB FFS! Cut that down and you'll have my attention. It doesn't have to be 487 bytes, hell you could even use a million times that. Shouldn't be too hard, right?
 
Because computer memory is severely limited these days...

Imagine if all applications were as efficient and small as this one. As somebody with an interest in algorithmics, I get very annoyed by the "RAM and processing is cheap"-viewpoint. That's not what should determine how we code. Efficient code and mathematically optimised code should be foremost in any good programmer's mind. Think how much further we could progress with more efficient code.

From Cormen & Rivest's classic textbook:
For a concrete example, let us pit a faster computer (computer A) running insertion sort against a slower computer (computer B) running merge sort. They each must sort an array of 10 million numbers. (Although 10 million numbers might seem like a lot, if the numbers are eight-byte integers, then the input occupies about 80 megabytes, which fits in the memory of even an inexpensive laptop computer many times over.)

Suppose that computer A executes 10 billion instructions per second (faster than any single sequential computer at the time of this writing) and computer B executes only 10 million instructions per second, so that computer A is 1000 times faster than computer B in raw computing power. To make the difference even more dramatic, suppose that the world’s craftiest programmer codes insertion sort in machine language for computer A, and the resulting code requires 2n^2 instructions to sort n numbers. Suppose further that just an average programmer implements merge sort, using a high-level language with an inefficient compiler, with the resulting code taking 50n lg n instructions.

To sort 10 million numbers, computer A takes 5.5 hours versus less than 20 minutes on computer B.
 
Will it be smaller if he took out the comments?
 
Imagine if all applications were as efficient and small as this one. As somebody with an interest in algorithmics, I get very annoyed by the "RAM and processing is cheap"-viewpoint. That's not what should determine how we code. Efficient code and mathematically optimised code should be foremost in any good programmer's mind. Think how much further we could progress with more efficient code.

From Cormen & Rivest's classic textbook:

Efficiency can be taken too far though. I'd rather have something that might take a bit longer (often not even noticeable) and have simpler code which is less likely to have bugs.
 
Efficiency can be taken too far though. I'd rather have something that might take a bit longer (often not even noticeable) and have simpler code which is less likely to have bugs.

Efficient does not mean convoluted. Since when is merge sort or quick sort really complex to implement? Sometimes knowing a small mathematical theorem can make all the difference in the world, a little bit of research beforehand instead of continuous, mindless typing makes a huge difference.

Anyone who implements bubble sort on a live product (not during development) should be shot.
 
Imagine if all applications were as efficient and small as this one. As somebody with an interest in algorithmics, I get very annoyed by the "RAM and processing is cheap"-viewpoint. That's not what should determine how we code. Efficient code and mathematically optimised code should be foremost in any good programmer's mind. Think how much further we could progress with more efficient code.

From Cormen & Rivest's classic textbook:

Oh my ...! Now I gone and done it. And especially looking at your avatar, I'm sh&tting myself here :eek:


More seriously though:
Yes, you have a very valid point. I remember having a task round about 2003/2004 to look at an app that did reconciliation between 3 sets of financial data. It was supposed to run daily, but ran for me more than 24 hours, and had thus been switched off months before I started at the company.

It ran in a few seconds after I fixed it up, and in about 1.5 minutes once I added in all the extra checks they wanted done. All I can say is: understanding the Big O notation of an algorithm is very important.
 
I won!

I won!
attachment.php

except that the computer (upper case) thinks that the best defence is a good offence -- it replies to "CHECK" with a "CHECK" of its own :wtf:
 

Attachments

  • bootchess.png
    bootchess.png
    9.7 KB · Views: 603
Interesting that this was done by Red Sector, the group that produced this in 1989:
[video=youtube;L_6dFgGHdNo]https://www.youtube.com/watch?v=L_6dFgGHdNo[/video]
 
Top
Sign up to the MyBroadband newsletter
X