Greasy Fork is available in English.

WordSleuth

A script that helps you guess words in skribblio

< Feedback on WordSleuth

Review: Good - script works

§
Posted: 2023.06.25.

When guessing in chat, a message saying "[word] is close!" might appear. It seems to happen when the guessed word is only one letter away from the correct word.

You might be able to use this message to narrow down suggestions by learning the conditions for triggering the message.

§
Posted: 2023.06.25.

Here is the idea. Not sure if the code works, I never ran it.

function removeDissimilarWords(filterWord, wordList) {
var filteredList = [];

for (var i = 0; i < wordList.length; i++) {
var word = wordList[i];

if (filterWord.length !== word.length) {
continue;
}

var diffCount = 0;

for (var j = 0; j < filterWord.length; j++) {
if (filterWord[j] !== word[j]) {
diffCount++;

if (diffCount > 1) {
break;
}
}
}

if (diffCount <= 1) {
filteredList.push(word);
}
}

return filteredList;
}

// Example
var filterWord = "hit";
var wordList = ["hit", "him", "hot", "fit", "hey", "got", "day"];

var filteredWords = removeDissimilarWords(filterWord, wordList);
console.log(filteredWords);

fermionAuthor
§
Posted: 2023.06.25.

Thank you for the suggestion. I have implemented it and added observable hints to the chat. You can see how I did it by checking the history tab on GreasyFork. I utilized a technique called the Levenshtein distance to efficiently measure the difference between the strings.

Post reply

Sign in to post a reply.