diff --git a/src/renderer/components/PVLines.vue b/src/renderer/components/PVLines.vue index 3a677fd..82ddaf3 100644 --- a/src/renderer/components/PVLines.vue +++ b/src/renderer/components/PVLines.vue @@ -151,28 +151,6 @@ export default { this.originalMultiPV = this.engineSettings.MultiPV this.updateLines() }, - enginetime () { - if (this.active && this.PvE && !this.turn) { - if (this.PvEValue === 'time') { - if (this.enginetime >= this.PvEInput) { - if (this.lines[0] != null) { - this.onClick(this.lines[0]) - } - } - } else if (this.PvEValue === 'nodes') { - if (this.enginetime === 60000) { - this.onClick(this.lines[0]) - } - } else if (this.PvEValue === 'depth') { - if (this.enginetime === 60000) { - this.onClick(this.lines[0]) - } - if (this.enginetime >= 5000 && this.depth === this.seldepth) { - this.onClick(this.lines[0]) - } - } - } - }, nodes () { if (this.active && this.PvE && !this.turn) { if (this.PvEValue === 'nodes') { diff --git a/src/renderer/components/SettingsTab.vue b/src/renderer/components/SettingsTab.vue index fc68415..2c61b9b 100644 --- a/src/renderer/components/SettingsTab.vue +++ b/src/renderer/components/SettingsTab.vue @@ -252,12 +252,14 @@ export default { case 'nodes': this.$store.dispatch( 'setPvEParam', - 'go nodes ' + this.PvEInput * 1000000 + 'go nodes ' + this.PvEInput * 1000000 + ' movetime 60000' ) this.$store.dispatch('setPvEInput', this.PvEInput * 1000000) break case 'depth': - this.$store.dispatch('setPvEParam', 'go depth ' + this.PvEInput) + this.$store.dispatch( + 'setPvEParam', + 'go depth ' + this.PvEInput + ' movetime 60000') this.$store.dispatch('setPvEInput', this.PvEInput) break default: diff --git a/src/renderer/engine/driver.js b/src/renderer/engine/driver.js index a86c6cc..6248c38 100644 --- a/src/renderer/engine/driver.js +++ b/src/renderer/engine/driver.js @@ -26,7 +26,6 @@ export default class EngineDriver { */ constructor (input, output) { this.events = new EventEmitter() - this.ignore = false this.ready = false this.pendingReady = false this.info = { @@ -67,12 +66,6 @@ export default class EngineDriver { _parseLine (line) { this.events.emit('line', line) line = line.trim() - if (this.ignore) { - if (line.startsWith('bestmove')) { - this.ignore = false - } - return - } switch (line.split(/\s/)[0].trim()) { case 'uciok': this.events.emit('initialized') @@ -121,9 +114,12 @@ export default class EngineDriver { this.events.emit('info', info) break } - case 'bestmove': - this.events.emit('bestmove') + case 'bestmove': { + const words = line.split(' ') + const ucimove = words[1] + this.events.emit('bestmove', ucimove) break + } } } @@ -158,7 +154,6 @@ export default class EngineDriver { case 'quit': return await this.quit() case 'stop': - this.ignore = true this._write(cmd) break case 'setoption': diff --git a/src/renderer/engine/index.js b/src/renderer/engine/index.js index 31a075b..90ae214 100644 --- a/src/renderer/engine/index.js +++ b/src/renderer/engine/index.js @@ -60,7 +60,7 @@ export class Engine extends EventEmitter { // run main engine this.mainWorker.postMessage({ - payload: { binary, cwd, listeners: ['io', 'info'] }, + payload: { binary, cwd, listeners: ['io', 'info', 'bestmove'] }, type: 'run' }) diff --git a/src/renderer/store.js b/src/renderer/store.js index 9310b46..60c2902 100644 --- a/src/renderer/store.js +++ b/src/renderer/store.js @@ -690,6 +690,12 @@ export const store = new Vuex.Store({ engine.send(context.getters.PvEParam) context.commit('setEngineClock') }, + PvEMakeMove (context, payload) { + const state = context.state + if (state.active && state.PvE && !state.turn) { + context.dispatch('push', { move: payload, prev: context.getters.currentMove[0] }) + } + }, setActiveTrue (context) { context.commit('active', true) }, @@ -1471,4 +1477,5 @@ ffish.onRuntimeInitialized = () => { // capture engine info engine.on('info', info => store.dispatch('updateMultiPV', info)) + engine.on('bestmove', move => store.dispatch('PvEMakeMove', move)) })()