glinscott / Garbochess-JS

A strong javascript chess engine using WebWorkers
http://forwardcoding.com/projects/ajaxchess/chess.html
Other
310 stars 100 forks source link

How to use the postmessage API? #10

Closed barneycarroll closed 11 years ago

barneycarroll commented 11 years ago

There's a neat little onmessage listener at the bottom of garbochess.js that implies a decoupling of player 2 from the AI. I've tried sending simple SAN moves, but I always get a busted! (FEN description) alert response. What's the right way to use this?

glinscott commented 11 years ago

https://github.com/glinscott/Garbochess-JS/blob/master/js/boardui.js is the code for interfacing with the worker. Look for the g_backgroundEngine.postMessage() calls.

The moves are formatted as "from square, to square", not in SAN. So, for example, "e4" then "Nc6" would be "e2e4" then "b8c6".