Engine In Javascript

Code, algorithms, languages, construction...
glinscott
Posts: 8
Joined: Mon Jun 14, 2010 6:12 pm
Real Name: Gary Linscott

Re: Engine In Javascript

Post by glinscott » Tue Jul 23, 2013 7:59 pm

Awesome job! Great to see another strong JS engine on the scene :).

I played them against each other at 2s a move, and Garbochess (http://forwardcoding.com/projects/ajaxchess/chess.html) barely prevailed, although it was a toss-up in the midgame for quite a while. My guess is that they are quite close in strength.

1. d4 Nf6 2. Nf3 d5 3. c4 dxc4 4. e3 b5 5. Bd2 Nc6 6. a4 Rb8 7. axb5 Rxb5 8. Qa4 Rb6 9. Bxc4 Bd7 10. Qc2 Qb8 11. Bc3 Nb4 12. Qc1 Bf5 13. Na3 Nd3+ 14. Bxd3 Bxd3 15. Ne5 Bf5 16. O-O Ra6 17. f3 Be6 18. e4 c6 19. Re1 g6 20. Nac4 Qb7 21. Na5 Qb5 22. Naxc6 Rxc6 23. Nxc6 Qxc6 24. Rxa7 Qb6 25. Ra8+ Kd7 26. Qa1 Bc4 27. Ra4 Bd3 28. Re3 Bb5 29. Ra7+ Kc8 30. Ra8+ Kb7 31. e5 Nd5 32. Re1 e6 33. Qa5 Qxa5 34. Rxa5 Bd3 35. Rea1 Be7 36. Ra7+ Kb6 37. Rd7 Re8 38. Raa7 h5 39. f4 Ba6 40. Bd2 Bc8 41. Ba5+ Kb5 42. Rdc7 Nxc7 43. Bxc7 Kc6 44. Ba5 Bb7 45. b4 f6 46. h3 g5 47. g3 h4 48. Kf2 Rb8 49. b5+ Kd7 50. exf6 hxg3+ 51. Kxg3 Bxf6 52. Bc3 gxf4+ 53. Kxf4 Ke8 54. Ra4 Bd5 55. Rb4 Rc8 56. Bb2 Rc2 57. Ba1 Rf2+ 58. Ke3 Rf3+ 59. Ke2 Rxh3 60. b6 Be7 61. Rb1 Bf3+ 62. Ke3 Bg5+ 63. Kf2 Be4 64. Rb4 Bh4+ 65. Ke2 Bd3+ 66. Kd2 Bg5+ 67. Kc3 Be7 68. b7 Be4+ 69. Kc4 Bd5+ 70. Kb5 Bxb7 71. Rc4 Be4 72. Kb6 Rb3+ 73. Ka5 Rb1 74. Bc3 Bd3 75. Rc8+ Kd7 76. Ra8 Bd6 77. Ra7+ Kc6 78. Ra6+ Bxa6 79. Kxa6 Rb3 80. Bd2 Ra3+ 81. Ba5 Ra2 82. d5+ exd5 83. Ka7 Rxa5#

bluefever
Posts: 22
Joined: Wed Jul 10, 2013 8:23 am

Re: Engine In Javascript

Post by bluefever » Tue Jul 23, 2013 10:10 pm

glinscott wrote:Awesome job! Great to see another strong JS engine on the scene :).

I played them against each other at 2s a move, and Garbochess (http://forwardcoding.com/projects/ajaxchess/chess.html) barely prevailed, although it was a toss-up in the midgame for quite a while. My guess is that they are quite close in strength.
Wow, your interface has a lot more features :)

I only did the GUI as a quick hack on top of the engine for the YouTube video series. Since then I've been adding features - I've grown quite fond of the project, it was my first JS program.

I MUST add the actual fen live you have, that is essential. ANd you even have the algebraic move notation. Argh!! :)

I think your engine is stronger though :)

Btw, I had a torrid time getting it to work in IE 9 and older. No const, no console, no typed Arrays..... terrible.

bluefever
Posts: 22
Joined: Wed Jul 10, 2013 8:23 am

Re: Engine In Javascript

Post by bluefever » Tue Jul 23, 2013 10:13 pm

On thing I meant to ask, as I'm new to JS - do you have any tips on not blocking the GUI when the engine is thinking? I notice Garbochess does not. I couldn't find much info on doing this, apart from a webworker, which didn't seem right.

Thanks!

bluefever
Posts: 22
Joined: Wed Jul 10, 2013 8:23 am

Re: Engine In Javascript

Post by bluefever » Wed Jul 24, 2013 3:17 pm

I found a small bug in GarboChess, nothing to do with the playing, but the UI. If I undo moves, it doesn't remove them from the movelist, and adds the new moves on 8-)

It's a great App, though. I added the "current FEN" also today :)

glinscott
Posts: 8
Joined: Mon Jun 14, 2010 6:12 pm
Real Name: Gary Linscott

Re: Engine In Javascript

Post by glinscott » Fri Jul 26, 2013 6:11 am

Yeah, sadly, webworkers are the only way to go really. You can also process the search in chunks, but that basically requires writing an iterative search, which is not as fun.

bluefever
Posts: 22
Joined: Wed Jul 10, 2013 8:23 am

Re: Engine In Javascript

Post by bluefever » Fri Jul 26, 2013 7:00 am

glinscott wrote:Yeah, sadly, webworkers are the only way to go really. You can also process the search in chunks, but that basically requires writing an iterative search, which is not as fun.
Yes, the search in chunks would be a PITA to program.

According to caniuse.com, IE 9 and older do not support webworkers, though :(

Thanks for the answer, I'll have a look into it today

Post Reply