d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Where To Store List Of Words
12Next
Add Reply New Topic New Poll
Member
Posts: 6,325
Joined: Dec 2 2007
Gold: 2,347.75
Aug 26 2012 02:53pm
I want to make a game where the user should guess a word, but I don't know where I should store the words? For example: the user must guess a word that is 10 letters long and then the program would randomly find a word for the user to guess. I would not assume that I should make arrays and make it static, and .txt files is just a little to easy to edit.

What do you suggest?

PS. I would have a list of words with 5, 6, 7 ,8 ... letters and so on, and do you think they should be stored in different files or just the same to later be filtered out?
Member
Posts: 16,144
Joined: Mar 27 2008
Gold: 14,618.00
Aug 26 2012 03:00pm
how many words?
what programming language?
what u need this program for? (does the wordlist need to be extendable by other users?)
Member
Posts: 6,325
Joined: Dec 2 2007
Gold: 2,347.75
Aug 26 2012 03:11pm
Quote (Richter @ 26 Aug 2012 22:00)
how many words?
what programming language?
what u need this program for? (does the wordlist need to be extendable by other users?)


1: as many as possible, because the words should get pulled out randomly from the bucket if you know what i mean
2: c++, sooner or later to be ported to objective c for an iphone game.
3: need the program / game as a hobby project just for practicing. The wordlist is "secret" meaning no. the end user should not be able to manipulate the wordlist nor see it.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 26 2012 03:14pm
Quote (Utunity @ Aug 26 2012 05:11pm)
1: as many as possible, because the words should get pulled out randomly from the bucket if you know what i mean
2: c++, sooner or later to be ported to objective c for an iphone game.
3: need the program / game as a hobby project just for practicing. The wordlist is "secret" meaning no. the end user should not be able to manipulate the wordlist nor see it.


can you explain why this needs to be a secret? i assume the list will contain hundreds of thousands of words (or some other large number). i don't see how it's going to help the user.

can you explain why a database is insufficient? perhaps store it on a server somewhere, and you can push the words to the devices over time.

for the short term, just abstract it out. create a function that says "getNextWord" and build your game from there. later, you can change the data store to whatever you want.

This post was edited by carteblanche on Aug 26 2012 03:16pm
Member
Posts: 6,325
Joined: Dec 2 2007
Gold: 2,347.75
Aug 26 2012 04:34pm
Quote (carteblanche @ 26 Aug 2012 22:14)
can you explain why this needs to be a secret? i assume the list will contain hundreds of thousands of words (or some other large number). i don't see how it's going to help the user.

can you explain why a database is insufficient? perhaps store it on a server somewhere, and you can push the words to the devices over time.

for the short term, just abstract it out. create a function that says "getNextWord" and build your game from there. later, you can change the data store to whatever you want.


well isn't that secret, but it needs to be offline though, and for now i'm just using a txt file, but just wondered if there were any more sufficient ways to do it. Without internet connection though.
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Aug 26 2012 04:50pm
sign and encrypt a plaintext dictionary
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
Aug 26 2012 05:20pm
Quote (Utunity @ Aug 26 2012 06:34pm)
well isn't that secret, but it needs to be offline though, and for now i'm just using a txt file, but just wondered if there were any more sufficient ways to do it. Without internet connection though.


when i say push to devices, i mean for updates. after the initial install you sync the words and store it locally. after that you do online updates which are stored locally.

Quote (irimi @ Aug 26 2012 06:50pm)
sign and encrypt a plaintext dictionary


im not very familiar with using encrypted files. can you do it in such a way that you dont need to decrypt or read the entire file just to get one word? i guess encrypt each line, then use file pointers to jump to a random line?
Member
Posts: 30,717
Joined: Sep 19 2007
Gold: 254.00
Aug 26 2012 06:15pm
Quote (carteblanche @ 26 Aug 2012 17:20)
when i say push to devices, i mean for updates. after the initial install you sync the words and store it locally. after that you do online updates which are stored locally.



im not very familiar with using encrypted files. can you do it in such a way that you dont need to decrypt or read the entire file just to get one word? i guess encrypt each line, then use file pointers to jump to a random line?


yes
block ciphers
DES works, this doesn't have to be super secure. And even then, it might be overkill for what you're doing. Try ROT 13 if you want something dumb and easy.

You could also decide to include the words in the executable's code instead of an external file.
http://stackoverflow.com/questions/3743120/a-way-to-read-data-out-of-a-file-at-compile-time-to-put-it-somewhere-in-applicat


D has a way cooler way to do this: http://dlang.org/expression.html#ImportExpression
you can literally do
Code
static string text = import("file.txt");
and it will do it at compile time
Member
Posts: 4,605
Joined: Sep 15 2011
Gold: 9,464.00
Aug 26 2012 11:33pm
Quote (carteblanche @ Aug 26 2012 04:20pm)
im not very familiar with using encrypted files. can you do it in such a way that you dont need to decrypt or read the entire file just to get one word? i guess encrypt each line, then use file pointers to jump to a random line?


well, I'm sure there are ways to do that (as pointed out above).

but i'm kind of assuming that the OP's program is dead simple - that is, the dictionary can be loaded fully into memory and used as such, and that the text file is really there for persistence more than anything else... in which case, you don't need to be able to decrypt it piecewise.

and if readable by user isn't actually a big deal (you just dont want them to modify it), you don't even need all that jazz. all you really need to do is to validate the file's checksum.

This post was edited by irimi on Aug 26 2012 11:34pm
Member
Posts: 9,830
Joined: Jun 15 2009
Gold: 11.00
Aug 27 2012 04:56pm
Depending on what you mean by "secret" the answer might vary.

If you put the wordlist in the executable I assume something like a simple strings command would pull out the word list but would be sufficient to hide them from your average user
Go Back To Programming & Development Topic List
12Next
Add Reply New Topic New Poll