Wednesday, January 1, 2014

Design All The Things

Cultura is entering into an alpha state where it'll be playable on a test map. There are a few things I want to get it going:

  • Families - Children and Marriage
  • Households - Wealth tracking, management and consumption
  • Ecology - Renewable resource growth, non-renewable resource mining limitations, climate requirements for plants/animals
  • Land Regions - Splitting the map into irregular shapes

Families

Everyone in the game will belong to a family. It's defined as a set of parents, unmarried children and children not of age. It's used to track children and births.

Births are fairly simple. For Cultura, it's a compromise with a game world to give a player more direct input into affecting how fast they can get more children. A family has a single progress bar. When it fills up, the mother becomes pregnant. Then after a set amount of time a new child is born and the progress bar is reset to zero. In order to fill the progress bar, the family must be healthy. The higher the health, the faster the progress bar fills up (excess health fills into the progress bar).

Children stay children for a set amount of time. Then they become unmarried adults. I plan to have a relationship progress for these people and when they achieve it they then marry with someone else who has also filled their relationship bar. This allows the player to have direct impact on the speed of marriage. For instance, holding more festivals and events fills the progress bar faster. For now, once someone is an adult then they will immediately attempt to form a new family with another adult. These two adults are removed from their original families to form a new family as the parents.

In the future I will probably put in a baby time period where the people can do nothing. Then a child time period where they can go to school, play games or sports or apprentice and earn skills and do some amount of labour. And then finally they enter an adult period where they have full labour capacity and end their education and so on.

For now, complicated issues like divorce will not exist. Widows can remarry (they'll count as an unmarried adult).

In code, what will be done is adding a vector of family objects to a faction. Each family object tracks a vector of people for the parent(s), a vector for the unmarried children and a vector for the children. Homosexual families, polygamous families, adoption etc occur through other algorithms. The family class itself will be structured to handle it all in the future. For now though there'll just be vanilla marriage and family fission/fusion (mother/father plus the children). During update tick it would track excess health of the family and put it into the progress bar for next birth. The number of children determines the amount required for the next pregnancy. Homosexual parents would obviously just have zero progress for pregnancy. There is also intended to be future technology (likely medieval age) for contraceptives that would also stall progress. This may be useful if resources become tight.

Households

Separate from families are households. A household is defined as everyone living at the same household. There can potentially be multiple families living in the same household. Each person tracks their living space separately.

Households are important in several ways. A person who crafts any item will do so at their household and thus utilize the industrial improvement of that house. They will also store goods at their house. They also receive benefits from the housing but split across the number of people living there.

I intend to track wealth by household rather than by family. I will have to see whether that makes sense in the future.

People consume goods individually and thus acquire their health and happiness bonus from goods consumption separately.

In code, this means that each person has a reference to a building id which represents their home. When conducting unit actions, such as harvesting or item crafting, they first refer to this building id as their drop off point. If none is available or it is not suitable then they look to public buildings that are nearby.

Ecology

The game currently doesn't replenish resources which is bad news if you actually wanted to play. The update tick functionality needs to take in a game clock of some sort to determine the time of year (and thus the season). As well, plants and animals need requirements such as season of growth or climate required. Animals may have additional requirements. I haven't yet decided whether those requirements should be set in stone (a deer always require pine trees) or have them procedurally generated as the game map is formed (a deer that spawns in a land region with oak trees will have oak trees as a requirement, whereas a deer that spawns in a land region with maple trees has maple trees as a requirement).

During a growth season, a land region tracks the number of plants of a particular type, their growth rate and then adds a certain value back to the land during each update tick. This way if the player changes the number of plants then they also affect the total growth rate. For grasses and bushes (such as wheat or strawberries) each plant can regrow on its own because they are never cut down. Trees on the other hand regrow base on the number of trees still standing and then new saplings only spring up after the existing trees have all grown back to their full amount.

Non-renewable resources don't regrow and their limitation is based on the amount that can be drawn from it at any given time. For instance a single stone deposit may only have 100 stone drawn from it per hour. This can be improved with technology (such as building an open pit mine on the deposit).

Animals have requirements based on the vegetation or animals that exist in a land region. So if a deer requires 5 pine trees, there are 100 pine trees in a land region, then there can be 20 deer. Then additionally, deer are born slowly based on this amount. If you increase the number of pine trees then you also increase the number of deer. The vice versa also applies. This means that deforesting an area also impacts animal numbers.

The UI hasn't been built yet but the land management screen should be colourful and clear about the ecological implications of a player's actions. They need to know the growth rates and animal birth limits, as well as what affects them. After that the game has no restrictions. You can ecologically destroy the world if you want.

In code, the update tick needs an optional parameter for the terrain manager to take in the game clock. Well, the game also needs a game clock! While it has a clock in general it doesn't track the time of year and reset to zero each new year.

Land Regions

Land regions define an irregular shape of land for several in-game purposes. The first is the plants and animals. Each land region has its own set of plants and animals. One land region might be pine and deer. Another might be pine and rabbits. Taking different land regions means gaining access to different types of plants and animals. However, the game is designed so that you can play with an incomplete set of resources and simply trade with other players for what you don't have.

Second is that these help to define interesting borders. When you take a land region you own that area and others may not enter without eliciting some political consequences.

Third are roads. I intend to make pre-set roads between neighbouring land regions. These roads can eventually be improved with technology. They start as nothing but are coded into the game so that when people want to travel to another region or deliver goods somewhere, they take that path and not a random path.

Fourth is climate. A land region can have a custom climate. I won't make it too complicated at first. Maybe just cold, temperate and hot. Plants and animals will have climate requirements and if they are in a land region that has the wrong climate they won't grow or grow at a penalty.

In code, I will probably have the terrain manager keep track of these land regions. Being irregularly shapes makes their definition difficult. My current compromise is for a land region to be comprised of a set of rectangles. In order to test if a particular square in the game exists in a land region, it is tested against that set of rectangles. That is a relatively quick test that may take upwards to 5-10 such checks. It depends on how crazily shaped I want land regions. The rest of the data that may exist are perhaps a set of "roads" (set paths in the game for units to take), the climate and also the plants/animals that exist. I may even shove some graphic variables in there (the static geometry of the trees and so on) since I don't currently have a graphics module in my engine (woe is me).

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