What's the most efficient way to check a value against a large list of items?

Hello all,
I am making a word game (like Scrabble) which requires players to use tiles to make words. I am trying to make it so that the words are checked for validity against a database of words (the entire english dictionary) when played. I was wondering if there some way of simply asking if the value exists in the database without having to loop through every word to find out? Would TMaps help out in this instance? The english language as a text file is around 1.6mb so I imagine it would be quite inefficient to be looping through this every time.

And secondly, would it be possible to populate the word database with an external text file via blueprints?

Any help would be greatly appreciated :slight_smile:

First of all, if you are that much worried about efficiency you should not be using blueprints but c++ instead. Secondly, you should consider using a integrated database solution such as SQlite 3. Implementation and tutorial on forums. (Porting txt to database is pretty easy.)

Scrabble is much more complex with it’s point system, you do not need to add these on the database. Instead, make each tile have a ‘point’>1 integer variable and then calculate the total points if the word exists and is valid for submission.

you can separate your data alphabetically, so if your word begins with an S, you only check through the list of words beginning with the letter S. that way, instead of checking a million entries, you only check 30,000. if you want things to be more efficient, you can break the data down into smaller arrays. so put all the words that begin with “Sh” into its own list, and that will bring that 30,000 items to check, down to about 2,000, which should be fast enough.

if you want to automatically organize your data into an alphabetical tree that can be searched quickly, you might want to look into Btrees:

Ah yes. That sounds like a good option of splitting up the data. What is the equivalent of the b-tree in Unreal? I seem to be just getting ‘behaviour trees’ coming up in my Google searches (sorry, bit of a noob with this stuff - hence the questions :wink: )

So after a bit of searching around it looks like TMaps are probably the thing I am after, but they (still) don’t appear to be accessible from blueprints. Even if created via C++. Can anyone confirm this?