Created
January 5, 2012 19:16
-
-
Save jadonk/1566737 to your computer and use it in GitHub Desktop.
Test stockfish performance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env node | |
| var child_process = require('child_process'); | |
| var stockfish = child_process.spawn('time', [ './stockfish' ]); | |
| stockfish.stderr.setEncoding('ascii'); | |
| stockfish.stderr.on('data', function(data) { | |
| console.error(data.replace(/\n$/, '')); | |
| }); | |
| stockfish.stdout.setEncoding('ascii'); | |
| var stockfish_write = function(cmd) { | |
| console.log(cmd); | |
| stockfish.stdin.write(cmd + '\n'); | |
| }; | |
| stockfish_write('uci'); | |
| stockfish.stdout.on('data', function(data) { | |
| console.log(data.replace(/\n$/, '')); | |
| if(data.match(/^uciok/m)) { | |
| stockfish_write('position fen r1bqkbnr/pp2pppp/2n5/2ppP3/3P4/3B1N2/PPP2PPP/RNBQK2R b KQkq - 3 5'); | |
| stockfish_write('isready'); | |
| } else if(data.match(/^readyok/m)) { | |
| stockfish_write('go depth 14'); | |
| } else if(data.match(/^bestmove/m)) { | |
| stockfish_write('quit'); | |
| stockfish.stdin.end(); | |
| } | |
| }); | |
| stockfish.on('exit', function(code) { | |
| console.error('stockfish exited with code ' + code); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment