Friday, November 15, 2013

Goods and Production Rate Balancing

The economy of Cultura is serious business. It's also set in the paleolithic age. For the alpha, the technology and economy will span only the paleolithic age. The "full" game, first iteration, will span from paleolithic to neolithic (the three ages will be paleolithic, mesolithic and neolithic). So let's take a look at the various concerns by splitting the economy into its various stages.

  • Sourcing Raw Resources
  • Collecting Resources
  • Producing Goods
  • Consumption

Sourcing Raw Resources

The beginning starts with a small band of sentients (human, ogre or elf) exploring an unknown landscape. There's no fog of war but the map is large (think Anno 1701 size). There's plenty of space. There's trees, bushes, grassy patches and animals. At the start, trees and animals are plentiful. Bushes and grassy patches are scarce. Once you pick up the technology of planting, you get to shift the balance. You can plant new trees, bushes, grasses and whatnot to improve the growth rate of the land. You can replace what plants grow where (but climate penalties will be there). Animal population will depend on some plant in each land region, remove it and you lower their growth rate.

Renewable resources (anything falling under the tree, bush, grass and animal category) can grow faster at first by simply planting more of those plants. Once you start researching agriculture techs then you can improve the growth rate of plants in your land regions. A year is broken into four seasons. When a plant or animal hits its growing season it starts replenishing its resource. If it's already at max then it starts to spawn new versions of itself (trees grow new trees, animals give birth to new animals). Growth rate of plants depends on the number of plants. Animals births are limited by the plant they are dependent on.

Non-renewable resources have a "draw limit". You can only take so much from it before the site is "exhausted" and you must "find more". Why all in quotations? Because the game is meant to be played as long as a player feels like, if I were to put in actual numbers for the amount a non-renewable node held then there is also a limit on how long the game is played. I could always put in a really high number that is physically unreachable but psychologically speaking it's nicer to just be infinite. Another choice is to bug the player to do some more prospecting to magically find more resources every so often but meh it's pointless and adds nothing. Technological improvements increases the draw limit and is themed as increasing mining/quarrying technologies.

Balancing! This involves an excel sheet and lots of numbers. The question asked is "How many people do I want to be able to live in a particular land region at full goods consumption?". Also what is "full goods consumption"? That is, how many goods do I want people to be able to consume? Here's what I'm thinking:

  • Paleolithic: 6-9 Goods per capita
  • Mesolithic: 12-15 Goods per capita
  • Neolithic: 18-21 Goods per capita

For balancing purposes, this means you need to be able to source enough materials per capita to supply 6-9 goods and have enough left over labour output to produce those three goods. When you first start, your labour output is capable of producing about 2-3 goods and collecting the materials for them. By the end of finishing the Paleolithic industry technologies, then you are able to hit that 6-9 range. The timeframe for a particular age I'm aiming for is 4-9 hours (plenty of time for building a city, enjoying it, getting into trouble, dealing with politics and other AI players and setting up complex trade routes for a multi-tier industry).

Collecting Resources

Having said a mouthful before hand I can be more brief here. Collecting resources is just about sending all your people out there and then stripping the earth of its bounty. Technology improves the rate at which you do it via your stone tool. The stone tool will be a magical repeat technology which you can pour tech points into and will give you bonuses and also when you hit milestones give you named bonuses (such as "biface" or "burin").

Like before, it is balanced such that 50% of a person's labour is used up for collecting enough materials for 6-9 goods at maximum technology. You start off at around 2-3 goods at 50% of labour.

The main concern about collecting resources is that the player must watch the ecological damage caused and ensure that they properly balance growth technologies. If you clear cut a forest, it is gone and the trees spend a very long time trying to recover (because growth is based on the number of plants or animals). You can help to plant more trees or bushes though through agriculture (bushes and grasses) or silvaculture (trees), animals have no technology. Those technologies aren't available until neolithic though.

Producing Goods

After your hard work growing stuff and collecting it, now you mash it with your hammerstone repeatedly until it becomes something awesome... like bread or beer. Because hammering wheat with a stone makes beer. Trust me.

Essentially, people will grab what resources you've collected and turn them into goods. These goods are then distributed as you see fit. There isn't much more to say... collect stuff and turn it into usable stuff. The target is 6-9 goods produced at maximum Paleolithic tech.

Consumption

The game revolves around consuming ever greater amounts of goods to improve your health and happiness to levels that support ever greater populations. With more people comes more problems (plagues and riots, your choice... or perhaps as the Swedish say "Choose between Cholera and Plague"). But with more people comes larger armies, larger cities, more complex industry chains and so on.

Each good when consumed provides health and/or happiness. A city (all the people in a single land region) have a graduated requirement. That is, the first 10 people require nothing. The next 20 require 5 happiness/5 health each. The next 70 need 15/15 and so on. A good is consumed in one minute, a year is one hundred minutes and thus 100 goods are consumed in a year to be continuously consumed.

Property lasts 1 minute and then becomes "damaged" and requires upkeep. This means a person buys an intermediate good and it instantly repairs property in her possession. Consumable goods lasts 1 minute and then disappear when finished, thus requiring the person to buy more (food is a consumable as an example). Super property lasts forever and requires no upkeep. It however costs 10x as much materials and labour to produce than a typical good.

Finally, I do intend to put in some "slack" labour output. This allows for labour wasted due to walking around and carrying goods to places. There are also other functions that soak up labour such as house construction, people used up in conducting trade, people used up in policing or military services and the production of military goods.

Yay

In a short description, the robust economic system is meant to intrigue you in sourcing new resources to set up new industries (higher tier cross-requirement goods), while the UI is streamlined to ease the maintenance/expansion of existing industries. The result is a setting where you have a constantly expanding empire where diplomacy, war, trade, cooperation, subterfuge and all the like revolve around one thing: consume more goods. Well actually, it revolves around one thing... giganticus stacks of gold bullion. Mmm piles of shit.

Monday, November 11, 2013

Alpha Economy

Think about fields of giganticus stacks of gold bullion. Then remember that Cultura actually starts in the stone age so what you really have are stacks of polished gold rocks. So last time I talked about consolidating for Alpha, well this is about the actual economy.

Mmm.

Alright long story short there are 14 raw items: grain, fruit/vegetable, meat, stone, wood, earth, metal, bone, fur/skin, fibre, filler, herb, precious metal, precious stone.

Complicated enough? Of course not! This is an economy game. We expect flow charts that make your eyes bleed. The food type raw goods (grain, fruit/vegetable, meat) each lead to two consumable goods and one intermediate good. The others lead to one property good, one consumable good and one intermediate good. Precious metal and precious stone make one super property, one property and one intermediate. All of these goods are appropriately themed for stone age (although I haven't decided what exactly they will be quite yet).

What do I mean by those types? All goods provide health, happiness or production bonus. The type they are determines how they provide the benefit.

Consumable good is a good that someone will simply take and consume. As long as they are consuming it then they will receive its benefit. You can only consume type of an item. Higher quality consumable provides a better bonus.

Property good is a good you place inside your home and then gives you its benefit. However, over time they require upkeep which means it consumes one unit of intermediate good. In order to produce them they require the same intermediate good.

Super property is a good you place inside your home and then gives you its benefit. Then that's it. No upkeep and no repair.

There are 5 different residential buildings which consume all the property and super property.

Then there are 3 industrial buildings and 3 tools. This one is a bit more complicated, you might notice that I have been careful about production rates and ecological growth rates. What is important here is that I want a region of land to support 100 people continuously consuming all goods. So the base production rate is not capable of doing this; maxing out production rates is what will allows full consumption. A player needs to worry about ecological renewable resource growth rate (which can be improved via technology) and industrial bonuses (tools and industrial buildings and their associated technology). Essentially, a player has to balance how much they can take from the land without damaging it and how fast they can take from the land and turn it into goods.

For military, there are 3 weapons and 3 armour. This means 3 different damage types.

I've specifically not listed out the exact goods, bonuses and other numbers because they're likely to change quite often. However, this is what I plan to include for the Alpha. Most of the gameplay features now work so it's time to flesh them out with game data.

Resources and More!

The world of Cultura has been going on and I've been finishing up the xml loading portion of the game. Right now I've just finished what one of my friends call "jack-testing" (ie. it compiles) of the last piece of the xml loading; modular-izing the material selection window between the goods crafting UI and the building construction UI. Yaaay! In any case this brings me to a point where game design matters before continuing any further so I thought I'd consolidate the game for alpha at this point.

Here's what I'd like to have: 14 raw resources, 17 consumable goods, 7 property type goods, 4 super property goods, 5 residential structures, 3 industrial structures, 3 tools, 3 weapons, 3 armour. Of course, all the gameplay and dev-style UI to go with all these features. By the end of the alpha I'd like to have random level generation, fully fleshed out tech tree and wealth management UI (dev-style UI is fine).

Suffice to say, I like economics and I like playing games surrounding them. What I like most is being able to get a visual reward out of it. The core of Cultura is about building stuff, using the stuff and piling that stuff up into giganticus stacks of hoarding. This is why I like seeing new games on the horizon like Clockwork Empires. In any case, industry chains and goods piling? Mmm.

The exact idea is like this: Cultura is about building stuff and using that stuff to expand the number of people you can support. More people means more labour and more military manpower. Over-extending (by not watching your health/happiness) brings about negative consequences worse than the positive aspects of increased population. So the basic distillation of the game is: Harvest Resources -> Create/Trade Goods -> Consume Goods -> Expand.

As said before I like stockpiling good stuff so I invented the concept of "super-property" which for now is built off of two raw resources: precious metal and precious stone. These types of goods last forever, require no repair and give cumulative bonus. Everything else should be streamlined for consumption (rather than risk bottlenecks and pile up of useless goods). I might toy a bit with consumption rates and property use to allow cumulative bonus. It all depends on what is more fun with more tweaking. That aspect of game design can be left open.

Only the property type goods require an intermediate good to produce. This isn't always going to be the case but for the alpha goods it will be. I don't think I'll make a final decision on the exact material types and for now they will all be equal in value. The health/happiness system has yet to be worked out entirely but I can forge ahead with everything else and leave code stubs for those calculations. In essence, I want a way to encourage players to have a variety of goods. For instance, if you want pottery you could get blue clay pottery or red clay pottery. You can store up to 5 pottery in a display room. If you display a greater variety of different pottery the bonus is greater than showing the same pottery. But with the possibility of blue clay pottery, blue/red clay pottery, red clay pottery... what is the bonus of using blue clay, blue clay, blue/red clay versus blue clay, red clay, blue/red clay? In the latter case, you already have pottery that uses red clay but not a purely red clay pottery... however items with more materials in them give more value. I might calculate bonus based off of "sum of item level" and then a second additional bonus of "materials used"

I'll compile a list of exactly what goods will be in the game design wise but leave what they actually are open. That is I'll say I need a Bone Consumable Good but it could be "bonemeal". I'm leaving that open since I have no graphics yet and the Stone Age theme requires a bit of resource to see what exactly people back then had. I'll also leave out tech-themed goods until the beta (Mundane, Steampunk and Fantasy). But in general, the Mundane gets the advantage of being able to build more types of goods (and thus receive more health/happiness as a result) to compete with the advantages of magic (Fantasy) or advanced machinery (Steampunk).

Wednesday, October 2, 2013

XML and Scrolling

Cultura has a lot of different resources. And it might be overwhelming to a player who isn't all the rage into Dwarf Fortress or Anno 1404. So, in Cultura, the concept is simplified a bit. There are "items". You can see below in the list those are things like "grain", "fruit", "meat". Within an item category are "materials". So there are different types of grain such as "wheat" or "oats".

What this means is that all goods will require "items" (not materials). So when you want to make "flour", you use "grain". It doesn't matter what kind of grain. But using more types of materials creates higher quality items. Higher quality items last longer or give better bonuses.

The current list of items and materials are:

  • Grain: wheat, oats, rye, barley, stone grass, green brome, silk rye, bluestem
  • Fruit/Vegetable: juniper berries, crab apple, blackberry, strawberry, glowing mushroom, crab plum, yellow berry, tiger nut
  • Dairy: none for now
  • Meat: gazelle, seal, mammoth, sabertooth cat, unicorn, ice crab, dragon, direwolf
  • Stone: granite, limestone, flint, chert, stonewood, rune rock, aquaferra, dark granite
  • Wood: pine, oak, cypress, sycamore, silverleaf, ironwood, amberbark, goldwood
  • Earth: clay, sand, kaolin, silt, bright clay, dark shale, fire sand, frost silt
  • Metal: tin, iron, nickel, zinc, viper stone, cold iron, frost ore, amber nickel
  • Bone: gazelle, seal, mammoth, sabertooth cat, unicorn, ice crab, dragon, direwolf
  • Fur/Skin: gazelle, seal, mammoth, sabertooth cat, unicorn, ice crab, dragon, direwolf
  • Fibre: silk, cotton, ramie, hemp, giant spider silk, thread mushroom, rock string, yarn bush
  • Filler: papyrus, ryegrass, leadtree, burclover, hollow weed, elf blade, grey shrub, goldclover
  • Herb: tea, ginger, basil, cinnamon, glowing nettle, ember flowers, comfrey root, mandrake
  • Precious Metal: gold, silver, copper, platinum, mithril, adamantium, snow silver, null iron
  • Precious Stone: turquoise, diamond, jade, sapphire, mana crystal, moonstone, sky pearl, power stone

In terms of code the only trickiness surrounds meat, bone and skin. For those items they are refined from animal (or sentient) carcasses. Your hunters will go out, kill a gazelle and then harvest "carcass" type goods. These are then turned into meat, bone and skin. This means for the game purposes, meat/bone/skin count as non-raw goods! Instead "animal parts" is what you collect and then based on the material of the animal part you get different meat, bone and skin. You can then use those to craft further items. The xml that has been written looks something like:


<good>
 <name>Meat</name>
 <id>10000</id>
 <prereq>
  <req>
   <id>100</id>
   <amount>1</amount>
  </req>
 </prereq> 
 <category>
  <id>100001</id>
 </category>
 <graphic>
  <meshname>meat</meshname>
  <texture>meat.png</texture>
 </graphic>  
</good>

This gives a quick way to add in new stuff into the game. How do we parse it? Using rapidxml :) I'm not going to write a poopy xml parser when there's a million out there. Those aren't particularly interesting or hard problems to solve versus making Cultura. The intent is, afterall, to make an awesome game.

Using xml, the units, structures, goods and materials are all loaded at initialization. Then they are saved in the "gameEntityCreator". This class holds all the definitions. Whenever some components needs to make a new unit or structure or resource node etc, they call the gameEntityCreator to do so.

Next for the xml loading is to change the UI to make use of the gameEntityCreator and its list of definitions. The goal is modularity and moddability. While I don't have an intent in making the game mod-able, I do intend to have as little "one-shot" code in the game as possible through better design.

Some additional awesome fixes by a friend:

  • Game starts with the camera properly centered on your cave
  • No more scrolling unto infinity, it stops at the edge of the map

Sunday, September 15, 2013

Work Orders and Terrain

Graphics in Cultura is designed around the idea that what an artist draws is what they get to see in the game. That way, there's no strange distortions (other than effects) and so on, allowing artists to simply draw. As part of that, the terrain on the ground used to be rotated quads but no longer! They are now the same as everything else. In addition, the terrain drawing has been randomised using a single hard-coded seed. What this means is that if I have three different grass textures I could rotate through to draw a particular square, it will choose one at random but because the seed is hardcoded, it always chooses the same one so it looks consistent as you scroll around or reload the game.

Using some test tiles, you can see that they are pesudo-randomly chosen and it is always the same every time you load up the game or scroll here.

Work orders have also been finished off, minus UI styling. They list out the existing work orders and allow you to modify them.

If you create one, it will then list it out. This allows you to select it and change it.

The rest is taken care of automatically in the game. Workers will shift what they need to do. By design, if they are already working on an item, they will complete that before adjusting to the new marching orders. That's fine to me so that I don't have to deal with partially finished goods.

Sunday, September 1, 2013

Item Crafting and More!

Features Completed

It's been a while since I posted the last feature complete type of post mainly because the item crafting feature involved a lot of moving pieces. But it's done! The goal after this is expanding it out (I wanted to be able to select a unit and then have an item crafting button at the bottom in a limited action panel) and also to build more infrastructure to support it (I've decided that I'll just go with xml data loading during initialization).

So what was done?

  • Industry Management Screen
  • Work Orders
  • Automated Animal Hunting
  • Automated Node Harvesting
  • Automated Item Crafting

The industry management screen loads up a test-version of the goods tree. On the left hand side are the raw resources and they lead to ANY secondary item that can be produced from them. Later I'll sort the goods alphabetically in their subcategories so everything can be found easily. The point of having each resource lead to any secondary item that can be produced from it is to be able to easily find secondary items (for instance, if an item requires both metal and wood then it will occur twice in the tree extending off from wood and also from metal).

Once you click on one of the goods in the tree, you can then select the options below to change the industry management. Only work orders are fully implemented. So if you select work orders you go to the work order screen.

Here you select how many you want, what materials to use (the options are: must use, use if available, don't use). This screen will also show existing work orders to allow you to change their settings. On next update, the labourers completing the work order will update their settings accordingly. So, there's a delay of building the current item for any labourer completing the work order (for instance, if you cancel the work order, the labourers will still finish what they are working on at the moment).

About item crafting, these are the following game decisions surrounding it:

  • Item crafting must occur in a building
  • The AI will select a building which the person owns or the government has assigned a government building to him (will choose the best building)
  • Material selection occurs each time the unit starts building the next item, in case material settings and availability has changed
  • Each building can only have ONE type of industry improvement (forcing you to build additional houses to improve the industry rate for more labourers)
  • After crafting an item, the carry limit is not checked, the unit will simply be carrying it and queues a drop-off

What doesn't get good screenshots but took a lot of work was the actual implementation of the work orders. There are three different situations: you gave a work order for hunting animals up to a limit, you gave a work order for collecting raw resources or you gave a work order to craft some materials. In the case of hunting animals, the AI finds an animal in the land region of a unit and then has the unit queue up a hunt animal action. The limit is in the amount of meat to harvest (not number of animals). I may, in the future, add in the ability to select an animal limit rather than a meat limit. For a raw resource, the unit finds a resource node of the correct type and material type (but the player can always select yes to all material types). So if you create a work order for wood and said "Y" to pine, then a unit will only try to chop pine wood up to the quantity. Finally, item crafting has a unit attempt to collect resources necessary to produce the good and then go to a building to craft it.

Here is some "flour" (I think my cavemen are making crack but if I don't debug then I can feign ignorance)

Next feature will be surrounding stuff to improve item crafting before I move onto the other buttons in the industry management

Sunday, August 18, 2013

Collecting Some Thoughts

In progress right now is the industry management and work orders. Each feature at this point is taking a longer time than previous ones since they are larger pieces. For industry management there are several components before an alpha version is complete:

  • Goods Tree Screen
  • Labour Dialog, Industrial Structures Dialog and Work Order Dialog

Those UI components are completed and functionality for the work order dialog is also complete. The other component that would be necessary for the alpha version of Cultura is the full functionality of Labour Dialog. Each of these dialogs are different ways to handle industry. Labour dialog allows you to assign a number of people to work in a particular industry to produce as much as they can. It also handles tool selection and non-ideal labour assignments (for the alpha it means people who have a house that is designed for a different type of good and in the future it will also mean people who are not using their best skill). The Industrial Structures dialog allows you to easily upgrade industrial structures and/or view what type of households exist. Each house can have only one type of industrial upgrade (dedicated industrial structures don't exist in the alpha and not likely until you reach neolithic age technology). The work order dialog allows you to order up specific amounts of a good to be collected/crafted using a material selection.

Currently, the work order functionality (you set a work order and then the game automatically begins to assign people to complete the task) is code complete but not fully tested (and debugged and so on). So that'll be finished soon enough. The difficulty in getting this to completion is the rather large number of edge cases and UI design issues that come up. Cultura is a complex game and that means a complex UI. But, ideally the game offers a simple UI to the user but holds easily accessible advanced options for them to micromanage to their heart's content. Additionally, outside of the management UI, there will be a limited number of buttons when units are selected to craft items and possibly other options in the future. Much of the complexity arises from how the code should intelligently react to user input (what should a unit harvest, when should a unit stop, should a unit queue up actions or throw away actions, etc)

Collecting all the tasks together what does Cultura need? Let's ignore UI issues for now. Those will be fleshed out when a feature complete alpha is done (since it's hard to say what might be clunky before actually playing the game).

  • Managing Work Orders
  • Managing Labour Assignments
  • Managing Industrial Structures/Households
  • Tracking wealth by household
  • Family Spawning/Reproduction
  • Random Level Generation for new games
  • Data-driven tech tree and goods tree
  • Data-driven graphic resource/mesh creation
And nice to have for alpha:
  • Event-driven system
  • Graphics component with event-driven system

There are a few open design questions that haven't been fully settled upon:

There might be a UI for seasonally created work orders. For example, it might be "Hunt up to 150 gazelle meat in Summer". This is useful if you don't want to accidentally damage the ecosystem. That currently doesn't exist. There are only work orders and labour assignment.

For now, each household may have any number of bedrooms, living rooms, dining rooms and other such residential rooms but only one industrial structure. Estates are composed of different houses, each with up to one industrial room. This is to simplify gameplay and reflect the cottage-style industrial of earlier ancient times.

Reproduction is currently going to be progress based and dependent on health. Poor health leads to slow reproduction rates. After a set amount of time, children become adults. A set amount of time after that they couple with someone else and start a new family. This new family moves out immediately and requires additional housing. Insufficient housing leads to homelessness (I'm unsure whether people can just randomly build houses or whether land property is controlled). I'm also unsure if I wish to implement cultural rules (such as a daughter moves into the son's estate). I'm also unsure of how to do estate spawning or estate joining. For example, let's say a son grows up and then gets married. Does he build his house in his family estate and combined his labour with that of his extended family or does he break off and start a new estate? Estates share the fruits of their labour but not personal property.

I'm still open as to the random level design. Mostly I gravitate towards having a balanced world where each land region is of a specific type and that type determines the kind of resources it may contain but is "balanced". For example, all land regions have 5 common resources and 2 rare resources. Additionally, I'll design the goods tree to be balanced. Each type of good leads to an equal number of industries except precious metal and precious stone which lead to extra industries (and thus drives up their value in a soft manner).

Lastly, my current set of "raw item categories" is: grain, fruit/vegetable, dairy, meat, wood, stone, earth, fur/skin, fibre, filler, bone, herb, precious metal, precious stone. Each has 4 mundane and 4 fantasy style goods. Steampunk theme means they may encounter either resource. Eventually I'd like to rank the material types by rarity. An item's appearance is determined by the most rare material used in its construction. I'd like that more rare materials give a greater bonus when used. The resources are paleolithic themed and that is why there aren't apples, pears or strawberries. Although I'm not clear on whether strawberries existed back then, it got rather difficult to be too authentic so the following list is only somewhat accurate to stone age:

  • Grain: wheat, oats, rye, barley, stone grass, green brome, silk rye, bluestem
  • Fruit/Vegetable: juniper berries, radish, dates, almonds, glowing mushroom, blue leek, yellow berry, tiger nut
  • Dairy: none for now
  • Meat: gazelle, seal, mammoth, sabertooth cat, unicorn, ice crab, dragon, direwolf
  • Stone: granite, limestone, flint, chert, stonewood, rune rock, aquaferra, dark granite
  • Wood: pine, oak, cypress, sycamore, silverleaf, ironwood, amberbark, goldwood
  • Earth: clay, sand, kaolin, silt, bright clay, dark shale, fire sand, frost silt
  • Metal: tin, iron, nickel, zinc, viper stone, cold iron, frost ore, amber nickel
  • Bone: gazelle, seal, mammoth, sabertooth cat, unicorn, ice crab, dragon, direwolf
  • Fur/Skin: gazelle, seal, mammoth, sabertooth cat, unicorn, ice crab, dragon, direwolf
  • Fibre: silk, cotton, ramie, hemp, giant spider silk, thread mushroom, rock string, yarn bush
  • Filler: papyrus, ryegrass, leadtree, burclover, hollow weed, elf blade, grey shrub, goldclover
  • Herb: tea, ginger, basil, cinnamon, glowing nettle, ember flowers, comfrey root, mandrake
  • Precious Metal: gold, silver, copper, platinum, mithril, adamantium, snow silver, null iron
  • Precious Stone: turquoise, diamond, jade, sapphire, mana crystal, moonstone, sky pearl, power stone