@@ -8,6 +8,7 @@ ffish['onRuntimeInitialized'] = () => {
88 console . log ( `ffish.info(): ${ ffish . info ( ) } ` )
99}
1010
11+ // TODO: Maybe get rid of WebSocket server all together and communicate with vuex-store directly
1112const wss = new WebSocket . Server ( {
1213 port : 8082
1314} )
@@ -55,8 +56,8 @@ Converts a string given uci pv line into a string of san move notation.
5556*/
5657function extractPV ( gameFEN , rawPV ) {
5758 let movesStr = rawPV . split ( ' ' )
59+ // TODO: Make this variant specific
5860 let board = new ffish . Board ( 'crazyhouse' , gameFEN )
59- // let board = new ffish.Board('chess', gameFEN);
6061 let sanPV = board . variationSan ( rawPV )
6162 board . delete ( )
6263
@@ -70,7 +71,6 @@ class CLICreator {
7071 this . idAuthor = null
7172 this . stdIO = [ ]
7273 this . child = null
73- // this.ourWs = null
7474 this . multipv = [ {
7575 depth : 0 ,
7676 seldepth : 0 ,
@@ -155,31 +155,42 @@ class CLICreator {
155155 }
156156 }
157157 /*
158- Sends the move destinations via WebSocket
158+ Sends the move destinations via WebSocket.
159159 */
160160 sendMoveDestinations ( ) {
161161 ourWs . send ( JSON . stringify ( {
162162 destinations : this . destinations
163163 } ) )
164164 }
165+ /*
166+ Sends 'isready', 'go infinite' commands to the engine.
167+ */
165168 goEngine ( ) {
166169 let message
167170 message = 'isready' + os . EOL
168171 this . child . stdin . write ( message )
169- // message = 'go movetime 1000' + os.EOL;
170172 message = 'go infinite' + os . EOL
171173
172174 this . child . stdin . write ( message )
173175 this . stdIO . push ( '>' + message )
174176 }
177+ /*
178+ Resets the current member variables.
179+ */
175180 reset ( ) {
176181 this . update = false
177182 this . curPVLines = 0
178183 this . stdIO = [ ]
179184 }
185+ /*
186+ Closes the active engine.
187+ */
180188 closeEngine ( ) {
181189 this . child . stdin . write ( 'close' )
182190 }
191+ /*
192+ Starts the engine binrary and parses the UCI replies.
193+ */
183194 startEngine ( ) {
184195 console . log ( `this.engineBinary: ${ this . engineBinary } ` )
185196 this . child = childProcess . exec ( './' + this . engineBinary , {
@@ -203,11 +214,10 @@ class CLICreator {
203214 output : this . child . stdin
204215 } )
205216
217+ // parse a PV-line e.g.:
218+ // info depth 17 seldepth 27 multipv 1 score cp 60 nodes 1008782 nps 1007774 hashfull 468 tbhits 0 time 1001 pv e2e4 e7e5
206219 this . rl . on ( 'line' , ( line ) => {
207220 line = line . trim ( )
208- // console.log(line)
209- // let re = /cp (\d+)/;
210- // <info depth 17 seldepth 27 multipv 1 score cp 60 nodes 1008782 nps 1007774 hashfull 468 tbhits 0 time 1001 pv e2e4 e7e5
211221
212222 if ( line . startsWith ( 'info ' ) ) {
213223 let re = new RegExp ( 'multipv (\\d+)' )
0 commit comments