

Chess@home: Building the largest Chess AI ever (in JavaScript) - sylvinus
http://sylvainzimmer.com/2011/09/06/chessathome-building-largest-chess-ai/

======
gcp
The last time anyone did a project like this (ChessBrain), they were very
careful not to give any meaningful performance results. I can tell you why:
latency is critical in these applications, and APHID scalability is terrible
once you go over a few nodes. Scaling YBWC is even harder, more latency-
sensitive, and responds terribly if you can't effectively share memory over
multiple nodes.

Using a lot of CPUs to generate heat is easy. Using them to generate good
chess moves is another matter.

How about having your "2000-node chess program" play against the strongest
GPL-ed chess program (Stockfish 2.1), running on a fast 4-core box?

If you can win a match of meaningful length against that, I might be
interested.

Until you get there, this is a nice exercise in combining technology to
achieve meaningless results.

~~~
sylvinus
Indeed. APHID doesn't scale well and it will be hard to distribute YBWC
efficiently but we think we have a shot at it with very short compute windows
for each worker. We may also look at other algorithms but currently a
variation of YBWC seems the most promising.

In terms of strength, we'll add the UCI protocol to be able to run games
against other engines. We'll see how it performs but we don't expect to beat
Stockfish easily, even with a very large number of nodes. That will be part of
the experiment and we'll be happy to publish the results.

Now, another path to get real performance would be to find a way of using
webGL on the workers. Folding@home has proven it's sometimes 10x more
efficient than using CPUs. If we can manage to do that then we _might_ have a
shot at being both the largest and strongest AI...

~~~
gcp
Folding@home has proven that embarrassingly parallel problems run well on
embarrassingly parallel architectures. Computer chess is not one of those.

Forget about using the GPU for chess. Just getting that to work somewhat
decently is a huge achievement - which _no-one_ has succeeded in so far.

Some people, when they see a problem, think: "We'll use the GPU". Now they
have 2 problems.

~~~
sylvinus
Fair point. Though I'll have to get burned trying before being convinced it's
that complicated :) However webGL is not in the critical path of the Guinness
Record thing, so I'll happily trust you for now!

~~~
0x12
this guy might have a hint or two, or maybe you could collaborate if you go
that way:

<http://blog.cudachess.org/>

------
ggchappell
> Widget ethics. Using third-party processing power has usually been opt-in:
> people needed to install SETI@home or the BOINC software to lend their CPUs.
> JavaScript allows us to use people’s CPUs without their explicit consent
> just when they visit a page with the widget, which makes this a grey area.

This could be a new way of generating revenue from a website: selling time on
visitors' machines. I'm not saying it's a good or ethical idea, but it's
certainly an _interesting_ idea.

~~~
mambodog
That was the idea behind the Javascript Bitcoin Miner, though it turned out to
be unfeasible in the end.

<http://bitcointalk.org/index.php?topic=9042.0>

comments: <http://news.ycombinator.com/item?id=2566365>

~~~
rorrr
I think somebody is building a WebGL version. That could generate a ton of
money on a large website.

------
sylvinus
By the way, just posted the source from NKO:
<https://github.com/joshfire/chessathome>

------
Read_the_Genes
I tried using this, but it left me with the impression that it was
unprofessionally done.

1\. The board is not correct. The black square must be in the left corner.
While this may seem like a small quibble, it changes the patters so that
squares like e4, which should be white, are now black. This makes it difficult
to play.

2\. There are apparently no openings programed into the computer. Since
openings are so complex, simply using an algorithm to find good opening moves
does not work well. So, this program will almost always start out with bad
first moves.

~~~
sylvinus
Hi,

Please keep in mind it was hacked together in 48h, so yes it's _supposed_ to
be unprofessionally done ;-) However we'll now calmly fix all the issues and
continue improving it: <https://github.com/joshfire/chessathome/issues>

Feel free to report more bugs, we love feedback :)

------
0x12
Useful link:

<http://www.rgoarchitects.com/Files/fallacies.pdf>

'The fallacies of distributed computing explained'.

------
judofyr
> When the AI is strong enough, we’ll invite an actual french Chess Grand
> Master along with a Guinness official for the most epic Chess game, ever!

Ehm, what makes this so epic? Computers have been known to beat humans at
chess for quite a while now.

~~~
oldstrangers
Its gotten so bad (good) that cell phones are now playing at GM levels. Kind
of depressing, but inevitable.

[http://en.wikipedia.org/wiki/Human-
computer_chess_matches#Po...](http://en.wikipedia.org/wiki/Human-
computer_chess_matches#Pocket_Fritz_4_.282009.29)

~~~
sylvinus
Yes, it's astounding (if true) that Pocket Fritz only searches 20k nodes per
second, compared to Deep Blue's 200M. There must be some serious positional
intelligence involved there!

~~~
TylerE
Your average GM is also not Gary Kasparov. The difference between a typical GM
and one of the handful of elites is pretty astounding.

~~~
starwed
For a graphical grasp of this concept, take a bell curve, and _then plot only
the top 0.1% of the bell curve._ That's the distribution of abilities among
people who are any good at all at chess, and it is no longer anything close to
a bell curve.

------
rozim
Variation on a theme: implement Stockfish in NACL, or, if Stockfish is too
hard to port, a simpler though strong program like Fruit.

Then, you can essentially isolate out one of the variables, the strength of
the "node", or client, engine, and you can play your Stockfish distributed
against a Stockfish on a local box.

Of note is that there will still be 2 advantages the distributed version has:
\- more CPUs (obvious to everyone) \- more RAM (well, obvious once you mention
it)

If the distributed version is stronger then one question will be, was it more
CPUs, or more RAM, that tipped the balance?

~~~
gcp
For any reasonable amount of RAM (say >64M) and a strong engine with a good
hash-replacement algorithm: always the CPUs. They are simply not RAM-limited.

------
sgdesign
Great idea, it's amazing that you could build something like this so fast!

Although in my case, a single AI node is probably already enough to beat me at
chess, let alone 2000…

------
willvarfar
It occurs to me that you can be thinking whilst it is the opponent's turn i.e.
you can give some nodes the job of looking at likely next moves and others for
determining counters to that and so on.

PS don't forget to ask your contributors to open a tab for each core they have
if their browser is going to use a separate OS thread for each

PPS Google Chrome's NACL is, longer term, an interesting direction perhaps?

~~~
sylvinus
Yes, most chess programs do this, although it is forbidden in some chess
computer tournaments with stricter rules (but we'd never qualify in those
anyway :)

As for asking people to open multiple tabs, that may be an additional
instruction for D-Day if they want to max out their CPUs. But we figured 1 CPU
maxed out while browsing a website would already be enough :)

Chrome's NaCl is definitely an interesting direction, but we'll investigate
webGL first which seems to be more promising (see Folding@home).

Thanks for the feedback!

------
GoGlobal
It sounds pretty interesting, but is JavaScript really the proper way to
implement... Is the implementation transferable to other problems?

~~~
ImJasonH
I've been doing some free-time hacking on a generic solution to distributing
Javascript tasks. <https://code.google.com/p/mrjs>

It's definitely not secure, or very reliable, but it's a start at least.
(Contributions accepted!)

------
coldarchon
duh, reminds me of my long forgotten project, I got 15GB of 200Mio played
games on FICS and 15800 games of grandmasters. Took too long for my AI to look
through all of them ..

