Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] Searching a Dictionary file

Author
Message
Thomas John Gorham
6
Years of Service
User Offline
Joined: 23rd Jun 2018
Location:
Posted: 22nd Dec 2019 04:52
Hi guys im attempting to make a simple game for my Dad.

The premise is simple, you get generated 3 letters and you have to make the longest possible word with those 3 letters in a row.

I dont code often, I havent touched AppGameKit in over a year (eeek) , last thing I made was a simple space invaders game and it took me several weeks.

But anyway I have dived into it. I have downloaded a dictionary txt file with over 100,000 words. I would love to see a little coding example about how to search it. Say entering a string and seeing if it exists in the txt file?

Also is 100,000 + words too big, should I divide it into 26 txt files? One for each letter. Its 4MB in size

Looking forward to your help,
Thomas

The author of this post has marked a post as an answer.

Go to answer

smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 22nd Dec 2019 07:02 Edited at: 22nd Dec 2019 07:05


something along those liens ought to work i would imagine just typed it up real quick

Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 22nd Dec 2019 16:38
I made a similar game once using a dictionary file. But I think I wrote my own binary search routine.

I'd keep it as one file, it should be fine. When you generate the 3 letters, find all the matching words at that time and keep it in memory that way you're not having to search the text file on every user submission.
Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 22nd Dec 2019 18:47 Edited at: 22nd Dec 2019 18:48
This post has been marked by the post author as the answer.
Store your dictionary in an array, then sort it. You can then use the very fast .find() method to search your array.
Thomas John Gorham
6
Years of Service
User Offline
Joined: 23rd Jun 2018
Location:
Posted: 23rd Dec 2019 00:41
This is brilliant! Thanks

Login to post a reply

Server time is: 2024-11-23 08:12:25
Your offset time is: 2024-11-23 08:12:25