How do I Store and check all English words?

0 favourites
  • 3 posts
From the Asset Store
290 static tiles (32x32 in size) + 2 animations for use in your project!
  • Hi,

    I'm trying to create a word game and I need to store basically the entire dictionary. I'm trying to check if words exist at run-time

    How can I do this?

    I downloaded a massive text file with 300,000 words, put it in a .json, and then loaded it into an array at run-time, but when I check if certain words are in the array it doesn't work

  • Have you confirmed that the array is loaded properly? What are you using to check, array.indexof()? If the string has to match exactly, make sure you're not adding any unnecessary characters like spaces when populating your array.

    Also it might be worth trying to use the dictionary object and the "Has Key" condition instead. I suspect it could be significantly more efficient for searching through large amounts of strings, although I haven't tried it myself.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I will say I downloaded one of those so called english word lists and most of them don't look like words to me, but anyways.

    Here is a test to load such a wordlist into a dictionary without hanging the browser. Once loaded it's as simple as the "has key" dictionary condition.

    As far as speed goes, its way faster to have the words in a dictionary instead of an array if you need to find if a word is in it.

    With an array it would have the worst case of having to look at every single word before finding it.

    You can do a binary search since the words are sorted to improve that. Maybe a worst case of checking 40% of the words.

    With a dictionary it finds the word more or less directly.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)