|Update, September 2015: Complete re-write in TypeScript/React.|
Four years after I wrote this post, I found the time to port it to TypeScript/React, with configurable depth search and an arguably better looking interface.
I wrote the code in both functional (OCaml/F#) and imperative (C#/C++) styles, and got different speed results from each one of them. Naturally, C/C++ was the fastest one by far: more than 5 times faster that the next best performer (OCaml). People from Reddit and Hacker News joined in, with implementations in Python, Java, Go, Haskell and D(!). I placed all the code on Github, so it is easy to compare the various implementations and see how the code works.
It took me 2 hours to do the porting (most of which was spent reading the canvas APIs). I kept the default depth checking at level 7, and then, using my trusty Phenom II/3GHz at work, I tested it with the 5 most popular browsers. The Minimax engine (which you can test yourself above, just click on the middle column) - reports how much time it takes to make a move. This is what I got:
|Google Chrome 12.0.742.122||2.147 seconds|
|Internet Explorer 9.0.8112.16421||4.007 seconds|
|Safari 5.1 (7534.50)||4.754 seconds|
|Opera 11.50 (build 1074)||5.016 seconds|
|Firefox 5.0.1||7.328 seconds|
Update, August 3: Apparently, the new engine coming up in Firefox will run just as fast as Chrome.
Update, August 7: Since Firefox is not yet up to speed, and browsers/CPUs in mobile phones are even slower, I added auto-detection of mobile browsers, and set the depth level to (a) 5 for mobiles, and (b) to 6 for normal, desktop machines.
|Back to index My CV About me||Last update on: Sun Sep 13 09:55:11 2015|