The most flexible database format that D&D Helper supports is the
Phrase Structure Rule grammar style database. Briefly, it expands a rule into
text and other rules.
For example, let's try to make a database say "Jack is going to the
store." All examples are real and do work in my parser. The files are all
simple text files. The source file to generate the sentence is quite
Jack is going to the store.
The first rule in the file is considered the starting rule. So, we start
with [MAIN] and we pick a random rule. Since there is only one, we pick
that one. Let's make this a little more complex by changing the name and
[NAME] is going to the [PLACE].
With the above rules, we can get "Timothy is going to the shed.", "Jack
is going to the library.", "Greg is going to the shed." and others. In
fact, by having 3 names and 3 destinations, we can get a total of 9
Let's make this a bit more interesting and add more description.
[NAME] is [JOINER] the [PLACE].
At the [PLACE], you will find [NAME].
With this lengthy example, you can get a bunch of different
possibilities. "Jack is coming from the shed." "Timothy is crawling nearby
the library." "Steve is walking away from the store." You can see a bunch
By adding another five names or other places, you get the possibility to
create many other phrases. By adding more variances, you can get more
flavor in your statements.
With the above example, you will notice that the JOINER only expands to
three possible rules. The first rule, "[WALK] [TO_FROM]" can expand to many
possibilities, but it only has a 1/3 chance of being picked if JOINER is
used. To make the output look better, we should have the "[WALK] [TO_FROM]"
rule get used more often.
With a JOINER section like this, we give preference to the first rule.
Essentially, we add the numbers on all of the rules. Then, we pick a random
number, then check to see which rule gets it. 10 + 1 + 1 = 12. Picking a
random number, 4, means that we use the first rule. If I pick 11 or 12, we
use the boring "going to" or "coming from" rules. Essentially, the first
rule is 10 times more likely to get picked than an "average" rule.
# This is a completely different example.
# Do not just add this to the above PSR rules
# Also, any line starting with a # is considered
# a comment and will be ignored.
Pick up [OBJECT]. [^OBJECT] is over there.
This example illustrates how you can capitalize the first letter in an
expanded rule. The first rule picks two objects (they may be different or the same) and
the second object has its first letter capitalized. "Pick up the sword. A
kitten is over there." "Pick up an apple. An apple is over there." "Pick
up a kitten. An apple is over there." Additionally, it shows how you can
add comments to your PSR files.
The file format also supports long lines -- just use something like
line to the end of the first one.
Lastly, if you have "[", "]", "[*]", or "[#]" in your rules, it will
convert that into just the "[", "]", "*", or "#" character, respectively.
Newlines can be added by using "\n".
If you make a file and you would like to use it in D&D Helper, just
follow the above guidelines and send it to me. I'll convert it into a
database for you. If you don't mind, I would also like to host it on my
site and distribute it to others.