Tuesday, April 29, 2014

Eating Ochre Dye and Too Much Pottery

Consumption Type

Ever fathom the consumption type of a good? Cultura has! Bread? That's food. Ochre dye? That's a consumable good. Pottery? That's a property good. Polished gold rocks? That's super property. And it just so happens it finally made its way into the code base. The consumption type that is. No more eating ochre dye or smashing pottery into faces for good fun. That might look a little wrong to the player so it was decided by the Design Gods that it should be changed.

Food is eaten to prevent starvation and food must be eaten each day. The bonuses gained from food (usually health) last for seven days because that's the arbitrary length of time that was decided. Eating the same kind of food confers no additional bonus. Consumable goods when consumed confer a bonus and immediately disappear. The bonus lasts seven days. Property goods are placed into slots in a family's home. A home is comprised of different rooms, and so buildings are built room by room by the player. More slots means more property items that can be enjoyed at the same time. Once a slot is filled it spreads its bonus evenly across the people in the family. Property requires repair over time. Probably every seven days.

Collecting Goods

Once a day each person queues up actions to eat food, collect consumables and another to collect property goods. The one issue has been the hierarchy of the actions. If placed at the individual level, the actions of eat food and collect consumables works out fairly okay. Everybody needs to eat and everybody would like to consume as many goods as possible. But for property, you only need to fill the slots or repair damaged property. So if every person queued up such actions you'd end up with too much pottery. Too much pottery is a problem that exists in Cultura.

One solution is to have an action queued up at the family level (similar to faction level actions) so that the family needs it completed but it doesn't really care who in the family does so. That way it only doles out enough actions to individuals to meet the exact demands. It's possible to also shift collecting consumables up to this level. This is useful for maintaining a family budget when private markets are introduced into Cultura. At the very least, the code needs to be able to handle it if not do so currently.

So, hopefully in the next update you will hear how pottery has been enjoyed by the residents of Cultura. In fact you might consider that since they no longer consume pottery (presumably by smashing it into their faces and then laughing) and instead enjoy pottery in their homes what has been done is aesthetic pleasure has been hardcoded into the minds of Culturans.

Saturday, April 19, 2014

Importing Minor Annoyance, Exporting Death

Diplomacy

One of the more fascinating properties of economic games are emergent properties. Think Dwarf Fortress and it's physics system. So with Cultura, where does that come from? It's the AI factions. So here are some thoughts surrounding the diplomatic angle of the game.

At the very beginning there's few options. Nobody can speak with each other and there's no common language (or much of a language at all). It's all zug zugs and dabus. But the diplomacy will be styled after three factors: Prestige, Reputation and Relationship. And from that comes different kinds of relationships that work on two principles: type of time frame and type of exchange.

Prestige, Reputation and Relationship

Prestige represents the power of your society as perceived by others. Reputation represents trustworthiness. Relationship represents the summation of interactions, positive and negative, between each society. Prestige and Reputation is global. You will seem just as powerful to everyone according to your prestige rating and much the same, your reputation is global. Break a treaty with anybody, everyone sees you are a treaty breaker. Relationship however is between each nation and so while you can be seen as weak or untrustworthy by someone, they may still be your good friend because their relationship score is high.

Reputation is the primary vehicle that promotes the honouring of treaties and oaths. Breaking an oath damages reputation and causes global damage to your ability to craft future deals. Your friends will still like you but those who know you less only have your reputation to go by and thus will discount your offerings to them. It's very much like losing face in life. You can only lose face, you can't gain it. So damage to your reputation cannot be fixed by anything other than waiting it out for people to forget and see that your newer dealings are trustworthy.

Types of Treaties

However, the more interesting part is the kinds of treaties you can make. There'll be the usual neutral ones of "don't breach my territory" and also "territorial claims" (which are less neutral). But for the ones that define the relationship with another society, these go down different paths with increasingly more powerful treaties much like leveling your relationships. Maybe you want to seek a deep friendship, perhaps you want to be the most powerful badass barbarian horde or you want to be the imperialist dynastical China. I'm quite sure dynastical is a word. Don't look it up, just use your gut feeling.

The way the relationships are organised is based on type of time frame and type of exchange. For time: An exchange of presented goods OR an exchange of future goods OR a contractual renewable agreement. So for instance, if your emissary takes 300 watermelons to the neighbouring Boogaloo tribe, then they can only trade the 300 watermelons for whatever the Boogaloo have. A future exchange is to promise to send what you did not present. A contractual agreement is the ability to continue to trade without having to again speak with the neighbouring tribe.

For the type of exchange, goods have roughly been divided into three categories. Tangible goods are objects such as food, consumables, property or super property. Tangible social goods are objects such as military recruits, slaves or labourers. Finally, intangible goods are prestige, reputation and relationship.

The paths roughly go down that of War, Power and Peace. I may add a fourth, which is a different way to pursue peace (seeking alliances versus seeking amalgamation). So as examples of types of relationships: Within War you could choose Subjugation where the defeated party agrees to a supply of tangible goods, or there is Conscription where the defeated party agrees to supply tangible social goods. Or you could seek a route within Peace: representation relationship, an exchange of intangible goods for tangible social goods. The main design will be a relationship that starts off simple but expands in options (a wider range of goods and social goods you can offer for a wider range of goods/social goods in return).

Thus allows the diabolical machinations of the evilest players. Or AI.

Thursday, April 17, 2014

Spawning the Trees

Tree Seeds and Simulation

In the real world a tree grows new saplings in a number of ways: seeds carried off by wind, dropping seeds nearby, birds eating seeds and dropping them elsewhere or fruit eaten by animals and pooped somewhere else. Poop is really really important. In fact, human caused extinction of megafauna has caused serious ecological problems due to lack of pooping by the big animals. Anyway, rather than a full simulation in Cultura (although one day I hope that there is a checkbox in the game to have it run in full simulation mode versus game simulation mode), it has a very simple heat map to decide where the next tree grows.

But wait! How do we decide when something grows in the first place? Well, we head off into XML land where all the resources are defined. A particular material such as Pine has stats that say "you grow during winter, at a rate of 100 wood per season and start off with 200 wood". Then when the game is in winter, every Pine tree grows at 100 wood up to 200 wood. That's for level one pine trees. Resource nodes can be upgraded if you get the right technology thereby increasing the ecosystems carrying capacity for your society's greater consumption at its later stages. So then when a Pine tree reaches its maximum capacity for wood, it then adds any additional growth to a tracked spillover variable. When the spillover goes over a certain threshold a new tree is born!

Okay so where to put the tree? Well here's the simplest way. We put the tree at any square with the highest number of similar neighbouring resource nodes. We'll want to track the objects via what is basically a priority queue, with the most important queue being the list of locations with the highest number of neighbouring resource nodes.

  std::unordered_map<std::pair<int,int>, std::unordered_map<int,int>, hash_int_pair> m_heatMapByLocation; //location to (material id to neighbour node count)
  std::vector<std::unordered_map<int, std::unordered_set<std::pair<int,int>, hash_int_pair> > > m_heatMap; // neighbour node count to (material id to location)

And it's very simple, we just choose the first location with the highest number of neighbours because "good enough". Really, it's just a matter of whether it looks right to the player and only in full simulation mode (which probably won't be coded for a long time) will the game care about doing it how it is done in real life.

std::pair<int,int> CLandRegion::getFirstHottestSquare(CGameState* gameState, int materialId)
{
 for (int i = m_heatMap.size() - 1; i >= 0; i--)
 {
  if (m_heatMap[i].count(materialId) < 1 || m_heatMap[i][materialId].size() < 1)
  {
   continue;
  }
  else
  {
   for (std::unordered_set<std::pair<int,int>, hash_int_pair>::iterator iter = m_heatMap[i][materialId].begin(); iter != m_heatMap[i][materialId].end(); iter++)
   {
    //todo: different passability for special resource nodes, such as in rock or in water or shallow water
    if (false == gameState->isPassable(*iter))
    {
     continue;
    }

    return *iter;
   }   
  }
 }

 return std::pair<int,int>(-1,-1);
}

Tuesday, April 8, 2014

Eating Goods and Enjoying Food

Joys of Consumption

The ways of Cultura is to be materialist and be satisfied on consumption! In that vein, Goods Consumption has been added to the game. During day time the people work all live long day. When evening hits, they throw down their hammer stones and antler scythes (hmm... antler scythe is too advanced) and enjoy a rousing session of smashing ochre dyes onto their faces. This gives +5 happiness.

Consume Goods is a horrific state machine, as is Eat Food, both of which are foisted onto a unit once evening rolls around. Eat Food lasts forever (if they can find something to eat, they try to eat it but if they find nothing the action ends and they starve), but if the next evening hits the starvation counter increases (in case they are somehow capable of finding and eating food but it took them so long that a day passed before they reached it and ate it). For Consume Goods, they attempt to consume as many goods as possible during the evening. Once the next day rolls around, they stop and go back to working.

Where is sleep you ask? For now, Consume Goods doubles as sleep because you can't tell them what to do during this time period (although I may consider the idea of cutting into luxury time to produce just a bit more at the cost of happiness).

Each good or food has a bonus associated with it. For instance, ochre dye gives +5 happiness. Bread gives +5 health. This bonus is per material that the good was constructed with. For instance, bread made with wheat gives +5 health. Bread made with wheat and oats gives +10 happiness (+5 x 2). The number of materials you can put into a good is limited by your technology. And, everything a person consumes lasts seven days. So if you eat bread with wheat, you get +5 health and that lasts for 7 days. Although with food you have to keep eating or you starve, whereas with goods you can enjoy yourself a nice rock of handful ochre dye and not need to play with a handful again for another seven days. Amazing!