I would like to have random people with preferences generated for an economic strategy game. For simplicity, lets say each person has age(number), home area and its type (city,village,...) and preferences(likes ice cream,..).

The problem is, if I used uniform random generation(choose random age, home, and preference) all people would be ...uniformly distributed and there would be no demographics for player to discover. By features I mean, for example, young people like soda, in addition people living in village tend to prefer red colored packaging (=> player shipping it with different packaging to country will sell more). I would like to have the people generated so that there are always some distinctive demographic features(which does not have to be known to the game itself) present in the data.

The features does not have to and should not resemble real-world ones, the algorithm should work without requiring any 3rd party databases. Homes for people are given as input from previous generation step as array of tuples of settlement id and capacity (thus also type).
What could be general procedure for this type of procedural generation?


2 Answers 2


Generate your demographics with weighted random distribution. Before generating the statistics for any individual people, decide the weighted statistics for your groups (i.e. age groups, location, etc.). Then, when generating a person, get their group information first (either randomly or some other method for assigning people to groups). Then use an individual's group information to weight the statistics of their preferences.

Alternatively, you can generate the people in phases. Generate everything randomly, then over multiple iterations, change people's preferences to gravitate towards uniformity. For example, if in region A, young people that say "soda" instead of "pop" is slightly higher, over multiple iterations that lead would increase, and eventually "soda" would be the dominate phrase used to refer to sugar water.

You can even take this a step further and allow surrounding areas to provide influence depending on the uniformity of their preference. For example, if in your iterations it happens that a vast majority of people have one preference over another, that influence can spread to surrounding areas.

Imagine you have an attribute that has two choices, soda or pop. If you were to visualize this information with your location data on a grid with black and white, it would look like white noise. Totally random. Now you start what is essentially a cellular automaton. Attributes will change depending on the frequency of the attributes around them. For example, a soda choice, surrounded by 3 pop choices changes itself to pop. After multiple iterations you'll start to get localized regions where each choice is soda or pop. Those regions will grow and eventually your white noise is turned into islands of black and white. With more choices, it might looks somewhat like this video someone created of a Pokémon battle (more here on that experiment).

  • \$\begingroup\$ The first option is what I decided to go for in the end as it requires the least information upfront (might change it later for more complex solution, but for testing it suits me the best). Also, could you be more specific on the iterative procedure? I am not sure if I understand it to a point I could implement it. \$\endgroup\$
    – wondra
    Commented Feb 16, 2017 at 17:50
  • 1
    \$\begingroup\$ @wondra I added another paragraph and a visual example. \$\endgroup\$
    – House
    Commented Feb 16, 2017 at 19:37

You seem to have a bunch of visible attributes which themselves don't actually have a gameplay effect (age, location...) but offer a hint for the invisible, gameplay-related attributes (their preferences).

What you can do is randomly generate the visible attributes first and then when generate the gameplay-related attributes, bias them depending on the visible attributes.

For example, the formula for sweetness-preference could be random(0, 100) - random(0, age). This makes a senior who likes sweets less likely than a child who likes sweets.

Another option would be to define a couple of character stereotypes (child, elderly man, businesswoman, hipster, punk...) and assign default values for them.

When you create a new character, pick a stereotype. Then, when you roll for the character attributes, roll multiple random numbers and pick the value which is closest to the default value of the stereotype for that attribute. That way the majority of your characters will tend to conform to their stereotype, but there can and will be outliers. The more rolls you make, the less outliers you will have.

When having a set of predetermined stereotypes is not procedural enough for you, you could even randomly-generate the set of stereotypes and their default attributes. Your players will then still be able to spot correlations between characters based on the same randomized stereotype. For example, people who like soda also like red packing, because (unknown to the player) there is a stereotype which happens to have both a high default soda preference and a high default red preference and they all originate from it.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .