# Mathematical models for emergent properties

This topic is 1084 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I am a biological chemistry student, programming in my free time to get some practice and to use some of the math I learned. I might move into systems&synthetic biology or bioinformatics or physical chemistry, where programming may be very important.

I did some code on a roguelike type of game, so I can concentrate on what I think is fun and not waste time on things like graphics.

I have some of the basic stuff out of the way, had some fun with procedural generation and now I can think about the actual gameplay.

I am thinking about the game allowing the player to capture creatures and evolve them, like in Pokemon.

The think I run into now is how I combine different parts. They may be body parts or some internal metabolic process. Say I generate creature properties from the set of enzymes they have. Certain enzymes work together. Others do nothing.

Say I want every part/enzyme to have a number. When I combine two numbers I want to get some effectiveness score. This gives me a function of two independent values. Say these go from -100 to 100. Then say I want a function that returns a value between 0 and 10. So what I want is some surface that describes the 'effectiveness landscape'. It is some rolling hill landscape with a few mountains. These maxima are solutions to which parts would be the best to combine.

So I can make this function that is a sum of 9 different variations on f(x,y)=e^-(x^2+y^2). To that I can even add 1/5(cos(x/100)+cos(y/100) to create a saddle so the base of the landscape is never completely flat.

But this now all seems overly complex. A pokemon game just has set types that multiply damage and dice that get rerolled over and over to generate internal values. And what I have is this crazy function in Maple that doesn't even fit onto a page. The more I think about it, the more I think this is just a useless endeavour that will take a lot of time and not produce anything meaningful. Maybe I can just as well make a 10 by 10 table, put some 'effectiveness landscape' inside it myself, and just use that.

Which reminds me that the voice in the back of my head keeps telling me that what I really need is physics simulation engine. Considering my studies, what I really want is some simple model of chemical reactions inside my creatures. Only then I can have some genetics data that can have unique solutions and unique properties. Which then lead me to think I need 3d graphics and crazy stuff I won't have the time for to execute.

I tried to read up what has been said and written about this in gaming. I found a lot on procedural generation, but not a lot on this. If I don't get any good ideas, I might just give up on emergent properties and evolution and just go with procedural generation of creatures, using linear combinations.

Anyone has any ideas? In the end this is just something to get some programming experience, try to use some concepts that I learn, so that the couple of weeks where I do have free time to waste, I do it using game programming and not gaming itself.

Edited by Almeisan

##### Share on other sites

Say I want every part/enzyme to have a number. When I combine two numbers I want to get some effectiveness score. This gives me a function of two independent values

What effectiveness are you talking about? Whatever the creature does, its "effectiveness" at doing it is necessarily a function of ALL its part stats. Combining only two part stats is meaningless; at best, it can produce derived stats that might be useful in a structured model of your creatures.

A structured model is important because creature models aren't arbitrary: effectiveness at related tasks should be similar.

You appear to be trying to model Pokémon genetics bottom-up rather than top-down; you could simply represent your creatures only with game-relevant scores (e.g. hit points, not bone hardness and muscle thickness) and allow the player to breed creatures by simple probabilistic rules (e.g. every score of the child is picked from a Gaussian distribution, cut at some universal minimum ad maximum value that are fixed for each score, with average equal to the average of the parents' scores and standard deviation proportional to their difference). The hidden parameters of sophisticated creature models would become a controlled amount of random noise, with a good simplifying effect on the game.

What could be the added value of maintaining a complex creature model with low-level part stats? For example, more difficult breeding, with stats that should only be increased up to a certain point (for example, stats that make the monster strong and resilient might make it also too large or heavy for certain moves, or easily tired, etc.).

##### Share on other sites

Well, the effectiveness would be whatever parts do. I have not decided on what parts or creatures or players can actually do. I agree that for a creature, all parts are going to matter.

I agree that a model should be continuous, so that it is not arbitrary. If the genetics copies parent values with a slight modification, their properties would still be similar because the 3d surface used to model it is continues.

Let's take a creature made up of 3 parts. If we talk about effectiveness at task A, then an intrinsic value of part I and part II can be combined to effectiveness value x, part I and III value y, part II and III value z. The average of this can be the effectiveness a at task A of the creature.

In the system I have in mind it may be that part I makes one creature really good at task A, but that same part I, because of it's internal value, may make another creature bad at A. The function can have a maxima at one intrinsic value but a minima at the other. There's going to be many different optimal regions and finding them depends on finding the correct combination of both variables. By adding a small (cos(x/100)+cos(y/100) term I do add kind of a dome shape where 0,0 coords have maximum effectiveness. But I want to add these local peaks using e^-(x^2+y^2) for a gaussian-type distribution. Otherwise, every part is best always if it has the value 0 and worst either at -100 or 100.

If I calculate all parts at the same time to get a creature property directly, I need a function that has as many variables as a creature can have parts. Then, I don't only need to deal with 3d functions, but also 4d, 5d, 6d, etc. That would be too much complexity for sure. If I average the values of parts connected, I can use the same 3d function every time. If anything, that is already too complex. I already wonder a bit about how to randomly generate random maxima and minima while at the same time normalize the total area under the surface(so the average effectiveness is always the same) and normalize the maximum effectiveness to 10. That get's absurdly complex for a sum of several sinoids and exponentials.

I agree some KISS would be in order if I actually want to create something, rather than just fiddle around (but the latter is what I want to do).

At this point, I don't really want to determine what 'good' and 'bad' is, and I don't know what the gameplay really is going to end up. I really want to do some bottom down simulation and see if some gameplay flows from that.

Pokemon was just an example as it is something many people can relate to. The way parts seem to be modeled in a game like Dwarf Fortress, which you may relate to as you mentioned bone density as a property, is interesting to me. But I would agree with you if you say that it is questionable how much this actually matters to the person playing, as it can give identical gameplay.

But, the more this starts to resemble some simulation rather than a game, the better in some sense.

Maybe I should start to think about how the genetics would look like, as just passing on a fixed set of numbers isn't very interesting.

Ok, so I am basically thinking out aloud here. Not sure if this is comprehensible. If anyone has a general comment on a life simulator, genetics, emergent properties, simulating physics/chemistry in a gameplay setting, just comment.

##### Share on other sites

You need:

-No global optimum. The system must evolve in reaction to itself. The process of adaptation shifts the optimum. (think rock-paper-scissors mechanics of RTS games, where every unit is countered by another unit, so the optimum shifts as soon as the other player reacts to your choices by countering them)

-Feedback (this is a requirement for the above). System must change itself through some pathway. Feedback should also be used to prevent system from reaching some 'dead end' states (like if your creatures reproduce, you want some negative feedback to limit this to a sensible value, like limited food/diseases).

-Increasing complexity. Reacting to shifting optimum should be done by increasing complexity, instead of just adapting to another equally-complex solution. In most emergent systems, complexity seems to be limited by some nonlinear factors, where shifting to an equally or less complex solution will be favored once the complexity 'limit' is reached. For example, molecules can only grow so big, our genome can only be so long, we can only have so many cells, etc.

-Hierarchial/scale dependent interactions. The above "complexity limit" can be avoided for effectively infinite complexity by allowing groups of elements interact with each other - not just single elements (our society is effectively a group of humans made of group of cells made of group of molecules made of group of atoms made of group of particles made of group of smaller particles made of group of quantum unicorns). (the complexity limit is a necessity for the same reason we organize our software in nice modules - a big ball of spaghetti just doesnt scale)

Then youll have a nice emergent system in your game

A problem with such systems is that you cannot make your game behave the way you want and at the same time allow it enough room to actually work in interesting ways. If you want to explore such systems, either model it exactly according to a real-world (emergent) system, or create an abstract system where 'unrealism' wont be an issue (the simpler the better).

edit:

As for combining 'body parts' into a smaller set of properties according to some randomish continuous function, you could use a neural network (parts=>properties) - thats pretty much what theyre for. You would probably use fixed connection weights in the network, and use the same network for the whole simulation. But you can always make the network evolve as well (maybe in reaction to some environmental factors - like a cold environment might decrease the value of some network weights). You could even define the network ITSELF according to 'body parts' (or genes or whatever you want to call them) - so the 'genetic code' would define how the 'genetic code' is expressed and how environment affects that expression!

(Lets not worry about the learning curve of the game for now  )

edit2:

Also I just read interesting paper (about some theory named "practopoiesis") which tries to explain how adaptive systems like cells/humans/societies/brain/whatever form and function, their properties etc. Relates to AI/evolution/emergence and other such things (all the interesting things  ).

Edited by Waterlimon

##### Share on other sites

Waterlimon, do you mean that there cannot be an equilibrium? That the system should be variable with time?

Neural nets are their own can of worms. I have no formal training in programming, so donno if I want to get into that stuff. Stuff you mention about feedback or weather or disease, that is something that has to be added to whatever is already there, I feel.

I think I have a kind of basic system now that can describe the environment and basic organisms and their metabolism.

But I think I need a math library before I move on. I looked at Trilinos and GNU Scientific Library, but both I need to use in Linux, while I am in Visual studio currently. I don't run Linux currently. I see a lot of those math libraries are focused on linear algebra. Would be fun to do something with that.

##### Share on other sites

But I think I need a math library before I move on

No, you need a game.

• First you need something for the creatures to do (not necessarily combat sports like in Pokémon games, but in any case something that provides an interesting game to play). You are supposed to produce a game, not a physiology simulation.
• When you have rules defining what the creatures can be good or bad at, you can then pin down the creature models and stats the player is going to reason about. These models are the backbone of the game's strategy and difficulty, For example, Pokémon games have many special attacks and attack types because strategy is meant to consist mainly of bringing a suitable set of Pokémon to any fight (because having the right Pokémon means capturing them in a variety of ways and leveling them by picking up fights, as the RPG plot requires); Other games have other priorities: using whatever is available in the most effective way, avoiding casualties, complex move combinations, predicting what the opponent will do, preparing overwhelming offensives, etc.
• Finally, you can add a system of breeding, mutation etc. on top of the creature models if it seems fun.

If I calculate all parts at the same time to get a creature property directly, I need a function that has as many variables as a creature can have parts. Then, I don't only need to deal with 3d functions, but also 4d, 5d, 6d, etc. That would be too much complexity for sure. If I average the values of parts connected, I can use the same 3d function every time. If anything, that is already too complex. I already wonder a bit about how to randomly generate random maxima and minima while at the same time normalize the total area under the surface(so the average effectiveness is always the same) and normalize the maximum effectiveness to 10. That get's absurdly complex for a sum of several sinoids and exponentials.

On one hand, this stuff is trivial, not complex. Computing a lot of functions with many inputs and many parameters is an ideal job for a computer.

On the other hand, relying on random models for your creatures is almost certainly wrong. Models need to be designed explicitly, by you, because they are player-visible and therefore they need to make sense. Random elements must be subordinate to the creature model, and introduced to introduce novelty when playing again.

For example, if your "creatures" are tanks their stats will be fixed (armour thickness and quality in various parts of the hull, fuel tank capacity, fuel efficiency, guns, shots for each gun, safe turning radius at various speeds, weight, size, etc.) and their interactions ill be equally fixed; different games might have different available guns (say, different standard calibers and different explosives both as propellant and in HE warheads) affecting which armour configurations are more or less useful, engagement ranges, and almost everything else at the tactical level.

##### Share on other sites
Maybe in some way simulate what a part does, and how it affects other parts?
Think of a manufacturing line, each machine takes something, changes it in some way, and produces something.
You throw in a bit of random fluctuations, and you'll get very complex behaviour for a player very soon.

Simulating itself on the other hand is quite easy.

1. 1
2. 2
Rutin
19
3. 3
khawk
15
4. 4
5. 5
A4L
13

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633743
• Total Posts
3013645
×