CREATING A WORD-BASED
By Steven Savage (email@example.com)
Well, after building Generator programs for years, I realized I'd never really written down how I do it. It's not quite an art, and there's definitely a science involved.
When an acquaintance asked me to design a Wrestling Move Generator, I realized I had a perfect chance to detail how I create Generators - and hopefully inspire other people to experiment with their own.
You may not have an interest in wrestling, but the concepts and procedures expressed here can be used in any generator based on combining words.
WHAT IS A WORD-BASED
I consider Generators to be of two kinds - Phrase Based and Word Based. Phrased-Based generators utilize some predefined combinations of words in combination or combined with randomly chosen words - in short, like madlibs. A Word Based generator is a generator that combines only words into (hopefully) grammatically pleasing combinations.
In the case of Wrestling Moves, they are based on combinations of words. So, obviously a Word-Based generator fits.
First of all, in a Word-Based Generator, have an idea of what your target results might be like and analyze them. So, in the case of Wrestling Moves, let's examine some I chose randomly from a great source: http://220.127.116.11/bbbowm/bbbowm.htm.
First of all, in analyzing a larger amount of wrestling moves, I noted a pattern - they're usually two to three words combined in sequence. This is very common for many Word-Based Generators.
Most words in Word-Based Generators can be classified by what I call my DOA system - words can be Descriptors, Objects, or Actors. Descriptors modify Objects and Actors, and Objects may be paired with actors. Descriptors tend to come at the beginning of a sequence, and Actors are at the end, the centerpiece of the Generator code.
In the above examples we have:
Note that Mandible and Trapezius could be considered Descriptors. Some words may pull "double duty" in your Generators.
We can already see that by rearranging the words above we can create credible wrestling moves, such as
This is a good testimony that Wrestling Moves fit the DOA model.
More complex Word-Based Generators will likely break or expand the DOA model, but in most cases you will still have words that modify other words, words associated with other words, and words that are the centerpiece of your Generator.
In the basic DOA pattern, the following rules apply:
In analyzing the wrestling moves, let's stay with 2 and 3 word combinations - any more and we can see some potentially goofy results (Half Mandible Ankle Nelson anyone?). Also, we can expect not to have things be particuarly complex. These rules should suffice:
These will easily generate a lot of wrestling-sounding moves without creating complicated rules.
Now I can't predict what language you'll use. In fact, you may just want to turn whatever you design into tables for dice, so you can stop here.
First of all, there's storing the data. Simply, I use arrays of text, and corresponding to each word I have a binary flag indicating what category or categories the word fits in. In this case:
1 for a Descriptor
2 for an Object
4 For an Action
So something that could be both an Object and an Action would have a "flag" value of 6.
Binary flags are great because you can represent things in one number. However, I find if you have more than 5 categories, it gets confusing. In that case I usually use some kind of text tag to hold information related to the categories it fits in.
Next, I design the code itself. This usually takes a good deal of time and planning - don't rush it. Use those programming skills. Streamline. Comment your code. You'll be glad you did.
In this case, the code is pretty simple. I break it down like this:
If you break things down into separate functions/sections, you can make code work very easily. The code for the generator was designed and implemented in one day, using some pre-existing code for the page and randomization.
Designing a Word-Based Generator is not hard - if you take the time to analyze and plan.
Now, go forth and build!
The final result can be seen at http://www.seventhsanctum.com/gens/wrestling.html