Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: Dwarf Fortress Language Creator & Word Generator  (Read 8350 times)

phi2dao

  • Bay Watcher
    • View Profile
Dwarf Fortress Language Creator & Word Generator
« on: December 01, 2009, 08:13:59 pm »

This is a Dwarf Fortress Language Creator.  It is also a word generator.
I made it in Ruby, so you will need to have ruby installed to use it.  I tested in on both Linux and Windows, so it should work on those.  I haven't tested it on a Mac, so I don't know whether it will work on one or not.  It's pretty basic ruby code though, so I can't think why it wouldn't work on one.

Version 0.9
 - Contains the program and an example language file.

Change log
 - It's the first version

How to use
Using the program is pretty simple.
First, unzip the program.  You should get wordgen.rb and example_lang.txt.
Then, open a command promt/terminal/thingy and go to the directory where you put wordgen.rb.
To create a language file, enter:
Code: [Select]
ruby wordgen.rb --dwarf \path\to\lang.txt \path\to\language_DWARF.txt NAMEIf I wanted to create the Bakemono language, and had a language file called bakemono_lang.txt, I would enter:
Code: [Select]
ruby wordgen.rb --dwarf bakemono_lang.txt C:\Documents and Settings\Phi2Dao\My Documents\Games\Dwarf Fortress\df_28_181_40d15_win\raw\objects\language_DWARF.txt BAKEMONOThis would create a file in my current location called language_BAKEMONO.txt.  Simple, huh.
To use wordgen.rb as a word generator, enter:
Code: [Select]
ruby wordgen.rb -g \path\to\lang.txt 10This would print 10 words to the screen.
Code: [Select]
ruby wordgen.rb -G \path\to\lang.txt \new\file\name.txt 10would create a new file with 10 words in it.
Adding "u" to either -g or -G makes the program generate unique words.
Code: [Select]
ruby wordgen.rb -Gu bakemono_lang.txt testfile.txt 2000would create a file called testfile.txt which would contain 2000 unique words.
NOTE: Don't use -u unless your language file can create that many unique words.  Currently, it locks up if it tries.

Language Files
The language files that wordgen.rb requires are both simple and complicated.  There is an example file included with the download, and you should be sure to look it over.  Some of the help in that file might be weird, because I am really tired right now, and too lazy to fix it.  If you are still confused after what I write below, just post your questions, and I will try and help you.

We will start out with a realy simple language file.  It looks like this:
Code: [Select]
<weight default 1>

<startrule word>

<rule word>
<string SSS>

<rule S>
<string cv>

<symbol a>
<format v>

<symbol b>
<format c>
This file will always produce bababa.  Lets see why.

First, <startrule word>.  This tells the program that the rule it should start with is rule word.
Next, <string SSS>.  This is below <rule word>, so it is a part of rule word.  It tells the program that the word will have three "S", whatever that means.
Next, <rule S>.  Aha!  This is the "S" that rule word was talking about.  what does rule S say?
<string cv>.  This tells the program that each S will have a "c" followed by a "v".
Having figured out that neither "c" nor "v" are rules, the program will look through the formats.
The program sees that symbol b has format c, so for "c" the program puts "b".  It sees that symbol a has format v, so for "v" the program puts "a".  This will occur for each "S" in <string SSS>.  The end result will be "bababa".

Our language file is pretty boring, so lets make some small changes.  If our new language file looks like this:
Code: [Select]
<weight default 1>

<startrule word>

<rule word>
<string SSS>

<rule S>
<string cv>
<string vc>

<symbol a>
<format v>

<symbol b>
<format c 10>

<symbol c>
<format c>
What will wordgen.rb produce?  The answer is, something like "baabab" or "acbaba" or "baacac" or ...
Lets see why.  For one, we added a new <string> to rule word.  When a rule has more than one <string> it randomly picks between them.
Another change was we added a new symbol, and gave it the same format as symbol b.  When a format has more than one symbol, it randomly picks between them.
This file will produce more "b" than "c", though.  This is because the number 10 in <format c 10> makes "b" more likely to occur than "c".  The higher the weight, the more likely the symbol or rule.
You can set the default weight of symbols with the tag <weight default x>.
There is more in example_lang.txt, so be sure to look through it. 

If you have any questions, please post them.
If you have any requests, please post them.
If you want to talk about the weather, please do so.

I'll probably provide some more language files eventually.
Logged

CatalystParadox

  • Bay Watcher
  • hi ho, hi ho...
    • View Profile
Re: Dwarf Fortress Language Creator & Word Generator
« Reply #1 on: October 04, 2012, 04:47:35 pm »

This is a really great tool, and I'm surprised no one has said so before!  An absolute must for a lot of modding.

I don't feel bad for necroing because I imagine a lot of people who didn't know about this will be glad to find out it exists.
Logged
My proud turn in Failcannon | Uzolnom - "Oiledgod"

Quote from: Mego
I opened up the Unread Replies page and saw that you were the last poster. I got scared. Something about you posting scares me, ever since Failcannon.