Greasy Fork is available in English.

WordSleuth

A script that helps you guess words in skribblio

< Opinie na WordSleuth

Ocena: Dobry - skrypt działa

§
Napisano: 25-06-2023

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.

§
Napisano: 25-06-2023

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);

fermionAutor
§
Napisano: 25-06-2023

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.

Odpowiedz

Zaloguj się, by odpowiedzieć.