However, there is a var STOCKFISH with a postMessage method, but I believe using it needs the Worker running, which is probably best, because it doesn’t block the UI.
I’ve build on Mike’s foundation and added a little interaction, like loading a board via Forsyth–Edwards Notation ( FEN ) . Here’s a session:
0000 ==> isready
0000 <== readyok
0002 ==> uci
0002 id name Stockfish.js 10 by T. Romstad, M. Costalba, J. Kiiski, G. Linscott, D. Dugovic, F. Fichter, N. Fiekas, et al.
0002
0002 option name Debug Log File type string default
0002 option name Contempt type spin default 24 min -100 max 100
0002 option name Analysis Contempt type combo default Both var Both var Off var White var Black
0002 option name Threads type spin default 1 min 1 max 1
0002 option name Hash type spin default 16 min 16 max 16
0002 option name Clear Hash type button
0002 option name Ponder type check default false
0002 option name MultiPV type spin default 1 min 1 max 500
0002 option name Skill Level type spin default 20 min 0 max 20
0002 option name Move Overhead type spin default 30 min 0 max 5 000
0002 option name Minimum Thinking Time type spin default 20 min 0 max 5 000
0002 option name Slow Mover type spin default 84 min 10 max 1 000
0002 option name nodestime type spin default 0 min 0 max 1 0000
0002 option name UCI_Chess960 type check default false
0002 option name UCI_Variant type combo default chess var chess
0002 option name UCI_AnalyseMode type check default false
0002 option name Skill Level Maximum Error type spin default 200 min 0 max 5 000
0002 option name Skill Level Probability type spin default 128 min 1 max 1 000
0002 <== uciok
0004 ==> ucinewgame
0005 ==> position fen N7/P3pk1p/3p2p1/r4p2/8/4b2B/4P1KP/1R6 w - - 0 34
0006 ==> go depth 3
0006 info depth 1 seldepth 1 multipv 1 score cp 32 nodes 47 nps 7833 time 6 pv a8c7 e3a7 bmc 1
0006 info depth 2 seldepth 2 multipv 1 score cp 11 nodes 95 nps 10555 time 9 pv a8b6 a5a7 bmc 1.517
0006 info depth 3 seldepth 3 multipv 1 score cp 24 nodes 151 nps 12583 time 12 pv a8b6 a5a7 b6c4 bmc 0.784289
0006 <== bestmove a8b6 ponder a5a7
0008 ==> d
0008
0008 +---+---+---+---+---+---+---+---+
0008 | N | | | | | | | |
0008 +---+---+---+---+---+---+---+---+
0008 | P | | | | p | k | | p |
0008 +---+---+---+---+---+---+---+---+
0008 | | | | p | | | p | |
0008 +---+---+---+---+---+---+---+---+
0008 | r | | | | | p | | |
0008 +---+---+---+---+---+---+---+---+
0008 | | | | | | | | |
0008 +---+---+---+---+---+---+---+---+
0008 | | | | | b | | | B |
0008 +---+---+---+---+---+---+---+---+
0008 | | | | | P | | K | P |
0008 +---+---+---+---+---+---+---+---+
0008 | | R | | | | | | |
0008 +---+---+---+---+---+---+---+---+
0008
0008 Fen: N7/P3pk1p/3p2p1/r4p2/8/4b2B/4P1KP/1R6 w - - 0 34
0008 Key: 4E025494EA4A7523
0008 Checkers:
0008 <== Legal uci moves: a8b6 a8c7 h3g4 h3f5 b1a1 b1c1 b1d1 b1e1 b1f1 b1g1 b1h1 b1b2 b1b3 b1b4 b1b5 b1b6 b1b7 b1b8 g2f1 g2g3 g2h1 g2f3