Word Games

14 posts

Flag Post

I am new with flash, and am trying to do a word game. Are there any standard dictionary functions? Where do I find a reference for them?


Flag Post

Standard dictionary functions?

Flag Post

I have a string and I want to see if it is in a dictionary.

Flag Post

sounds to me like what you want is to implement a very large list of words that the game will parse through to see if it’s an actual word or not.

Well, being new, I would suggest looking for something else simply because 1: Parsing for words out of a neigh-immeasurable list is some pretty complicated code, and 2: unless there is some hidden dictionary functions you’ll either have to search for some pre-made open-source code or make list manually, which would entail finding a big ol’ list of words and copy-pasting the appropriate code to it to form an array of some sort.

In other words, it’s not that easy. Incoming loads of tedious work. If you’re feeling adventurous you could stick the aformentioned list into some non-flash code so that it goes through and writes the aforementioned appropriate code for you in the output window by using trace statements, but play with it and see. The list can’t be too long, however, because I imagine that using a dictionary of words will quickly cap you out above the 10MB max kongregate stipulates.

Flag Post

If you mean does Flash have a built in database of words, no. You’ll have to assemble or acquire a database yourself, then load the data into Flash. You can then use string functions to analyze the data.

Flag Post

I was partially interested in a datbase of words, but also thought some “search this database for matches” functions, they aren’t hard to write but if they existed already I wanted to use them.

Flag Post

An array of words? Oh no no. What you want for something like this is a hash table (or possibly a trie).

A hash table is a type of data structure made for looking up single arbitrary elements among huge lists in constant time. All you have to do is create a hash table with each word in the dictionary as a key. Values are unimportant, since all you care about is whether a given key exists or not.

It may be “pretty complicated code” behind the scenes, but all you need to create the table is at most a couple lines of code to loop through a list of words and add them to the table, and then you can use single statements for looking them up.

As for where you’d find an appropriate list of words, that, I don’t know. But it shouldn’t be too hard.

/me glances through an Actionscript reference

Um… Actionscript does have hash tables, right? I can’t find anything on them…

Flag Post

eh heh, is owned an appropriate word for right now?

Although, if it’s not built into AS, it’s easy to make your own, assuming, of course, it’s something that can be made on one’s own without beating your head into your desk repeatedly.

I believe this information can be quite valuable, do go on sir.

Flag Post

Huh. Upon further reading, it seems all objects in flash are hashtables or use hashtables to keep track of their components. Or something weird like that. So you can create any random empty object and use it as a hashtable.

So, to create the table, it would be something like this:

var wordtable:Object = new Object();
for (each word in list){
   wordtable[word] = true;

And for checking if a word exists:

if (wordtable[word] == true){do whatever}

I’m not at all sure if this is the best way, or if it’s how one is supposed to go about doing this… it’s certainly not what I expected, yet from initial testing to make sure I’m not going crazy, it works.

(Is there a help page that explains this forum’s weird formatting? I can’t find one, and I can’t get the pseudocode to look right.)

Flag Post

As for getting the wordlist into your array/hash, this will prove the more complex problem. There are only two ways I know of to get a bunch of data in, the first being you can hardcode all the values of the array by just making an AS file that loads every word into your datastructure. This is actually the smaller and quicker solution, and I do it a lot for large bits of data rather than use the xml parser thing.

The other way is the XML route, as xml is the only file format that flash supports. This will require you to write or find an XML formatted dictionary and then write a parser for it.

Fun times either way, IMHO reading in large streams of data is the most enjoyable and rewarding facet of game programming.

Flag Post

It is correct you would want to avoid an array, as looping through them would be slow. Hash tables are definitely much faster for direct look ups.

You may search some of these links for downloadable lists just did a quick search):




I was partially interested in a datbase of words, but also thought some “search this database for matches” functions, they aren’t hard to write but if they existed already I wanted to use them.

Getting the database is the hard part, writing the functions is easy. You’re just checking for string equality and possibly splitting the string into smaller parts and checking those, all fairly easy for the most part. If you want prefabricated string functions, you can search for some ActionScript string libraries.

The other way is the XML route, as xml is the only file format that flash supports.

Actually, in additional to XML you can read text file value pairs (&var1=Value). On top of that, in AS3 you can read any type of data you wish, as Flash supports the streaming in of binary data and parsing the bytes however you like; extending the possibilities a long way.

I can’t get the pseudocode to look right.

Code formatting info is in the sticky. I edited your post so you can see.

Flag Post

terrific! thanks for help

Flag Post

Aha, it’s in that sticky! Silly me, I only looked in the general help sticky. >.>


Regarding storage and importing of a word list: does Actionscript support serialization in any way?

Flag Post

Im a bit of a noob to flash myself, but is there no way to make it look into a website say dictionary.com, and check in there? I dont really know, but…