Documentation ¶
Overview ¶
Package gendemographics is based on Medieval Demographics Made Easy by S. John Ross.
Index ¶
Constants ¶
const ( PopulationDensityLow = 20 // population per sqmile PopulationDensityMedium = 40 // population per sqmile PopulationPerSqmAgriculture = 120 // 1 sqmile can feed 120 people PopulationPerCastle = 50000 // 1 castle per 50k people )
Various constants.
Variables ¶
var ( BizShoeMaker = &BusinessType{Name: "Shoemaker", Serves: 150} BizFurrier = &BusinessType{Name: "Furrier", Serves: 250} BizMaidservant = &BusinessType{Name: "Maidservant", Serves: 250} BizTailor = &BusinessType{Name: "Tailor", Serves: 250} BizBarber = &BusinessType{Name: "Barber", Serves: 350} BizJeweler = &BusinessType{Name: "Jeweler", Serves: 400} BizTavern = &BusinessType{Name: "Taverns/Restaurant", Serves: 400} BizOldClothes = &BusinessType{Name: "Old-clothes", Serves: 400} BizPastryCook = &BusinessType{Name: "Pastrycook", Serves: 500} BizMason = &BusinessType{Name: "Mason", Serves: 500} BizCarpenter = &BusinessType{Name: "Carpenter", Serves: 550} BizWeaver = &BusinessType{Name: "Weaver", Serves: 600} BizChandler = &BusinessType{Name: "Chandler", Serves: 700} BizMercer = &BusinessType{Name: "Mercer", Serves: 700} BizCooper = &BusinessType{Name: "Cooper", Serves: 700} BizBaker = &BusinessType{Name: "Baker", Serves: 800} BizWaterCarrier = &BusinessType{Name: "Water carrier", Serves: 850} BizScabbardmaker = &BusinessType{Name: "Scabbardmaker", Serves: 850} BizWineSeller = &BusinessType{Name: "Wine-seller", Serves: 900} BizHatmaker = &BusinessType{Name: "Hatmaker", Serves: 950} BizSaddler = &BusinessType{Name: "Saddler", Serves: 1000} BizChickenButcher = &BusinessType{Name: "Chicken Butcher", Serves: 1000} BizPursemaker = &BusinessType{Name: "Pursemaker", Serves: 1100} BizWoodseller = &BusinessType{Name: "Woodseller", Serves: 2400} BizMagicShop = &BusinessType{Name: "Magic-shop", Serves: 2800} BizBookbinder = &BusinessType{Name: "Bookbinder", Serves: 3000} BizButcher = &BusinessType{Name: "Butcher", Serves: 1200} BizFishmonger = &BusinessType{Name: "Fishmonger", Serves: 1200} BizBeerSeller = &BusinessType{Name: "Beer-seller", Serves: 1400} BizBucklemaker = &BusinessType{Name: "Bucklemaker", Serves: 1400} BizPlasterer = &BusinessType{Name: "Plasterer", Serves: 1400} BizSpiceMerchant = &BusinessType{Name: "Spice merchant", Serves: 1400} BizBlacksmith = &BusinessType{Name: "Blacksmith", Serves: 1500} BizPainter = &BusinessType{Name: "Painter", Serves: 1500} BizDoctor = &BusinessType{Name: "Doctor", Serves: 1700} BizRoofer = &BusinessType{Name: "Roofer", Serves: 1800} BizLocksmith = &BusinessType{Name: "Locksmith", Serves: 1900} BizBather = &BusinessType{Name: "Bather", Serves: 1900} BizRopemaker = &BusinessType{Name: "Ropemaker", Serves: 1900} BizInn = &BusinessType{Name: "Inn", Serves: 2000} BizTanner = &BusinessType{Name: "Tanner", Serves: 2000} BizCopyist = &BusinessType{Name: "Copyist", Serves: 2000} BizSculptor = &BusinessType{Name: "Sculptor", Serves: 2000} BizRugmaker = &BusinessType{Name: "Rugmaker", Serves: 2000} BizHarnessMaker = &BusinessType{Name: "Harness-maker", Serves: 2000} BizBleacher = &BusinessType{Name: "Bleacher", Serves: 2100} BizHayMerchant = &BusinessType{Name: "Hay merchant", Serves: 2300} BizCutler = &BusinessType{Name: "Cutler", Serves: 2300} BizGlovemaker = &BusinessType{Name: "Glovemaker", Serves: 2400} BizWoodcarver = &BusinessType{Name: "Woodcarver", Serves: 2400} BizBookseller = &BusinessType{Name: "Bookseller", Serves: 6300} BizIlluminator = &BusinessType{Name: "Illuminator", Serves: 3900} BizPlaceOfWorship = &BusinessType{Name: "Place of Worship", Serves: 400} BizLawEnforcement = &BusinessType{Name: "Law Enforcement", Serves: 150} BizNoble = &BusinessType{Name: "Noble", Serves: 200} BizAdministrator = &BusinessType{Name: "Administrator", Serves: 650} BizClergy = &BusinessType{Name: "Clergy", Serves: 40} BizPriest = &BusinessType{Name: "Priest", Serves: 1000} )
NOTE: Wouldn't this be better in a CSV or something? On the other hand, it'd be good to have some form of identifier that users of the package can refer to. IDK.
... should it be a map?
var ( PopRangeCity = utils.IntRange{8000, 12000} PopRangeTown = utils.IntRange{1000, 8000} PopRangeVillage = utils.IntRange{100, 1000} PopRangeHamlet = utils.IntRange{10, 100} )
Sizes of settlement types.
var BusinessTypes = []*BusinessType{ BizShoeMaker, BizFurrier, BizMaidservant, BizTailor, BizBarber, BizJeweler, BizTavern, BizOldClothes, BizPastryCook, BizMason, BizCarpenter, BizWeaver, BizChandler, BizMercer, BizCooper, BizBaker, BizWaterCarrier, BizScabbardmaker, BizWineSeller, BizHatmaker, BizSaddler, BizChickenButcher, BizPursemaker, BizWoodseller, BizMagicShop, BizBookbinder, BizButcher, BizFishmonger, BizBeerSeller, BizBucklemaker, BizPlasterer, BizSpiceMerchant, BizBlacksmith, BizPainter, BizDoctor, BizRoofer, BizLocksmith, BizBather, BizRopemaker, BizInn, BizTanner, BizCopyist, BizSculptor, BizRugmaker, BizHarnessMaker, BizBleacher, BizHayMerchant, BizCutler, BizGlovemaker, BizWoodcarver, BizBookseller, BizIlluminator, BizPlaceOfWorship, BizLawEnforcement, BizNoble, BizAdministrator, BizClergy, BizPriest, }
BusinessTypes is a list of all business types.
Functions ¶
func CalcNumberFarms ¶
CalcNumberFarms calculates the number of farms required to feed the given population.
func GenBusinesses ¶
GenBusinesses returns a map of business to number of businesses for the given population size. NOTE: Meh, not happy about it being a map.
func GenSettlementPopulations ¶
GenSettlementPopulations generates a number of cities, towns, settlements represented as population counts. NOTE: This is just a placeholder function and should be reworked.
Types ¶
type Business ¶
type Business struct {
*BusinessType
}
Business represents a single business of a given BusinessType.
type BusinessType ¶
type BusinessType struct { Name string // business type name (profession) Serves int // people served by a single business }
BusinessType represents a type of business.
func (*BusinessType) New ¶
func (bt *BusinessType) New() *Business
New returns a new business of the given business types.
type Client ¶
type Client struct {
BT []*BusinessType // business types
}
Client is a demographic generating client thingy. :P
func New ¶
func New() *Client
New returns a new client for generating businesses based on demographics.
func NewCustom ¶
func NewCustom(businessTypes []*BusinessType) *Client
NewCustom returns a new client for generating businesses based on demographics.
func (*Client) NewNation ¶
NewNation returns a new nation of given size in square miles (sorry) and population.
func (*Client) NewSettlement ¶
func (c *Client) NewSettlement(population int) *Settlement
NewSettlement returns a new settlement with the given population size.
type Nation ¶
type Nation struct { Size int // geographic size in square miles Density int // population density in people per square mile Settlements []*Settlement // settlements within the nation }
Nation represents a nation.
func NewNation ¶
NewNation returns a new nation with the given square milage and population density.
func (*Nation) Agriculture ¶
Agriculture returns the number of square miles required to feed the population.
func (*Nation) Castles ¶
Castles returns the number of active castles in the nation.
75% of all castles will be in the civilized (settled) areas of a kingdom. The other 25% will be in the “wilderness,” along borders, etc.
TODO: There should be different types / sizes of fortifications.
func (*Nation) Population ¶
Population returns the population given the population density.
func (*Nation) RuinedCastles ¶
RuinedCastles returns the number of abandoned castles in the nation.
From Medieval Demographics Made Easy by S. John Ross:
Ruins, first of all, depend on the age of the region. The following formula is only a guide. The frequency of ruins in Europe varied greatly depending on military history and remoteness of the area.
To determine the approximate number of ruined fortifications, divide the kingdom’s population by five million. Multiply the result by the square root of the kingdom’s age. If the kingdom has changed hands a lot, use the total age – the number of years that castle-building people have lived there, regardless of the Royal Lineage.
TODO: Maybe that should be a result of a simulation. If a fortification doesn't make sense anymore, it can be abandoned and fall into disrepair. This might also happen if there is a major recession etc.
type Settlement ¶
Settlement represents a settlement.
func NewSettlement ¶
func NewSettlement(population int) *Settlement
NewSettlement returns a new settlement with the given population.
func (*Settlement) Farmland ¶
func (s *Settlement) Farmland() float64
Farmland returns the required farm land to feed the population.
func (*Settlement) Log ¶
func (s *Settlement) Log()
Log prints information on the settlement to the console.