How does it work?
When the user clicks "Create Story!", a series of functions are called that work together to build one massive character string. The randomness exists solely in word choice. The structure of the story as a whole is rather rigid; the majority of the words that appear in each sentence are the same every time. About 15-20% of the words are generated by one of 40 different "word type" functions that store lists of words. Each of these 40 functions is characterized by a unique word type, such as "vividAdjective" or "goodPersonalityTraitNoun". With 30 words per word type function, the dictionary holds 1200 words/phrases. Pronouns were a little tricky, though more annoying than difficult. Click here to download the script and see exactly how this problem was resolved.
Doesn't that mean the story is basically the same each time?
For the most part, yes. Early versions of the program were much more random, but were not remotely coherent. It became evident that in order to generate somewhat coherent stories while maintaining randomness, the following things would need to be randomized: number of paragraphs, number of sentences per paragraph, number of words per sentence. To maintain an interesting narrative, there would have to be a distinction between how to build the intro paragraph, closing paragraph, and "filler paragraphs". Likewise, there would have to be stored groups (string arrays) of starter sentences, closing sentences, transition sentences, filler sentences...etc. After building this elaborate framework, composition of a story template that produced both interesting and coherent stories would be even more daunting. The amount of brainstorming to make all the sentence types and paragraph types flow together was truly overwhelming. Ultimately I settled on building a rigid template that produces consistently amusing stories (...so I like to think).
How can the program apply tone?
Of the 30 words in each word type function, 10 are default, 10 are sarcastic, and 10 are "extremely" random. Depending one what the user specifies, the program only looks at some of the words in that function. (In programming terms, the word type functions receive two arguments, "high" and "low". The math.random method then is multiplied across only the range of string array indeces specified by the parameters. Again, check the script if you're interested).
How does the ending type work?
Nothing fancy here -- there are two preset strings (loaded with word type function calls, just like the main story body) that are used each time. The ending is string is then concatenated to the body string.
Do you regret building this?
Derek Clark, email@example.com
Copyright © www.the-elite.net ~ 2004-2005