
Chess game in 487 bytes – new record - jamesbrownuhh
http://www.pouet.net/prod.php?which=64962
======
bane
I keep saying it, but the demoscene is probably the 3rd great software
movement (after commercial software and open source/free).

It's a weird kind of 3rd way, it's not open source, it's free as in beer,
there's tons of help/guides/talks available, but source is rarely made
available due to the competitive nature of the scene. Demogroups (or members
of groups) frequently end up in the commercial world and it's been
C64->Amiga->DOS->Windows for the most part, almost completely skipping Linux,
OS X and other x-nix derived platforms (though there are plenty of
exceptions). It's unusually prolific, there are literally tens of thousand of
pieces of software and at least a half million pieces of music produced by the
scene...and it's almost entirely purposeless with scant few connections to the
commercial world.

The result is frequently stunning technology _and_ art (and sometimes
technology that's so elegant it's basically art on its own), splinter scenes
and a constant showcase of real-time techniques that continue to push what
even grizzled computing veterans think is possible.

And oh yeah, it's mostly populated by people young enough to have not even
graduated college.

------
not_kurt_godel
It's not chess if it doesn't allow castle. From the comments
([http://www.pouet.net/prod.php?which=64962#c715279](http://www.pouet.net/prod.php?which=64962#c715279)):

> Well... It is clear to me that you put more interest in making a small chess
> program that in making a good chess program. That's understandable even if
> the result is a program very easy to beat but... you cannot say that
> BootChess is a complete chess program because it does not allow to castle
> (didn't tried promotions, underpromotions, en passant pawn captures,
> stalemate... but I bet that are not supported, are they?) and, worst, it
> does not care about avoid to place a King in check. Every chess player knows
> that it is illegal (the movement CANNOT be made) to place your king on a
> square controlled by your rival pieces. If you allow it, then this is not
> chess.

~~~
raverbashing
" It is clear to me that you put more interest in making a small chess program
that in making a good chess program"

That's pretty much obvious

It's an exercise in programming, it's not "the ultimate chess software"

~~~
not_kurt_godel
The obvious interpretation of "good" in that sentence is that it would allow
the player to play chess according to universally defined and agreed-upon
rules. Castling is one such rule. While I think one could argue there is some
leeway with allowing the king to move into check since it doesn't _prevent_ 2
players familiar with the rules from playing a valid game, inability to castle
does not pass this litmus test. Castling is integral to the game and is
neither obscure nor rarely invoked, even at the novice level - a game without
it is simply not "chess". While I agree this is an impressive programming
exercise and worthy of recognition in its own right, calling it a "new record"
is like claiming a marathon record after running 25 miles

~~~
a3_nm
To play the devil's advocate, castling was a pretty late addition to the rule
of chess compared to most other rules, so there used to be a game called
"chess" which did not feature castling (nor the option to move pawns initially
by two squares). Some regional variants of chess
[https://en.wikipedia.org/wiki/Indian_chess](https://en.wikipedia.org/wiki/Indian_chess)
did not feature castling fairly recently (and differed from mainstream chess
only by a few points), and there are stories of Indian chess players who
became masters in Europe (as late as the early 20th century) even though they
had learned to play without castling (can't recall the name of the one I had
in mind, but there are such anecdotes at least for Mir Sultan Khan).

I agree that it would be nicer if the implementation followed FIDE rules,
though, and that not being able to castle significantly changes the strategy.

------
rwmj
I'm glad they mentioned 1K chess for the ZX81 [1] which I remember typing in
from a magazine listing, and then playing against quite a lot (it was better
than a 10 year old me). Neither program is capable of castling.

[1]
[http://users.ox.ac.uk/~uzdm0006/scans/1kchess/](http://users.ox.ac.uk/~uzdm0006/scans/1kchess/)

~~~
ikeboy
If they can't castle then they aren't complete.

Or do you mean the ai can't castle, but you can?

~~~
ctdonath
It was a ZX81. "It's not a complete implementation" was presumed for anything
running on that tiny thing. The base model had 1K RAM, which _included_ all
video & OS memory space. Getting it to do _anything_ meaningful was a
challenge. That somebody, back then, could get a sane implementation closely
approximating chess running on it was _amazing_.

~~~
david-given
1K Chess for the ZX81 was 672 bytes long; the ZX81 had 672 bytes free.
(Although it was more complicated than that because the ZX81 'framebuffer'
changed size depending on what was on the screen, so a screen that was mostly
white gave you more spare RAM.)

Also, because the ZX81 more-or-less did its video in software (again, it's
more complicated than that; if you really want to know, you'll need a strong
stomach. Let's just say that it hinged on abusing the Z80's built in DRAM
refresh and the framebuffer was executable), which meant that the only time
you could do processing with the screen turned on when it wasn't doing video.
And the video took 75% of the run time.

The ZX81 was less a computer and more of a pile of hacks flying in close
formation. The fact it ran at all was a miracle.

~~~
rwmj
How the ZX81 display file worked:

[http://www.user.dccnet.com/wrigter/index_files/ZX%20Video%20...](http://www.user.dccnet.com/wrigter/index_files/ZX%20Video%20Tutorial.htm)

Note the encoding of that page causes it to render incorrectly at least in
Firefox. Using View → Character Encoding → Western fixes that for me.

------
Impossible
In the readme file (BootChess.txt) He quotes a great HN comment thread
([https://news.ycombinator.com/item?id=7940938](https://news.ycombinator.com/item?id=7940938))
from
([https://news.ycombinator.com/item?id=7940212](https://news.ycombinator.com/item?id=7940212)),
a 128 byte raycaster written by the same author. The title of that section is
"Proving know-how remains valued". This post has already generated some
similar gems like this one
([https://news.ycombinator.com/item?id=8954853](https://news.ycombinator.com/item?id=8954853)).

------
fcambus
Nice to see this appear on HN!

For info the author also released an impressive serie of very tiny intros
ranging from 64 to 256 bytes which can be found on his personal site :
[http://olivier.poudade.free.fr](http://olivier.poudade.free.fr)

------
ehamberg
The README file is really interesting:
[http://lpaste.net/119343](http://lpaste.net/119343)

~~~
mattdotc
If you enjoyed that README, you might also like Jason Scott's talks. See this
one about the history of early pirates in the BBS days:

[https://www.youtube.com/watch?v=a5AceLYWE1Q](https://www.youtube.com/watch?v=a5AceLYWE1Q)

~~~
ehamberg
Thanks! Looks interesting. :-)

------
morcheeba
Source code:
[http://olivier.poudade.free.fr/src/BootChess.asm](http://olivier.poudade.free.fr/src/BootChess.asm)

------
ctdonath
For interesting contrast: Toledo Nanochess
[http://www.nanochess.org/chess3.html](http://www.nanochess.org/chess3.html)
is the smallest C implementation of a full & decent chess program.

------
fuzzywalrus
Couldn't get the OS X binary to mount and I'll have to fire up a VM to try a
different binary.

However there is a nice txt file, Bootchess.txt that has some interesting
excerpts. I was curious if it has an AI, to which it does:

" Usually the heart of any midly advanced computer chess games includes a
MinMax function (or its unique call merging sister function NegaMax) called
recursively evaluating both sides' possible moves and trying to minimize loss
whilst maximizing captures : each evaluation pair rundown is called a "ply" in
chess jargon. It can take Kasparov some 27 moves to battle a 3-ply and the
champion programs competing with grandmasters usually have at least 5-ply. In
the case of BootChess there is alas not enough space (512 bytes binary program
size and 640 bytes RAM execution environment) for such level of
sophistication. It uses a variant : while maximizing captures it tries to
minimize the taxi/Manhattan distance to the opponent's black king rank. This
weaker ai element combination will be named "TaxiMax" for the occasion and can
be viewed as a half-ply plus."

------
tluyben2
Very nice to see that the RSi guys (who I have been a fan of since the begin
90s; especially the Amiga stuff was very impressive, both in skill but also
art) still take challenges like this one. Disadvantage here is that whenever I
click a Pouet.net link, I can pretty much say farewell to my productive day...

------
darkmighty
With such a small number of bytes wouldn't it be viable to run some sort of
optimization to minimize the code even further?

------
aaron695
Does it run on a ZX81? If not I'd guess it might be using short cuts not
available on the original machine.

Easy way to get them smaller and be legitimate chess (This seems to be missing
half the rules) would be let white move, then resign. You might have to allow
white to resign / offer a draw as a move as well.

------
fsiefken
That would include 1) rules for the movement 6 chess pieces 2) board
definition and initial setup 3) end conditions 4) exceptions. A tweets lenght
worth of each, neat.

~~~
firethief
"Exceptions"??

------
rinjipal
Oh ! and this one is a PC boot sector. Sexy

------
jpwagner
reminds me of the runner-up in the first js1k competition (even better):
[http://js1k.com/2010-first/demo/750](http://js1k.com/2010-first/demo/750)

------
tempodox
WTF??? What is that page?

------
RIMR
Yeah, well this guy can launch a GUI in zero bytes! Beat that!

[http://www.pouet.net/prod.php?which=18860](http://www.pouet.net/prod.php?which=18860)

