Monday, March 31, 2014

Tasks!

There's been progress on having people consume goods in Cultura. So far there's eating and starvation. Next there will be consuming goods. There's three kinds of goods in the game: consumable, property and super property. Consumable goods disappear upon consumption. Property requires repair over time. Super property requires no repairs. The exact balance hasn't quite been determined yet. It'll all be about timing it so that it feels right. Whatever "right" means.

The people spend most of their time doing their jobs. These are the tasks you assign them through a labour management system or you click on them and tell them to do things and then they do it. They follow your command because it is the paleolithic age and you're the guiding spirit. In later stages of the game they do it because you're the voice of big government micromanaging their lives to the last detail. But during this time period, they essentially do things that you want. Once day time is over, it becomes evening time, and they do things for themselves. While I haven't decided whether you can interrupt happy time (to get an extra bit of work out of them), this is when they eat, when they enjoy life and consume goods.

During evening, the eat food action is put on top and then followed by the consume goods action. Individuals do not need to do anything to enjoy their property or super property but they do need to actually spend time to enjoy consumable goods (and later iterations will have mass goods such as visiting a museum). So in essence, during the evening, eating food and consuming goods takes precedence over user commands. Is that good? Waits to be seen. This forces the player to either give them goods to enjoy to boost health and happiness, or suffer the penalty of idling people.

On a small note, I've changed the way a suitable square is detected for placing a resource pile. This prevents them from being placed within other buildings. That was a problem.

Monday, March 24, 2014

Walking and Pathfinding in Cultura

Passability Map

It's a common problem in gaming and thus a wheel that has already been invented. How to figure out where you can walk on a map when some squares are impassable? Well, here's how Cultura does it and it's nothing fancy.

For each tile in the game there is an associated 32-bit integer which describes the passability. How to read this integer? It's a bit map. We can set various values. In general 0 means nothing is there and thus is definitely passable. We could set the first bit meaning there is water there... only units that can pass through water may go through it. And so each type of terrain can have an associated passability flag.

In Cultura, this passability map is only updated when you construct buildings (which likewise use the map to figure out if your placement is valid). Many parts of a building are passable (for example, a floor!) and some are not (for example a wall). Then there are doors.

The main rule is nothing can be smaller than 1x1. In that way there's no walls or doors smaller than 1x1 the pathfinding algorithm can simply look at a tile and state whether or not a unit can walk on it. Very simple.

So now all buildings are 4x4 structures, the outer is a wall, there's a door and the inner 2x2 area is walkable floor area. Hooray!

Saturday, March 1, 2014

How babby is formed

Food, Health and Reproduction

In the world of Cultura, the healthier your family then the faster you get more children. Healthiness is based on the food/goods consumed by a person. So far food consumption has been coded and health is properly added to a unit. At the end of each day (for debug purposes it was shortened to a matter of seconds), excess health is added to a family's birth progress meter. Once it fills up, a person is born and the meter resets!

Children are born with the characteristics of their parents, randomly chosen. The sex is also randomly chosen. For now it is using C++'s rand. Not exactly random but close enough for now. So this means if parents are an ogre and an elf, you might get an ogre or you might get an elf. If one is purple and the other is green, you might get purple or you might get green. I don't do anything complicated such as recessive/dominant genes and mixed alleles and whatnot. The purpose of this game isn't biology, it's culture! However, if the parents are from mixed cultures I am currently unsure what to do but for now the child will randomly pick one culture. That's for the purpose of ethnically discriminatory policies that societies might engage in... when I code that in.

The next step in the game is figure out how children break off from families and form new families (and whether to track the parent family). This might become important if I wanted to code in family dynasties. For example, a Roman Equites would care a lot about his/her children and parental relationship is through the son/husband. Or Chinese families would create estates in a similar manner with related families allowed to be in the same estate and utilize the industrial facilities there to earn money. But for now, we'll just worry about family creation with children.

Starvation is tracked and while there is no ill side effects coded, eventually it'll be decreasing health until death for each day without food. It's important to have both good feedback to the user about how much starvation, who is starving and how close someone is to death.

Bigger Buildings

Buildings in the world of Cultura are component based, meaning you build rooms and attach them to each other and that creates a singular building. I haven't put in rotating buildings and what not but the idea is that if you rotate a building so that it lines up with another building that determines whether it connects to it or not. In addition, all buildings are now 2x2 in size. I don't think there'll be anything in the early stone age portion of the game with different sizes but certainly when building more fantastic stuff (literally or figuratively) the sizes might be different.

For now we can behold a "den", which is a building component that is equivalent to a bedroom:

Infrastructure

I had to switch off the Greedy pathfinding in the game because people kept getting stuck like dumbasses and then filled themselves in with their own filthy poop. Well actually I haven't coded poop yet so the latter part isn't possible. Yet. In any case, it is now entirely A* pathfinding but obviously with just a naive implementation the performance demands much. So I may have to turn my efforts to some performance tweaking at some point in the near future. There are two general ideas: first is to make the A* faster (as I've done before but the code gets quite ugly) and the second is to use memory to decrease the number of times I recalculate paths via A*.

Units now have graphic variant ids. These ids match across the "races". So right now there are Humans, Elves and Ogres. A graphic variant ID of 1 is the same "type" of human, elf or ogre. This means that if "1" maps to a purple-skinned male in Human, it also maps to a purple-skinned male in Elf. This was to make the reproduction algorithm simpler; I could just take the graphic variant of one of the parents and voila I got matching skin colour.

Placing structures now respect previously placed structures, construction sites, rocks, resource nodes and everything else in the way. No more magical slamming crap on top of other crap and then you can only click one of them.

Whew

With the ability to put 2x2 buildings, I've laid the ground work for developing an industry chain. You can already hunt, gather and craft. I'd like to be able to allow the user now to automate an industry chain and then subsequently consume those goods for happiness and health. That'll make the first true building block of Cultura.