Skip to content

Commit

Permalink
move PvE code to store.js
Browse files Browse the repository at this point in the history
  • Loading branch information
ksthicke committed May 17, 2024
1 parent 90988f7 commit dcbbe1f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 26 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
4 changes: 3 additions & 1 deletion src/renderer/engine/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@ export default class EngineDriver {
break
}
case 'bestmove':
this.events.emit('bestmove')
const words = line.split(' ')
const ucimove = words[1]
this.events.emit('bestmove', ucimove)
break
}
}
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 dcbbe1f

Please sign in to comment.