Tuesday, December 9, 2014

Building Skynet

Artificial Intelligence

So, after the Alpha there's going to be some thought about how to build the opponents in the game: the AI. Most games are built using scripted AI and some limited heuristics in order for the player to compete against some rudimentary opponents. In games such as Civilization it's a make or break scenario; bad AI translates to a truly awful game experience. For most big budget games, ironically there's zero time/money for developing good AI, whereas for indie developed games, there's a lot more room for it. It's mostly because AI is about the most unreliable (timeline wise) aspect of a game to work on.

Cultura is going to use pre-trained AI. How much heuristics depends on how well the training goes but let's talk about the idealized world of having an AI trained from nothing!

The Metrics

The Cultura AI is going to be looked at from three different angles:

  • Data: What metrics is the AI going to rely upon and measure?
  • Score: This is a continuous game, so rather than a concept of winning/losing which the AI can train upon, it continuously checks itself against a score to see whether it is doing well
  • Actions: What is it that the AI actually has control over in order to attempt maximizing the Score?

The exact method used to maximize score could vary: using a perceptron or perhaps a multi-layer neural net or something more sophisticated would be the obvious choices. These can lead to different output values for types of actions and what to act upon. A highly scripted AI would be built similarly except that the metric -> action translation would be built by hand. In the case of a trained AI, it would rely on the Data and then produce an choice about which action to take.

Data

The data is one of the most important aspects of the AI. Choosing insufficient or irrelevant metrics will mean that the AI is not paying attention to the right things to make its actions. Some of the data is simple. It should know what land it owns, what resources are on that land at any given moment and the number of people. It might also try to track buildings, industrial buildings of different types, tools, weapons and military power. And finally, the more difficult to track is the relationship with each faction it knows about.

  • Non-renewable Resources: It should know about the current maximum draw rate and the current actual draw rate.
  • Renewable Resources: It should know about the current amount left, the rate of growth and the current draw rate.
  • People: It should know about the number of people, it might split them apart by labour skill
  • Buildings: It should know about number of buildings, industrial buildings
  • Goods: It should track number of tools and weapons available, by type and have more points for superior tools/weapons in a particular category
  • Military Power: It should track how powerful it's currently active military is

How might we track a relationship with someone? The issue is that an AI should be able to care that it has hostile neighbours. But how to do that?

  • Relationship Score
  • Military Power
  • Distance

We could track those two metrics for each known neighbour, have some interesting way of calculating distance (perhaps the closest distance between two land areas of the two factions) and then worry about the military power. Then, we could lump all this together for a total relationship score that is used for calculations... or we could leave it separate. Lumping it together makes it a bit easier for the "national AI" to make overall decisions. One hopes through training it figures out that highly hostile military powers near it means that it needs to defend itself against the enemy.

Score

Ultimately, any AI needs some kind of objective function or else it doesn't train against much. In the case of Cultura there is no winning or losing. It is a continuous game that you continue to play FOREVER. So, how might we picture this? I figure the simplest way is to see the game as a race with positions and you always want to be number one. So, how well an AI thinks it is doing depends on how well others are doing. This could make the AI pretty hard to train (though, another thought is to have opponents who are fake but always improving at a constant rate and try to train AI against this).

This means that we have a way of calculating score and then all the AI is trying to do is get one more point compared to the highest score.

The score is likely to be a function that is something like Total = Population * Happiness * Health + Wealth + Buildings + Land. Another option is to try to track population, health, happiness and wealth separately and have the AI try to be first place in each category.

Actions

And what is an AI without the ability to do anything? The main picture of the world to the AI is Labour Distribution. Oh ho ho, how communist! But more seriously, this is where the AI tries to decide economic activity to the best of its ability in order to cope with the world and become number one. Also, for those that might actually be concerned about a fully communist AI-run society, the future of Cultura involves a concept known as administrative cost which limits the amount the government can do (because any action it takes administration points thus it might be superior to leave some things to private hands).

Okay so one type of action is changing the amount of labour in a particular industry at the margin. Doing it at the margin is important because we don't want an AI that makes crazy decisions, we want one that edges a society toward the optimal solution in a finite amount of time. Another type of decision would be to expand or upgrade the industrial structures related to a particular industry. In a similar vein, it might decide to increase the number of tools being made for a particular industry to increase production.

But, the more difficult decisions comes from foreign interaction. Okay, so it's pretty easy to say "Gee my happiness is low, build some kind of luxury". Then it's more difficult to say what kind of good. But even if you were to decide that when would you figure out "Gee let's instead trade ivory figurines for wooden furniture because the comparative advantage makes this a superior choice than forming a domestic industry to do this?" One choice is to say that a generic action is "increase production of x" and then a subsequent sub-choice to that is "how to increase production of x" where "trade" is an action and then the sub-choice there is "what do I trade off and to who for this good?"

And then of course, there's raiding, war and peace. How to train an AI to be able to figure out when it should make these types of decisions? "Relationship metric is very low, attempt to fix this is triggered, peace is less costly than war" OR "Wealth Score needs to be improved, weak nation nearby, crush nation and take goods"

Conclusion

This is a pretty good start to the AI question. In the end, the most important thing is there to be an awesome AI that is interesting to play against and is highly intelligent. This is one of the few games where an AI who is really awesome at managing a society is totally okay. Striving for Nintendo Hard here.

Thursday, October 16, 2014

Industrial Design

There hasn't been an awful lot of work done on Cultura in the past few weeks due to other concerns (like my job :D ) but in any case, some progress was made. The calculation for placing down buildings was revamped and by revamped I mean it now works properly.

Industry

Other than that, some thought was put into how industry works. Right now it's pretty basic. You collect some resources and it becomes a good.

  • Grains -> Beer
  • Grains -> Flour -> Bread

But, what exact structure do I want out of Cultura? So I compiled my thoughts into a convenient list:

  • Each land region only has a set of resources. Each land region has a type that determines how much of each type it contains (Dry areas have more grass and animals, wet areas have more trees).
  • Each society will focus on making only a subset of the types of goods. This is determined by the Culture Tree they pursue. Someone rich in wood would choose more wood-based goods. Someone rich in earth would choose more earth-base goods.
  • For each society to develop uniquely and have access to a balanced number of goods, each resource type leads to exactly three types of goods, one type of intermediate good and is assisted by one type of tool and one type of factory.

The point of this design is that each society can have 6-7 goods they produce, easily understood by a player and encourage trade to benefit both societies. Or raiding, up to you. This lets you focus a society to produce specific goods, have clear-cut industries you work on and have trade routes that are obvious (I produce Red Clay Pottery and I trade with Oglandia for Blue Flower Potpourri). For the lithic ages, this mimics the kind of trading that would mostly occur: goods for different goods. In later editions of Cultura, the concept of comparative advantage would be more well developed (that's not to say it doesn't already occur in this game but concepts such as labour specialization, labour skill, industrial infrastructure heavily affect comparative advantage and encourage trade of similar goods).

So the concept is meant to be simple. While it seems wordy here, the player is simply presented with a set of goods that are available from their land. Based on that they would choose to invest Culture points into "buying" goods that they can definitely produce. Then they build up those industries like in any other game (Anno, Caesar, Children of the Nile)... as in they would expand resource collection, make more tools, build up workshops all to increase productivity. After that they can choose to overproduce in order to trade the excess to other societies.

Tools and Factories

Now onto productivity. Okay, so there's another list of ideas:

  • Tools
  • Workshop/factory

After a lot of thought and debate in my head, I've settled on something as simple as possible. Tools boost productivity. There'll be a tool per super type of good. What do I mean by super type? A super type would be something like "pottery", which might start off as "clayware" which becomes "pottery" which becomes "glazed pottery" and then becomes "lacquerware" and so on. All of these can be improved by the same type of tool. Your tech level determines the level of tool you produce. In my opinion, the "confusion" that arises from having lots of different kinds of tools comes from the UI. In my planned UI (which has yet to occur) is to have the industry management group goods and their respective tool together when doing labour assignment. This way you can quickly balance the number of tool makers to goods makers and have the correct flow of tools immediately.

I use the term factory loosely. I just mean a building that helps produce a particular good faster. It does it in one big way: it skips steps. For the cost of fuel you can skip a bunch of steps. So normally a production chain is like "Grain -> Flour -> Bread". Then a second tier good would be "Grain -> Flour -> Bread -> Fruitbread" (look, you try to come up with more advanced bread). So, Grain is harvested from grain fields. Flour is made from Grain using labour. Bread is made from Flour using labour. Fruitbread is made from Bread using labour and Fruit. But, what if you had the awesome technology of... Fire Pit? Well then, now you can skip steps! Fruitbread can alternatively be made from Flour and Fruit and Labour and Lithic Fuel. So you've skipped the step of making Bread and instead directly make Fruitbread. Imagine the labour savings!

As the game designer this means I need to balance the cost of Lithic Fuel against the time saving you earn from not making bread (if it takes a really long time to make Lithic Fuel then I need to make the Fire Pit more productive to make up for it).

For the first iteration of Cultura this doesn't seem like much. But imagine later down the line when it is something like "Metal -> Metal Bar -> Bronze Bar -> Steel Bar -> Fine Steel Bar -> Perfect Steel Bar", then something like the "Fan-blown Blast Furnace" which gives you "Metal + Coal-Fuel -> Perfect Steel Bar" would mean that a single unit of coal-fuel just skipped four steps which could mean enormous labour savings (5x less assuming each step costs the same). It's really about game balance.

Ecosystem

How about the ecosystem? Most games are designed after "keep building forever". Cultura is designed a bit differently. This is meant to be a game where you play a society from ground up. And when I say from ground up, I mean eeeeeeeverything. The ecosystem matters. Forests grow. Animals give birth. If I were simulating water sources in the first iteration, there'd even be rainfall. I try to keep it simple though. The number of plants and animals determines their growth rate. In real life, their interaction determines the growth rate. But all I'm trying to simulate is a carrying capacity.

How many resources you draw from the ecosystem is limited by your land and your technology. Better land or better technology lets you draw more from the land. You can choose to underdraw to keep the ecosystem healthy or you could choose to overdraw for some purpose of prestige or fighting hostile societies, as a temporary measure. Or you might sacrifice the ecosystem of some land regions because you're not going to farm there anyway due to urbanization. It's up to the player to decide how to best utilize the land but the land will matter in this game.

Sunday, August 24, 2014

My A-Star is Too Slow, Now With Jump Point Search

As is the case in game programming, my first performance roadblock that is really hurting the Alpha is the pathfinding. It uses A* and it is slow once you get to 40+ square length paths. By slow I mean you can see it takes on the order of 100s of ms for just a few units.

That's bad.

So I went ahead and added Jump Point Search, JPS, but interestingly it made my pathfinding EVEN SLOWER! The issue is that JPS is only superior to super vanilla blind implementation of A* without even, I guess, a heap to store the open list?

Jump Point Pain

Okay, JPS isn't just awesome by blindly implementing the algorithm as pointed out by Harabor (here's the white paper). But it does add value, if we can figure out what is slowing everything down then we can get what it promises: less nodes to check in the open list which is an O(logn) insert.

First, why is A* faster than A* + vanilla JPS? The issue comes down to how the open list is processed. A* with a simple heuristic ( c^2 = a^2 + b^2 ) gives us a very accurate way of determining the next path to analyze without over-estimation. Additionally, the modified A* in Cultura "prefers" to check paths of longer length between two equal cost (known + estimated cost) paths. This means it will traverse down something that is likely to hit the goal node first and end the search. In practice, this means racing down the correct path almost immediately and finding the goal node. So the costs are a bunch of O(logn) inserts and O(1) pops to get the head.

This is quick but the inserts eventually slow down the pathfinding to a very mediocre speed by even a 40-length path.

Thus begins our quest to optimize the shit out of pathfinding.

Cost Estimation Heuristic

The first and simplest optimization was to improve the cost estimation. Originally it was using the "squared" straight line distance to avoid performing a square root. This avoids the computationally expensive square root in the hopes that it doesn't damage performance.

Unfortunately, that just wasn't true. The more accurate straight line distance versus the square straight line distance was pretty much a different in runtime complexity on path lengths over a 10-step length. This was due to the poor "next node" selection in the A* open list. Doing the full calculation allowed A* to correctly choose the next node without trouble and thus be nearly linear in all typical use cases in Cultura.

These days you can use really awesome square root calculators that make it painless. Here are two things: the ole quick square root popularized by Carmack and the much newer asm_sqrt instruction. My box is a quad-core 3.6 Ghz i8 processor for reference.

Just so you know, here's fast inverse square root:

float CJumpPointSearch::Q_rsqrt( float number )
{
 long i;
 float x2, y;
 const float threehalfs = 1.5F;
 
 x2 = number * 0.5F;
 y  = number;
 i  = * ( long * ) &y;                       // evil floating point bit level hacking
 i  = 0x5f3759df - ( i >> 1 );               // what the fuck?
 y  = * ( float * ) &i;
 y  = y * ( threehalfs - ( x2 * y * y ) );   // 1st iteration
//      y  = y * ( threehalfs - ( x2 * y * y ) );   // 2nd iteration, this can be removed
 
 return y;
}
Method Time
Quick Square Root ~25 000 000/s
asm_sqrt ~30 000 000/s

I can do thirty million sqrts a second. Or I can choose the wrong node eighty times and spend countless milliseconds hitting the A* open list. HMM!

JPS: Straight Line Jumps

A straight line is pretty simple. The JPS algorithm basically says keep going forward unless there are obstructions. Then you stop. Seems simple right? Well actually there's a lot of checks per square you need to do before you "jump" to the next square. Is the next square an obstruction or within the map? Is the next square the goal node? Are there any "forced neighbours"? Okay, NOW you jump. The number of checks is very significant.

That's not the worst part though. An unstated problem in JPS is that the jumping doesn't stop.

It doesn't look so bad here. We checked seven squares and then determined that this has no jump point successors. Therefore nothing gets added to the A* open list. Fantastic right? Except that in non-vanilla A* with a reasonable heuristic, I would have never checked all but one of those nodes. So what would have been the cost? Nearly nothing. But, with vanilla JPS, I've run through a "jump" check for all seven nodes. And it gets worse with map size. Cultura has very large maps but even something like a 90x90 test map, I'm nearly running 60-square checks for every straight line jump.

These checks can't be skiped. In order to preserve correctness we must do every square. However, you may not need to perform a full jump.

JPS: Diagonal Line Jumps

In JPS, a diagonal line jump is the most frequent kind of jump you want to do because very rarely do you have a straight path to your goal node. However, the JPS algorithm does an extra step to ensure correctness/optimality for diagonal jumps. Every square you jump forward you must also check the straight line jumps that come out of it.

These straight line jumps have all the performance issues as a normal straight line jump because they're the same thing. And notice they can't be skipped otherwise you might miss an optimal path. So for every square a diagonal jump can go we add two straight line jumps. The number of checks grows very rapidly. For a map such as 90x90, each straight line jump can be 50-60 iterations of the jump function each one consisting of 3-5 checks. Now imagine a reasonable map in Cultura, like a 500x500 map or a very large one like 2500x2500, a straight line jump can be 10000s of checks. So a diagonal line ends up being hundreds of thousands to millions of checks versus just a few in A* with a heap sorted open list. JPS becomes insanely slower.

Jump Point Optimizations

What do?

Order of Operation

Let's consider a few situations:

We could have a goal node accessible through a straight line path. We could have one accessible through a diagonal path. And we could have one accessible by neither.

The first step in JPS is to "prune neighbours" before deciding to figure out the jump point successors. That means we're trying to figure out, from the current node that we just pulled from the A* open list, which directions we should attempt to jump. We can immediately identify that if we're in a straight line path (the x or y value is the same as the current node) then we should see if a straight line jump works. Therefore we should prefer to check the straight line first. Otherwise, let's do the diagonal first because the straight line can't possibly hit the goal node; only a diagonal can. Obstructions can change this but the algorithm already accounts for this.

In practice this means using a deque to store the "pruned neighbours". We push front for the jumps we want to check first, push back to those we want to check second. We are preferring to look at jumps that have a chance of hitting the goal node first.

Of course this is only useful with an early exit. If we find a path that hits the goal node we are using the properties of A* and JPS to exit early from the jumping. We have found a path to the goal. Exit now and let the A* handle whether that is optimal or not. If not? It won't be analyzed again. If it is, we found a path and we can return it immediately. Due to the properties of A*, any other goal path can only at best be of equal length.

Delayed Diagonal Checks

A diagonal path needs to make a straight line check every step of the way. But, if the diagonal path can just simply take you to the goal node (because there were no obstructions), the question is: who gives a shit? The answer is nobody. You got an optimal path, you have an optimal path. Use it!

Rather than make a straight line check every step of the way, as stated in the original vanilla JPS algorithm, just delay those checks only when the diagonal path fails to yield a path.

Overrunning the Goal and A*

When you're using a heap for the A* open list, an insert is O(logn) and popping is O(1). Is that expensive? No! But it is more expensive if you didn't have to do it. JPS is meant to reduce the number of open list checks but that's not useful if the "jump" function takes so ****ing long that the heap inserts and pops were cheaper. What's the answer? Leverage both.

Whenever a jump overruns the goal node, just exit out and return that as a jump point successor. Let the A* algorithm figure out whether it should bother to keep going. The cost is cheap. Imagine a 2500x2500 map. You could do a million checks before realizing this jump is not useful. But A* would have known that far earlier, skipping so many checks that it was much much cheaper to have just simply inserted this into the open list. It's a heap, big deal. It'd have to grow to enormous sizes in order to be a problem.

Have a Path, Use the Path

Whenever we find that we have a path with a goal node, we immediately exit out of finding further jump point successors. The properties of A* will guarantee that we won't use this path if it is not optimal. But we can't tell if it is optimal without going to A*'s algorithm. This avoids the need in JPS to do pointless diagonal or straight line jumps, which again, have a significant cost to them. Inserting a potential goal node into A*'s open list and immediately checking its validity saves significant computation time (a single logn insert versus potentially 1000s of jump checks on various squares).

What's Next

Right now we're running at around 120 solutions for ~60 length paths in a 90x90 map per second. For the pathological case of thousands of units operating at the same time attempting to do pathfinding we would want something around 500-600 solutions per second. We can pursue a few other options: precomputation, caching calculating paths, using greedy whenever possible, reducing function calls and other super-optimization of code (right now the code is very pretty and laid out in OO manner).

I'll be taking a two week break from coding this so that is where I leave the pathfinding state in right now. This is a working real world example of using A* and JPS. I'll likely post up the code (as useful as that may be for people making games with completely different data structures, passability rules and so on), when I'm at the efficiency I'd like to be at for the pathfinder.

Sunday, August 10, 2014

It's a Bug Hunt also Everything is a Strawberry

Much like the Colonial Marines, sometimes you just got to go on a bug hunt. Cultura is at an alpha stage. You can do things and these things probably have bugs or crashes. I'm here to get rid of those bugs using the power of my pulse rifle.

Right now, there's one glaring issue that will slowly get worked out with some placeholder graphics and dummy test values for growth/resource count; everything is a ****ing strawberry. Why? I don't have the graphics for 99% of the resources in the game and also they don't have their values properly set yet. So most of the resources look like strawberries and I'll have to slowly replace everything to get it to a reasonable test state (and then later replace those graphics).

Anyway, the easiest way to talk about what's going on is a changelog:

  • Added a cost to a cave so that it is a buildable structure
  • Placing buildings respects territory ownership
  • Create open area at start location for a starting cave
  • Added a cave
  • Harvest node or animal respects territory when deciding drop off point outside of a storage building
  • Removed silverleaf and replaced with darkwood
  • Added graphics and basic resource information for all eight types of wood, at least wood will stop looking like strawberries
  • Fixed resource node generation, was only making the last item type of each resource node type
  • Fixed resource node generation which put nodes on top of each other, passability map wasn't being updated properly
  • Added Jump Point Search to help with pathfinding performance
  • Fixed world generation of animals, unit ids weren't added to nature faction

Lingering issue: Pathfinding is toooooooo slow.

Another lingering issue: Everything looks like a strawberry. Hard to tell things weren't strawberries. People starved to death due to this.

Here's a screenshot of the current state. Some test graphics and also test graphics for the border.

Sunday, July 27, 2014

Create Me A World

Random world generation is in. The architecture is built. Test functions thrown out. Hostages rescued.

Right now the "random" world is a gigantic flat plain of grass. Faction starting points and animals have been thrown in but overall there isn't much to see. Everything needs balancing. Resource nodes have to be added. Starting caves have to be thrown in. Maybe I might add some starting resources, not sure about that yet.

Figure 1. Invisible everything.

The main point here is that since the world can be generated, it's a matter of filling it in. There's some algorithms I might explore. I'll explain in more detail once I put some real maff into the code. Maths are good.

Wednesday, July 16, 2014

Red Pottery or Orange Pottery or Slightly Reddish Orange Pottery?

Items

A big part of Cultura is about the consumption of goods: property, consumables, food. Then there are tools and military items. With many planned items with variants, how to turn this into something that's understandable for a player? So let's start from the beginning. What do you consume in Cultura? You've got people and every day that passes they eat consumable goods and food. At the same time they enjoy bonuses from property they own in their homes.

Excellent. Materialism is complete. Or is it? Let's say you got an item like pottery. This takes an item called "earth" to make. So far so good. You mine some earth. Put it in a workshop. Workers and slaves poop out some pottery. You put the pottery in a home. Then you enjoy that pottery. But, earth has several variants. Maybe you're getting feldspar, or maybe you're getting red ochre. Those are two planned types of "earth". Although, I will admit, using red ochre to make pottery is going to be tough. In any case, what if you used red ochre instead of feldspar? Then you have a red ochre pot. If you use feldspar then you have a feldspar pot. Are these different?

In Cultura, yes they are! You get bonus from every unique type of item. Pottery made from different materials are considered different. What happens if you have same pottery? If a person has two red ochre pottery then she only gets full bonus from the first. Any subsequent one only gives half the bonus. That's simple and encourages variety.

Okay what about tools and military weapons? That's a bit different from luxury goods. Sure it might be cool to have oak furniture and then also have pine furniture in another room. It completes that missing part in my soul where I yearn to have every kind of wood in my house. That is a thing. But when it comes to military weapons what you care about are RPG stats. How much DPS, eh?

In this case, they take a different approach. Tools and weapons instead can use any number of materials but have no "base material" after it is constructed. Whether you use flint or chert to make your stone chopper, it doesn't create a different item. Instead, the more types of material you use then the higher the level of the item produced. So if you use only flint, then you have a level one stone chopper. If you use flint AND chert, then you have a level two stone chopper. Pretty simple and works well with tools, armour and weapons.

The level of complexity here is somewhat inbetween Dwarf Fortress (any item can be made out of any material or in fact a bunch of alloys and that affects its quality) and Anno (all items can only be made in one way thus there is no way to differentiate them). This "variation" allows for trade between societies making the same item but it's not so significant that close neighbours might not be producing exactly the same good. In that case, they're more likely to trade completely different items (I give you oak furniture for deer leather clothing).

Saturday, June 28, 2014

Productivity

Buildings and Tools

As part of the game design process there's some decisions to be made about industrial structures and tools that help your people make more stuff so that they can consume more stuff in their evil capitalist materialist consumerist lifestyle of reckless abandon.

Tools

Tools cost a certain amount of resources to make, they last a certain amount of uses. This means it's more efficient to use them in conjunction with an industrial building. Then they break and must be replaced. This helps speed labour and of course the bonus must be balanced against the cost of the tool. By reducing labour time this frees up food (because labour time could be calculated in terms of the food that was eaten).

Their bonus is simple. Tool increases production speed and reduces labour time required.

Industrial Buildings

An industrial building takes up space and requires fuel. The kind of fuel changes with technology. This cost is balanced against the reduction in consumption of inputs and an increase in the amount of outputs. The building lasts forever but has high sunk costs.

First, it improves the ratio of input to output. Say you want to make pottery. If you have no building it costs 100 slip to make 1 pottery. If you have a firing pit it takes 180 slip and 10 lithic fuel to make 2 pottery. That's a better ratio. It takes the same amount of time but since you get twice the output, really your productivity has doubled.

Fuel

I've been wrestling with how to make fuel "simple". One issue is that you can effin burn anything. Let's power your evil firing pit with everything from orange peels to old people! Okay, maybe not orange peels. In any case, since so many things can be "fuel", how do I want to define it in game? My current design idea is something like this: there's a good you can make called "lithic fuel", this is the simplest fuel you can make. However, you can make the generic lithic fuel out of many different inputs. So you can select which items are allowed to be used in your lithic fuel industry and then your assigned workers automatically choose the "cheapest" (which would probably be interpreted as the "most abundant") input possible and then create lithic fuel from that. So lithic fuel could use "wood" or "filler" or "bones" or whatever.

However, perhaps the better industrial buildings then require something like "coal fuel". This has stricter input requirements. Now you can only use "wood" or "coal" (which sadly isn't in the game right now, but perhaps a future iteration!). As a side note, the early steampunk tech route is likely to just mirror China because their ancient technology is pretty much steampunk (they had blast furnaces for thousands of years before Europe). That or Greeks if they hadn't wasted all their technology as toys while using mass slave labour.

So the main issue here is that it makes the coding a bit tricky. While most of my goods have only one possible kind of input, fuel has several kinds of possible input. But, I've introduced a concept called "item super id", in addition to an "item id". So what I can do is have 3 or 4 different item ids that say "lithic fuel" and to the player they'll see they have several kinds of lithic fuel. They'll understand why they're in different bundles because it'll say something like Lithic Fuel (switchgrass) and another will say Lithic Fuel (oak). That's understandable. They can then have matching super ids, so that the "firing pit" will require the super id of "lithic fuel super category" which all of those different item ids fit in. Voila! Solved my code problem. With more ids.

Occupancy

Another aspect is how many people can live in the same structure? Originally I was going to do a flat "2 people per room". But then I thought "hmm maybe a bedroom can fit more than say a storage vault". So I'm introducing the concept of occupancy rate per room. It's pretty simple. Go beyond the rate then the family suffers some penalty.

One of the estates that a family owns is considered the primary residence. They get a base health/happiness bonus. If the family exceeds the occupancy rate of this estate then they suffer a penalty for every person beyond that to their health and happiness. Very simple.

Animal Growth

Trying to keep this one simple as well. Animals are born during their birthing season. The rate depends on the herd size. Outside of the birthing season, their numbers decrease to the maximum. The maximum herd size is determined by how many plants (if herbivores) there are in the land region or animals (if carnivores). Best to slaughter animals beyond the max herd size just as it leaves birthing season.