Created
January 16, 2015 15:52
-
-
Save jeremyf/4345a7233dda6b7b47d3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby -wU | |
if ARGV[0] =~ /-h/i | |
$stdout.puts "Generates a fantasy demographic of workers by population size." | |
$stdout.puts '' | |
$stdout.puts "./#{File.basename(__FILE__)} 2000" | |
$stdout.puts '' | |
$stdout.puts "Derived from Fantasy Demographics by Robert S Conley, 2010." | |
$stdout.puts "Released under the Creative Commons License Attribution 3.0 Unported." | |
$stdout.puts "You can share, remix, as long you give proper Attribution." | |
$stdout.puts '' | |
$stdout.puts "http://www.batintheattic.com/downloads/Fantasy%20Demographics%20Version%201.pdf" | |
else | |
SIZE = ARGV[0].to_i | |
end | |
# These are broad categories of profession. In the largest medieval settlements | |
# these were finely divided into bewildering array of guilds each dedicated to a | |
# different aspect of a trade. For example fletchers for arrows were different | |
# those who made the arrow shaft which were different than those who made the | |
# arrow heads. For most games this level of detail is overkill and confusing. I | |
# grouped similar professions into the same categories. Here I list each broad | |
# profession and the some of the detailed occupations that can be found under | |
# that category. | |
$stdout.puts "Population: #{SIZE}" | |
[ | |
["Artist", 965], | |
["Baker", 202], | |
["Carpenter", 196], | |
["Chandler", 509], | |
["Clerk", 3_929], | |
["Engineer", 13_750], | |
["Finesmith", 238], | |
["Fisherman", 1_078], | |
["Games", 3_667], | |
["Glassmaker", 1_375], | |
["Harper", 6_875], | |
["Herbalist", 573], | |
["Jeweler", 276], | |
["Laborer", 149], | |
["Leathercrafter", 80], | |
["Legal", 1_222], | |
["Luxury", 18_333], | |
["Mason", 259], | |
["Mercernary", 3_929], | |
["Merchant", 243], | |
["Metalsmith", 529], | |
["Miller", 275], | |
["Miner", 1_618], | |
["Ostler", 322], | |
["Physician", 289], | |
["Pilot", 1_774], | |
["Potter", 2_619], | |
["Religious", 786], | |
["Sailor", 4_583], | |
["Scholar", 353], | |
["Servant", 154], | |
["Shipwright", 3_929], | |
["Tailor", 94], | |
["Tanner", 1_058], | |
["Tavern", 130], | |
["Teamster", 1_122], | |
["Timber", 833], | |
["Weaponsmith", 462], | |
["Weaver", 119] | |
].each do |profession, threshold| | |
number_existing = SIZE / threshold | |
chance_of_one_more = (SIZE - number_existing * threshold) / threshold.to_f | |
if chance_of_one_more > rand | |
number_existing += 1 | |
end | |
if number_existing > 0 | |
puts "* #{profession} #{number_existing}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment