Skip to content

Commit

Permalink
Crazyhouse fix and engine toggle fix (#275) (closes #257)
Browse files Browse the repository at this point in the history
* fix crazyhouse drag issue

* remove log messages

* move PvE code to store.js

* remove ignore

* make linter happy
  • Loading branch information
ksthicke authored May 17, 2024
1 parent a835dc8 commit b0f8e65
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 35 deletions.
22 changes: 0 additions & 22 deletions src/renderer/components/PVLines.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
6 changes: 4 additions & 2 deletions src/renderer/components/SettingsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
15 changes: 5 additions & 10 deletions src/renderer/engine/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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')
Expand Down Expand Up @@ -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
}
}
}

Expand Down Expand Up @@ -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':
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/engine/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
})

Expand Down
7 changes: 7 additions & 0 deletions src/renderer/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
},
Expand Down Expand Up @@ -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))
})()

0 comments on commit b0f8e65

Please sign in to comment.