Town Generator Script

As you may know I’m getting back in to D&D after years of not playing. (Anyone in north Houston with a group that could use a player drop me a line.) Right now I’m working on a campaign world. And last night I came to the point I needed to generate some towns. I read in the DM’s guide how to do this randomly and even did it once.

But then my inner geek came out and I spend the next 4 or 5 hours writing a Ruby script to generate random D&D towns. This script will generate a random town for you each time it is run. It has one optional parameter – the name of the town size as given in the DM’s guide.

After you follow the link above and download the script, if you are running MacOS X (and probably Linux) you go to the command line and type:

ruby CityGen.rb

And hit return. It will spit out a bunch of text that you can copy and paste into a word processor for use. There is some strange output for the race demographic table. This is because the code uses tabs to make it easier to use the table in a word processor. The command line doesn’t like that.

If you include a town size like “Thorp” it will generate that size town, and not randomly pick the type.

ruby CityGen.rb Thorp


Generating city
Town Size: Hamlet
Population: 206
GP Limit: 100
Cash available: 1000

Power Centers
1. Type: Conventional
Alignment: Neutral Evil

Community Authorities
Sheriff is the highest level warrior
There are 2 full time guard(s) and 10 militia members
1 3rd level adept
1 2nd level commoner
1 2nd level expert
1 1st level barbarian
1 3rd level bard
2 1st level bards
1 1st level cleric
1 2nd level driud
2 1st level driuds
1 3rd level fighter
2 1st level fighters
1 1st level paladin
1 6th level rogue
2 3rd level rogues
4 1st level rogues
1 2nd level sorcerer
2 1st level sorcerers

The rest of the population
164 first level commoners
9 first level warriors
5 first level experts

Race Isolated Mixed Integrated
Humans 201 162 76
Halfling 4 18 41
Elf 2 10 37
Dwarf 2(other races) 6 20
Gnome 14 14
Half-elf 10 10
Half-orc 2 6

Anyway enjoy. I may make it take a flag that generates HTML

Did I mention that every new computer language I’ve every learned I learn making a D&D program, with the possible exception of ObjectiveC.

Written while listening to “Message In A Bottle”
album Every Breath You Take- The Singles
by The Police