Page MenuHomeAnticto

Public | How to create and use a population with Mutable Populations
Updated 47 Days AgoPublic

Overview

This is an example about how to set up Mutable Populations and use a Population and its Population Classes.
The basic workflow is:

  1. Create Customizable Objects (Covered in other tutorials and documentation).
  2. Create a Population Class, defining which values its parameters can take, and how often. Repeat to create different Population Classes from the same or different Customizable Objects.
  3. Create a Population choosing which Population Classes appear in it, and how often.
  4. Use a Population at runtime to generate randomized Customizable Object Instances according to the properties defined in the Population.

2. Population Class creation

This example covers the "Poor" CO

2.1. Name the Population Class

For this example: Poor.

2.2. Choose a Customizable Object to base the class on

For this example: Bandit_forRPG.

2.3. Add tags to the Customizable Object

If it does not have them already.
For this example: Cheap, Expensive.

2.4. Add tags to the Parameter options

For this example:
2.4.1. Select the Parameter "Shirts":

add "Cheap" to "None"
add "Cheap" to "Basic"
add "Cheap" to "Poor"
add "Expensive" to "2nd"
add "Expensive" to "3rd"

2.4.3. Select the Parameter "Shoes":

add "Cheap" to "None"
add "Expensive" to "Boots"

2.4.4. Select the Parameter "Trousers":

add "Expensive" to "Leggins Officer"
add "Cheap" to "Long"
add "Cheap" to "Short Farmer"

2.4.5. Select the Parameter "Bandage Left Hand":

add "Cheap" to "Forearm L"
add "Cheap" to "Hand L"

2.4.6. Select the Parameter "Bandage Right Hand":

add "Cheap" to "Forearm R"
add "Cheap" to "Hand R"

2.4.7. Select the Parameter "Wrist Cover Left":

add "Cheap" to "None"

2.4.8. Select the Parameter "Wrist Cover Right":

add "Cheap" to "None"
2.5. Add tags to the class wide population tag lists

For this example: add "Cheap" to the White List, "Expensive" to the Black List.

At this stage, when you are at your own, it's recommended to start using the "Test Population Class" button. Each Constraint added reduces the randomness but gives more personality to the Population Class. It's a balance act that depends on the variety of your Customizable Object. In this tutorial, if you execute it now, you'll see that the poor folks have proper (miserable) clothing, but the other details don't match the image we are looking for. The colors are too cheerful, and some things are out of place.
2.6. Add characteristics for specific parameters

2.6.1. Add a Characteristic for the Parameter "Amulet" and a Constraint of type Bool:

Set 1 as the weight for False. Let 0 be the weight for True

2.6.2. Add a Characteristic for the Parameter "Slim/Fat" and a Constraint of type Range:

Add range and set 0.4 as the maximum range. Let 0.0 be the minimum range

2.6.3. Add a Characteristic for the Parameter "Shirt Color" and a Constraint of type Range:

Add range, set 0.33 as the maximum range, set 0.07 as the minimum range and set the range weight to 3
Add range, set 1.0 as the maximum range and set 0.85 as the minimum range

2.6.4. Add a Characteristic for the Parameter "Handkerchief Style" and a Constraint of type Discrete:

Choose the discrete value "Lines"
2.7. Create other Population Classes to add variety to the Population

For example, a Population Class can be made in the following simple steps:

  • Create a new Population Class using Bandit_forRPG, name it "Rich"
  • Add "Expensive" to the Population Class class-wide whitelist.

3. Population creation

3.1. Create a Customizable Population asset.
3.2. Name it. For this example, "Townsfolk".
3.3. Add one element to class weights. For this example, set the class to Poor and the class weight to 9.
3.3. Add one element to class weights. For this example, set the class to Rich and let the class weight be 1.


4. Population usage

From where you want to generate Customizable Object Instances, simply call "generate population" on a Population asset. You can choose how many are created in a single pass, and regenerate the same Customizable Object Instance for them from a seed. You can get the seed on each generated instance call.

image.png (942×1 px, 212 KB)

The example implementation shown in the picture can be found in the Village demo project, "Infinite" level blueprint, in the "generate random characters" function.

How to do this is not included in this tutorial, as it heavily depends on the specifics of each project. But you can always switch the Population asset used in the village demo infinite level for your own Population to test things out fast.

Last Author
pep
Last Edited
Oct 14 2021, 11:52 AM

Event Timeline

ricard published a new version of this document.
pep changed the visibility from "Restricted Project (Project)" to "Custom Policy".Jul 9 2021, 11:47 AM
pep changed the title from How to create and use a population. to How to create and use a population with Mutable Populations.Jul 20 2021, 9:42 AM
pep edited the content of this document. (Show Details)
pep changed the visibility from "Custom Policy" to "Public (No Login Required)".Oct 14 2021, 4:07 PM
pep shifted this object from the S6 Mutable for Unreal Engine 4 space to the S3 Public space.