site banner

Small-Scale Question Sunday for June 16, 2024

Do you have a dumb question that you're kind of embarrassed to ask in the main thread? Is there something you're just not sure about?

This is your opportunity to ask questions. No question too simple or too silly.

Culture war topics are accepted, and proposals for a better intro post are appreciated.

2
Jump in the discussion.

No email address required.

Realistic Randomizers

So I have a project where sprite elements (head, hair, colors, several body bases, clothing) get composited into a character, and I want to add a random function to it. Call it an NPC generator.

The problem is most programs like this produce a jumbled mess: black-skinned blondes, children with beards, etc., and the end result looks like a Portland street camp.
Does anyone know a standard way to sample from multiple correlated variables to give realistic results? I'd prefer that over hardcoding a bunch of rules or templates, which is what most people default to.

A simple example of the handmade mechanic I already use is age+sex+race= height distribution.
The first 3 are uncorrelated and picked randomly unless a selection toggle overrides it. Age multiplies the mean of the normal distribution, then sex multiplies both the mean and standard dev, and finally race does the same. Height is then generated from the modified normal distribution with cutoffs.

Is there a better way to do this for e.g. hair color or presence of freckles? Someone much smarter than me must have encountered this problem and come up with a solution.

Ideally I'd just like to make a huge n-dimensional joint probability distribution to sample from. This would probably be a lot easier if I'd paid attention in linear algebra.

yeah, a bayesian network lets you just specify the conditional probabilities directly between nodes (nodes being character features here).

https://pgmpy.org/detailed_notebooks/2.%20Bayesian%20Networks.html

https://aima.eecs.berkeley.edu/slides-pdf/chapter14a.pdf

A Bayesian network might make sense here. ChatGPT can generate some reasonable sample code to give you a sense of what it'd look like ("Please write some sample code for pgmpy that uses a Bayesian network to generate characters for a game. Particularly for the traits age, height, sex, race, and having a beard").