07.01.2017, 21:11
(
Last edited by Moathib; 08/01/2017 at 03:51 PM.
)
System Dynamics 101
Introduction : Why should you learn system dynamics
I've known SA:MP for something like 7 or 8 years, now. I've seen many gamemode, and I even contributed to the creation and the administration of a well-known French-speaking server, called "Street-Kings", that we closed 6 years ago. Since then, I've never found a project that I was interested in. And I think there's a main reason for that : most of the PAWN scripters are (young) self-learners, who read a lot of tutorials about how to code, but not how to design a game.
I've never learned it myself neither, to be honest. I just read a bit about it and watched some videos. But I've studied something that's quite simple to use and very effective when you have to create well-designed game mechanics : system dynamics.
So through this tutorial, I'm (humbly) gonna try to give you a tool to help you design your gamemode. However, it might useful for other purposes.
A very important difference...
Before we begin, a little vocabulary clarification : scrolling through the "Scripting and Plugins" sections of the forum, you can often read thread titles like "Admin system" or "Another house system". Which is actually quite inaccurate. Those aren't "systems"; but "game mechanics". Those two terms can be defined as follows :
To understand what a system is, let's take an example : The image bellow shows a car that you obviously can't drive. Even though all its parts are there, the engine won't start. Because those parts need to assembled, so they can interact together.
Cars, like many other things we use every day, are systems : they are made of elements interacting together, so that the whole is greater than the sum of the parts.
Causal Loop Diagrams
In order to explain you more things about systems, we first have to learn how to represent them. We are gonna use "Causal Loop Diagrams" to do that. A big name for something pretty easy. Let's take an example I've found on ****** : a population system.
As we said, systems are made of parts interacting together. Here, the guy who draw the figure chose "Births", "Populations" and "Deaths". Those are the "variables" of the system, also called "nodes". The arrows symbolizes the connections between them ; they're "causal links", or "edges". They have three main characteristics :
Feedback effects
Nodes and edges linked together create pathways. If you follow one of them and you happen to come back to the your original starting point, then the pathway you've followed is a "feedback loop". Those are very important structures of the systems, because they are the origin of "feedback effects", meaning that the change of an original variable has effects on large parts of the system leading to a another change of the same original variable. Those effects are the real system gears.
A simple example of it can be seen in the diagram showed above. It represents two feedback loops. First, let's watch the one on the left. We see that "births" and "population" interact together : more people means more births, meaning more people, etc. We see that each time we loop, both variables keep growing, without anything stopping them. It's called "a positive feedback effect". The right side of the diagram, on the other hand, shows a "negative feedback effect" : each time we loop, the variables go down.
Those positive and negative feed back loops are also called "reinforcement" and "balance" loops. They are marked "R" and "B" on the diagrams, with a circular arrow around the letter, showing the rotation direction of the loop on the drawing.
In the example given in the diagram, it's pretty easy to guess the polarity of the loop. For more complex system, with many nodes and edges (with different polarities), it might be harder. But there are two methods to find whether you have a positive or negative feedback :
The loop gain is something very important if you wanna make good systems. It's gonna get kind of technical here, but let's try to make a bit of math. The more isn't to remember the formulas, but to understand how it works.
Let's imagine a loop made of 4 variables :
In order to calculate it, we have to change a little bit the way we draw the system, in order to make a linear diagram representing what happens only during 1 single loop :
Let's explain all this with words : imagine that you add 2 units to the variable A. It means that ΔA1 = 2. If at the end of the loop, A is bigger of 6 units, for instance (ΔA2 = 6), it means that the gain of the loop equals 6/3 = 3. With other words, in this case, each time we end the loop, the variable "A" is multiplied by three. It grows exponentially.
Now, let's imagine another situation where the loop is a balance one. If, for instance, adding 2 units to the variable A (ΔA1 = 2) makes it loose 4 units at the end of the loop (ΔA2 = -4), then the gain equals -2, meaning that each time we go around the path of the loop, the variable "A" is divided by two. It decreases exponentially.
So we can see here that the sign of the gain depends on the polarity of the loop : both have the same sign.
The gain can be calculated by tracing the effect a change has at each node of the loop. Let's get back to our 4 variable loop : its gain is calculated with this formula :
Loop-length
The length of a loop is the time it takes to loop. It's as simple as that.
But there's something important to underline here : edges of the system represent the structure of the system, but not the behavior of the variables. It means that they describe what would happen if, and only IF, there were a change. Sometime, it happens. Sometime, it doesn't. Or it might take more or less time. It depends on many things, like human decisions, for instance. So, some loop might have very variable length. Others don't.
There are three ways of knowing a loop length :
System dynamics
Until now, I've mainly talked about loops and their behaviors. On the other hand, the lone causal loop diagram I've showed you so far has 2 loops connected together, sharing the same variable : "Population". How does the evolution of this variable look like ?
This question is the point of system dynamics : understanding how a system evolves, depending on its variables and the relationships between them.
Loops are the main driving forces of systems. Depending their polarity, they can play two different roles :
In order to predict your system's dynamics, you can make a comparison of the loops' gain. The bigger the gain, the stronger the loop. But the length is also very important ; a variable that has a lot of influence inside the system doesn't matters if it never changes. So, loops made of frequent changes are stronger loops too.
Let's get started ! A method to make systems
So, now you know you more about system dynamics, it's time to use it.
Whether you want to imagine a system in order to create game mechanics, or you want to describe a mechanics you've already created (to understand it better, or to improve it), the steps to follow are the same.
1. Choose a scope
You can try to describe how everything in your gamemode interacts together if you like, but I'm not sure it's gonna be useful. The point of describing systems is to make them easier to understand. So try to find relevant game mechanics, in order to discover the main loops and the main variables.
2. Choose and name your variables
It's probably the most critical part of the process. A good choice is gonna make everything easier. It's kinda tricky, because there are many things you have to think about. But they are your building bricks. You need to find them all in order to design a proper system.
First, variables aren't always written in your gamemode, because some of them are related to the player. So you sometime have to guess within the system how to include human behaviors, and you mustn't forget any relevant human influence in the system.
Second, the way you name your variables is very important. A good name should be easily understandable and have a clear sense of direction, so that the meaning of an increase or a decrease is clear. In other words, your variables must be able to become larger or smaller. You should also use words, not sentences.
All the variables and relationships doesn't have the same importance. Some of them are just there to describe the process, or are steps that you can calibrate in order to adjust the system. Others are leverages : they are variables that can be influenced by the players, who can tale game-changing decisions that are gonna change the whole system dynamics. Choose them wisely.
3. Draw the edges and nodes
Now you have all you bricks, build the system. Be very careful with the polarities of the links ; mistakes can be deadly !
There's something important you must remember here : every link you draw in the diagram must represent a relationship between two variables, and not a correlation. It's not because you know that two variable are correlated that there is a causal link between them. Let's take an example : the better the player's job, the more expensive his car. We might be tempted to draw a direct link between those variables. But the real behavior of the system is different, and a bit more complicated. The real structure should be something like this : the better the player's job, the more money he gets, and the more expensive his car.
On the other hand, you don't have to be too precise. We might be tempted to describe every link in detail ; it's sometime useless and even counter-productive and irrelevant.
The links you draw should have unambiguous polarities. Sometimes, we might end up with diagrams where the relationship between two variable might sometime be negative or positive, depending on the situation. It means that there is more than one causal pathway between those two variables.
4. Find, name and number the main loops
With all the edges on nodes in front of you, you can begin to find the loops of the system, guess their polarity, give them a symbol (R or B) and a number.
There are often many pathways that form a loop in complex structures. There are softwares that help you to find them all. But it's not a good idea. Some of them are irrelevant in order to describe and understand the dynamic of your system. Try to find the more important ones, those that matters, those that help you to tell the story behind the system. You can even give them a name, depending on the role they play within the whole structure, like organs inside a body.
If you can, you should also evaluate the gain and length of the loops, in order to have a quantitative description of the system.
5. Correct your diagrams layout
Your diagram is a communication tool. Make it as clear as possible, so that you can see the important loops, no causal links are crossed, etc
6. Adjust the system
Change or create game mechanics that helps you to adjust the dynamic of the system, by changing the gain of the length of a loop, the leverage of a player, etc. Creating a system is an iterative process : you'll have to make it run and adapt it many times before it works well.
Introduction : Why should you learn system dynamics
I've known SA:MP for something like 7 or 8 years, now. I've seen many gamemode, and I even contributed to the creation and the administration of a well-known French-speaking server, called "Street-Kings", that we closed 6 years ago. Since then, I've never found a project that I was interested in. And I think there's a main reason for that : most of the PAWN scripters are (young) self-learners, who read a lot of tutorials about how to code, but not how to design a game.
I've never learned it myself neither, to be honest. I just read a bit about it and watched some videos. But I've studied something that's quite simple to use and very effective when you have to create well-designed game mechanics : system dynamics.
So through this tutorial, I'm (humbly) gonna try to give you a tool to help you design your gamemode. However, it might useful for other purposes.
A very important difference...
Before we begin, a little vocabulary clarification : scrolling through the "Scripting and Plugins" sections of the forum, you can often read thread titles like "Admin system" or "Another house system". Which is actually quite inaccurate. Those aren't "systems"; but "game mechanics". Those two terms can be defined as follows :
- A game mechanic is rule or a mean that are provided to the player so he can play the game. They are basically parts of the "gameplay".
- A system is something made of different parts interacting together, and that's what we're gonna talk about in the next section.
To understand what a system is, let's take an example : The image bellow shows a car that you obviously can't drive. Even though all its parts are there, the engine won't start. Because those parts need to assembled, so they can interact together.
Cars, like many other things we use every day, are systems : they are made of elements interacting together, so that the whole is greater than the sum of the parts.
Causal Loop Diagrams
In order to explain you more things about systems, we first have to learn how to represent them. We are gonna use "Causal Loop Diagrams" to do that. A big name for something pretty easy. Let's take an example I've found on ****** : a population system.
As we said, systems are made of parts interacting together. Here, the guy who draw the figure chose "Births", "Populations" and "Deaths". Those are the "variables" of the system, also called "nodes". The arrows symbolizes the connections between them ; they're "causal links", or "edges". They have three main characteristics :
- A direction, indicating which node has influence on the other one. Pretty intuitive.
- A polarity, showing how the nodes are related one to another :
- A (+)-sign indicates a "positive" relationship : both variables change the same way. It's case of the edge between "Population" and "Births" : more people means more births. and vice versa.
- A (-)-sign indicates a "negative" relationship : both variables change in opposite ways. It's the case of the edge between "Deaths" and "Population" : more deaths means less people, and vice versa.
- A delay, represented by the two lines drowned across the edge.
Feedback effects
Nodes and edges linked together create pathways. If you follow one of them and you happen to come back to the your original starting point, then the pathway you've followed is a "feedback loop". Those are very important structures of the systems, because they are the origin of "feedback effects", meaning that the change of an original variable has effects on large parts of the system leading to a another change of the same original variable. Those effects are the real system gears.
A simple example of it can be seen in the diagram showed above. It represents two feedback loops. First, let's watch the one on the left. We see that "births" and "population" interact together : more people means more births, meaning more people, etc. We see that each time we loop, both variables keep growing, without anything stopping them. It's called "a positive feedback effect". The right side of the diagram, on the other hand, shows a "negative feedback effect" : each time we loop, the variables go down.
Those positive and negative feed back loops are also called "reinforcement" and "balance" loops. They are marked "R" and "B" on the diagrams, with a circular arrow around the letter, showing the rotation direction of the loop on the drawing.
In the example given in the diagram, it's pretty easy to guess the polarity of the loop. For more complex system, with many nodes and edges (with different polarities), it might be harder. But there are two methods to find whether you have a positive or negative feedback :
- You choose a starting variable, you make it change the way you want, and you how your decision influences the other nodes. If the feedback effects reinforces your original change, it's a positive feedback loop. Otherwise, it's negative.
- You sums up the polarities of the edges of the loop, following those well-known rules :
- (+) & (+) = (+)
- (-) & (-) = (+)
- (+) & (-) = (-)
The loop gain is something very important if you wanna make good systems. It's gonna get kind of technical here, but let's try to make a bit of math. The more isn't to remember the formulas, but to understand how it works.
Let's imagine a loop made of 4 variables :
A → B → C → D → A → (...)We will consider that all the edges have positive polarities, meaning that it's a reinforcement loop. Let's say the "A" is our starting variable. The question is : how much does A increase each time we end the loop ? The answer is called "the gain".
In order to calculate it, we have to change a little bit the way we draw the system, in order to make a linear diagram representing what happens only during 1 single loop :
A1 → B → C → D → A2Here, A1 is the value of the variable A at the beginning of the loop, and A2 is its value at the end. The gain is calculated this way :
Gain = (ΔA2/ΔA1)Note that the small triangles in the equations are "deltas". Those are Greek "D" letters. They represent a change, or a difference in mathematics.
Let's explain all this with words : imagine that you add 2 units to the variable A. It means that ΔA1 = 2. If at the end of the loop, A is bigger of 6 units, for instance (ΔA2 = 6), it means that the gain of the loop equals 6/3 = 3. With other words, in this case, each time we end the loop, the variable "A" is multiplied by three. It grows exponentially.
Now, let's imagine another situation where the loop is a balance one. If, for instance, adding 2 units to the variable A (ΔA1 = 2) makes it loose 4 units at the end of the loop (ΔA2 = -4), then the gain equals -2, meaning that each time we go around the path of the loop, the variable "A" is divided by two. It decreases exponentially.
So we can see here that the sign of the gain depends on the polarity of the loop : both have the same sign.
The gain can be calculated by tracing the effect a change has at each node of the loop. Let's get back to our 4 variable loop : its gain is calculated with this formula :
Gain = (ΔA2/ΔD) x (ΔD/ΔC) x (ΔC/ΔB) x (ΔB/ΔA1)In this equation, each factor of the multiplication describes how two linked variables change together. For instance, (ΔD/ΔC) represents how much D increases or decreases (ΔD) if C increases or decreases (ΔC).
Loop-length
The length of a loop is the time it takes to loop. It's as simple as that.
But there's something important to underline here : edges of the system represent the structure of the system, but not the behavior of the variables. It means that they describe what would happen if, and only IF, there were a change. Sometime, it happens. Sometime, it doesn't. Or it might take more or less time. It depends on many things, like human decisions, for instance. So, some loop might have very variable length. Others don't.
There are three ways of knowing a loop length :
- Theoretically : if you know exactly how the variables of the loop behave, you can know the length of the whole loop by adding the time each change of the loop takes.
- Experimentally, if you don't know how long it takes, but you can study the system when it's working, you can collect empirical data and calculate a statistical average loop-length.
- If the two previous ways don't work, guess. Or make hypothesis.
System dynamics
Until now, I've mainly talked about loops and their behaviors. On the other hand, the lone causal loop diagram I've showed you so far has 2 loops connected together, sharing the same variable : "Population". How does the evolution of this variable look like ?
This question is the point of system dynamics : understanding how a system evolves, depending on its variables and the relationships between them.
Loops are the main driving forces of systems. Depending their polarity, they can play two different roles :
- Reinforcement (or positive feedback) loops make the system grow. They are like the accelerator of the car.
- Balance (or negative feedback) loops make the system decrease. They are like the brake of the car.
- The exponential one : the reinforcement loops are always stronger than the balance loops, so that the system grows forever, without any limit.
- The logistic one : the system begins to grow, until the moment that balance loops can go against the reinforcement loops. So the system reaches an equilibrium, or oscillates around it. And after a certain moment, if the effects of the balance loops are too strong, then the system will collapse.
In order to predict your system's dynamics, you can make a comparison of the loops' gain. The bigger the gain, the stronger the loop. But the length is also very important ; a variable that has a lot of influence inside the system doesn't matters if it never changes. So, loops made of frequent changes are stronger loops too.
Let's get started ! A method to make systems
So, now you know you more about system dynamics, it's time to use it.
Whether you want to imagine a system in order to create game mechanics, or you want to describe a mechanics you've already created (to understand it better, or to improve it), the steps to follow are the same.
1. Choose a scope
You can try to describe how everything in your gamemode interacts together if you like, but I'm not sure it's gonna be useful. The point of describing systems is to make them easier to understand. So try to find relevant game mechanics, in order to discover the main loops and the main variables.
2. Choose and name your variables
It's probably the most critical part of the process. A good choice is gonna make everything easier. It's kinda tricky, because there are many things you have to think about. But they are your building bricks. You need to find them all in order to design a proper system.
First, variables aren't always written in your gamemode, because some of them are related to the player. So you sometime have to guess within the system how to include human behaviors, and you mustn't forget any relevant human influence in the system.
Second, the way you name your variables is very important. A good name should be easily understandable and have a clear sense of direction, so that the meaning of an increase or a decrease is clear. In other words, your variables must be able to become larger or smaller. You should also use words, not sentences.
All the variables and relationships doesn't have the same importance. Some of them are just there to describe the process, or are steps that you can calibrate in order to adjust the system. Others are leverages : they are variables that can be influenced by the players, who can tale game-changing decisions that are gonna change the whole system dynamics. Choose them wisely.
3. Draw the edges and nodes
Now you have all you bricks, build the system. Be very careful with the polarities of the links ; mistakes can be deadly !
There's something important you must remember here : every link you draw in the diagram must represent a relationship between two variables, and not a correlation. It's not because you know that two variable are correlated that there is a causal link between them. Let's take an example : the better the player's job, the more expensive his car. We might be tempted to draw a direct link between those variables. But the real behavior of the system is different, and a bit more complicated. The real structure should be something like this : the better the player's job, the more money he gets, and the more expensive his car.
On the other hand, you don't have to be too precise. We might be tempted to describe every link in detail ; it's sometime useless and even counter-productive and irrelevant.
The links you draw should have unambiguous polarities. Sometimes, we might end up with diagrams where the relationship between two variable might sometime be negative or positive, depending on the situation. It means that there is more than one causal pathway between those two variables.
4. Find, name and number the main loops
With all the edges on nodes in front of you, you can begin to find the loops of the system, guess their polarity, give them a symbol (R or B) and a number.
There are often many pathways that form a loop in complex structures. There are softwares that help you to find them all. But it's not a good idea. Some of them are irrelevant in order to describe and understand the dynamic of your system. Try to find the more important ones, those that matters, those that help you to tell the story behind the system. You can even give them a name, depending on the role they play within the whole structure, like organs inside a body.
If you can, you should also evaluate the gain and length of the loops, in order to have a quantitative description of the system.
5. Correct your diagrams layout
Your diagram is a communication tool. Make it as clear as possible, so that you can see the important loops, no causal links are crossed, etc
6. Adjust the system
Change or create game mechanics that helps you to adjust the dynamic of the system, by changing the gain of the length of a loop, the leverage of a player, etc. Creating a system is an iterative process : you'll have to make it run and adapt it many times before it works well.