Population Mechanic Suggestion

Good morning everyone.

So, I am currently building a rpg musician game, in where you are an artist from a small town just trying to make it big.

While I have made great progress with building the game, I must admit, I am not very familiar with using AI or how I would handle the following task:

Ideally, I want a system of consumers that run in the background, and they perform different tasks. Being idle, streaming a song, buying a song, buying an album, etc.

I thought maybe generating a set on consumers with a struct that has data like favorite genre, how much they listen to music, etc. and then running a function every tick that gets a random consumer and applies a random action. Populations get big and I know this would probably be super heavy on memory as well.

I started as this being on my GameMode, then I made the population its own actor and did it that way…I just feel there’s a more efficient way to do this. Any suggestions on a better alternative?

Forgive me, I wasnt sure if I should make this a conversation or a question.

You could offload this in c++ to an FRunnable separate thread but it might be a bit overkill.

If you do use tick then you can also change it’s frequency so that it ticks only every few seconds. (no need to be checking over 60 times a second)

Also are these all actors or are they more like background tasks for instance out of the city your character is in (in game world)

So essentially I was just thinking of a background population, which didn’t necessarily need “stats” to be given, however I did essentially get inspired to make them NPCs

Since positing, to be more specific, I essentially created an event on my GameMode, which would randomly choose a (ConsumerStruct) from the population, and then randomly select an action from EConsumerActions, execute the action, then reupdate the array of ConsumerStructs. As it stands, the event currently fires of at 3 times the game speed, which is default 1. So it would be fired every 3 seconds and when in FF, ever 0.003 seconds.

For example, one action is Streaming a Single. The consumer struct contains a string for a FavoriteArtist, which has 50% chance of the consumer choosing to stream a single from said artist. 25% chance of streaming a ReleasedSingle from their FavoriteGenre, 25% of choosing a ReleasedSingle from the ReleasedSingles Array. The streams would then be applied to the chosen track. (functionality for SingleStruct and AlbumStruct and calc streams and sales have already been built.)

As i would be trying to accurately represent say the USA, I obvs cant store 327m entries in an array. So i tried something smaller, like 325 or 32500 to maybe accurately represent an entire population.

Although they were to run in the background, it would be cool to have a bunch of NPCs running around listening to music, streaming, yada yada. I hope this brings things more specific. So far consumer actions are idle, sleep, stream single, buy single, stream album, buy album, buy album track, and attend event.