Open TowelSniffer opened 1 year ago
I think I may have figured this one out. Make these changes to the FRONT template:
navigate
function as follows to tell the nextMove
function how many candidate moves there are to choose from (i.e., current.children.length
):function navigate(x, y, shiftKey) {
var i, move,
children = current.children;
// Look for move at same location in children
for (i = 0; i < children.length; i++) {
move = children[i].move;
if (move && move.x === x && move.y === y) {
current = children[i]; // Navigate to child if found
// Notify navigation (with no tree edits)
notifyListeners({
navChange: true
});
document.getElementsByClassName("besogo-diagram")[0].style.pointerEvents = "none";
var myTimeout = setTimeout(nextMove, 200, current.children.length);
return true;
}
}
if (!solvedState) {
errorCount++;
if (errorCount === handicap) {
errorCount = 0;
nextMove(current.children.length);
var myTimeout = setTimeout(nextMove, 200, current.children.length);
}
solvedColour = "#670A0A";
if (Persistence.isAvailable()) { Persistence.setItem("solvedColour", solvedColour); };
}
return false;
}
nextMove
function as follows to randomly select from the candidate moves:function nextMove(siblings=1) {
sibling = Math.floor(Math.random()*siblings);
document.querySelector('[title="Next node"]').click();
for (let i = 0; i < sibling; i++) {
document.querySelector('[title="Next sibling"]').click();
}
document.getElementsByClassName("besogo-diagram")[0].style.pointerEvents = "auto";
}
P.S. My version of navigate
above has also been modified to pass solvedColour
rather than errorCheck
to the BACK template. See my comments in #8.
I would like to have the puzzle be able to randomly choose lines to respond with.