UNPKG

node-uci

Version:

Universal Chess Interface protocol implementation for node.js

44 lines (41 loc) 940 B
export default function goCommand(options) { let cmd = 'go' const commands = [ 'searchmoves', //[moves] 'ponder', //bool 'wtime', //msec 'btime', //msec 'winc', //msec 'binc', //msec 'movestogo', //>0 'depth', //>0 'nodes', //>0 'mate', //>0 'movetime', //msec 'infinite', //bool ] commands.forEach(command => { if (!Object.prototype.hasOwnProperty.call(options, command)) return switch (command) { //array case 'searchmoves': if (options[command].length) { cmd += ' searchmoves ' + options[command].join(' ') } break //bool case 'ponder': case 'infinite': if (options[command]) { cmd += ` ${command}` } break //rest are >= 0 default: if (options[command] >= 0) { cmd += ` ${command} ${options[command]}` } } }) return `${cmd}` }