fix impossible picks

master
Peter Babič 3 years ago
parent 2d1c1ae542
commit 80297b7ac4
Signed by: peter.babic
GPG Key ID: 4BB075BC1884BA40
  1. 13
      src/App.svelte

@ -74,21 +74,22 @@
const change = curr => {
const prev = state.indexOf(pick)
const emptyHoles = [...state.keys()].filter(i => state[i] == hole)
const possibleDests = jumps.adjacencyList[curr].filter(jump =>
emptyHoles.includes(jump)
)
if (state[curr] == pole && prev == -1 && possibleDests.length > 0) {
state[curr] = pick
if (state[curr] == pole && prev == -1) {
let destExists = false
jumps.adjacencyList[curr].forEach(jump => {
const jumpedOver = commonBetween(curr, jump)
if (state[jump] == hole && state[jumpedOver] == pole) {
state[jump] = dest
destExists = true
}
})
if (destExists) {
state[curr] = pick
}
return
}

Loading…
Cancel
Save