SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Tutorials

Reply
 
Thread Tools Display Modes
Old 07/01/2017, 09:11 PM   #1
Moathib
Huge Clucker
 
Moathib's Avatar
 
Join Date: Nov 2010
Location: Belgium
Posts: 212
Reputation: 65
Default System Dynamics 101 for gamemodes design

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 :
  • 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.

What is a system ?

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 :
  1. A direction, indicating which node has influence on the other one. Pretty intuitive.
  2. 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.
  3. A delay, represented by the two lines drowned across the edge.
Be careful with the "sign"-stuff. It seems pretty easy, but it's not as intuitive as it looks. The reason is that we often have a kind of "judgments" about links and we mix them with the drawing convention, and we make mistakes. Some people use another polarity system, replacing (+)-sign with "s" (meaning the variables change the same way), and (-)-signs with "o" (meaning the variables change in the opposite way).

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 :
  1. 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.
  2. You sums up the polarities of the edges of the loop, following those well-known rules :
    • (+) & (+) = (+)
    • (-) & (-) = (+)
    • (+) & (-) = (-)
    and you get the polarity of the whole loop. This method can be achieved another way : if there's an even number of negative edges, your loop is positive. Otherwise, it's negative.

Loop-gain

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 → A2
Here, 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 :
  1. 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.
  2. 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.
  3. If the two previous ways don't work, guess. Or make hypothesis.
It's important to remember that it's something you don't always know or can decide. But we'll see later why this characteristic is important.

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 :
  1. Reinforcement (or positive feedback) loops make the system grow. They are like the accelerator of the car.
  2. Balance (or negative feedback) loops make the system decrease. They are like the brake of the car.
The behavior of the variables of the system depends a lot on the relative strength of those loops within the system. There are are two main types of evolution paths :
  1. The exponential one : the reinforcement loops are always stronger than the balance loops, so that the system grows forever, without any limit.
  2. 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.
Those are general patterns, of course. Complex systems can have a more complex evolution, with different phases, depending on the variables behavior, etc.

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.
__________________
Moathib ─ thebinarychoice.com

Last edited by Moathib; 08/01/2017 at 03:51 PM.
Moathib is offline   Reply With Quote
Old 07/01/2017, 10:06 PM   #2
Yaa
Banned
 
Join Date: May 2016
Location: = GetPlayerHouse("Yaa", 0.2);
Posts: 616
Reputation: 42
Default Re: System Dynamics 101

didn't undestand anything but Nice
Yaa is offline   Reply With Quote
Old 08/01/2017, 01:04 PM   #3
PrO.GameR
Gangsta
 
PrO.GameR's Avatar
 
Join Date: Oct 2012
Posts: 732
Reputation: 121
Default Re: System Dynamics 101

While this could be a really good tutorial, I've lost interest in it after first paragraph for a simple reason, it's aimed at a young, inexperienced community (sa-mp) and it's not at all newbie-friendly.

We are not designing a game here, you should be talking about a nice code design, you should be teaching them proper indexing, proper using of tools (like streamer options), etc.
__________________
Blueberry Prison Roleplay will be back soon!
Follow the forums for more information about opening day.

Forums
PrO.GameR is offline   Reply With Quote
Old 08/01/2017, 01:12 PM   #4
SickAttack
Godfather
 
Join Date: Dec 2013
Posts: 5,113
Reputation: 754
Default Re: System Dynamics 101

Doesn't seem too helpful.
SickAttack is offline   Reply With Quote
Old 08/01/2017, 01:53 PM   #5
Moathib
Huge Clucker
 
Moathib's Avatar
 
Join Date: Nov 2010
Location: Belgium
Posts: 212
Reputation: 65
Default Re: System Dynamics 101

Quote:
Originally Posted by PrO.GameR View Post
We are not designing a game here, you should be talking about a nice code design, you should be teaching them proper indexing, proper using of tools (like streamer options), etc.
First, I'm talking about what I know. I've never learned how to code in PAWN. This tutorial isn't about "how to code something" but "what can yo code". It's like learning literature : learning how to write down a good story is different than how to write down good sentences. And many servers are coded and design by the same person.

Quote:
Originally Posted by PrO.GameR View Post
it's aimed at a young, inexperienced community (sa-mp) and it's not at all newbie-friendly.
Maybe you should have read the whole text. Systems dynamic is quite an affordable theory, even if the title might seems very frightening.
__________________
Moathib ─ thebinarychoice.com
Moathib is offline   Reply With Quote
Old 08/01/2017, 02:17 PM   #6
Dignity
High-roller
 
Dignity's Avatar
 
Join Date: May 2013
Location: Belgium
Posts: 1,932
Reputation: 1102
Default Re: System Dynamics 101

Quote:
Originally Posted by SickAttack View Post
Doesn't seem too helpful.
Like half of your posts

Quote:
Originally Posted by Moathib View Post
Maybe you should have read the whole text. Systems dynamic is quite an affordable theory, even if the title might seems very frightening.
Haha, it's not the title, it's the thread layout

I've skimmed over it and this is actually quite useful. I've found myself doing most of this automatically due to muscle memory since it seemed most logical, but this thread will definitely give some insight to some of the newer scripters that do want to learn more.

Great tutorial!
__________________

Dignity is offline   Reply With Quote
Old 08/01/2017, 02:57 PM   #7
SickAttack
Godfather
 
Join Date: Dec 2013
Posts: 5,113
Reputation: 754
Default Re: System Dynamics 101

Quote:
Originally Posted by Dignity View Post
Like half of your posts



Haha, it's not the title, it's the thread layout

I've skimmed over it and this is actually quite useful. I've found myself doing most of this automatically due to muscle memory since it seemed most logical, but this thread will definitely give some insight to some of the newer scripters that do want to learn more.

Great tutorial!
I think you mean yours actually, since all you do is advertise your project and be a douchebag.

-----

I'll tell you this right now, new scripters aren't going to have the slightest idea of what this is about.

Just look at Yaa's post for example (it's just an example, don't assume anything).

Too much chit-chat, not getting to the point as fast and clear as possible... Basically just trying to make it complicated so people think it's "advanced" - like people always like to use.

This is pure common sense for one that is fluent in English, or even for an average knowledgeable individual.

-----

@OP - This is just my option...

As you stated that you never learned to code in PAWN, I don't think you're suitable to give advice or a slight insight to people on how a system should be created, or even a gamemode, as you have no prior experience in the "practice" field. Both fields, second one being the theory, is required as to my point of view.

Nonetheless, it's too long, not clear and straightforward, and there are typos you should fix. Also, no-one is creating a game here, this is a modification for a game.

I just don't see anyone using this, even less to create a better server, or even a server that is interesting to you.
SickAttack is offline   Reply With Quote
Old 08/01/2017, 03:49 PM   #8
Moathib
Huge Clucker
 
Moathib's Avatar
 
Join Date: Nov 2010
Location: Belgium
Posts: 212
Reputation: 65
Default Re: System Dynamics 101

Quote:
Originally Posted by SickAttack View Post
I think you mean yours actually, since all you do is advertise your project and be a douchebag.
Please guys, that's not the point of the thread..

Quote:
Originally Posted by Dignity View Post
I've skimmed over it and this is actually quite useful. I've found myself doing most of this automatically due to muscle memory since it seemed most logical, but this thread will definitely give some insight to some of the newer scripters that do want to learn more.

Great tutorial!
Thanks. If you wanna go further, you should read "Business Dynamics ; Systems thinking and Modeling for a Complex World", by John D. Sterman. It's a reference book. You can buy it or find a PDF on ******. There's a whole chapter about CLDs.

Quote:
Originally Posted by SickAttack View Post
As you stated that you never learned to code in PAWN, I don't think you're suitable to give advice or a slight insight to people on how a system should be created, or even a gamemode, as you have no prior experience in the "practice" field. Both fields, second one being the theory, is required as to my point of view

Nonetheless, it's too long, not clear and straightforward, and there are typos you should fix. Also, no-one is creating a game here, this is a modification for a game.

I just don't see anyone using this, even less to create a better server, or even a server that is interesting to you.
I didn't code anything, but I designed two gamemodes. So I imagined and described a lot of game mechanics. How they were made into code wasn't my part of the job, I had a partner doing that (even if I had a little idea of what was possible or not).

If your GM are made to be played, then you are making "games", even if SA:MP is a mod. Includes or streamers, or just parts of code aren't ; maybe I should make this clearer in the text.
__________________
Moathib ─ thebinarychoice.com
Moathib is offline   Reply With Quote
Old 08/01/2017, 03:52 PM   #9
PrO.GameR
Gangsta
 
PrO.GameR's Avatar
 
Join Date: Oct 2012
Posts: 732
Reputation: 121
Default Re: System Dynamics 101

Quote:
Originally Posted by Dignity View Post
Like half of your posts
Ahahahahaha


@Moathib
As Dignity said it's the layout, you've lost half your readers about loop gain, while there's some useful stuff somewhere between some of boring diagram design essentials that you mentioned here.

I haven't had time to read it all, but so far it's basically some useless stuff (for newbies) + some mentions on the importance of creating a diagram, designing a system, putting notes and having a general idea on how it works before actually coding it, which is great, but rest is useless IMHO.
__________________
Blueberry Prison Roleplay will be back soon!
Follow the forums for more information about opening day.

Forums
PrO.GameR is offline   Reply With Quote
Old 08/01/2017, 04:04 PM   #10
SickAttack
Godfather
 
Join Date: Dec 2013
Posts: 5,113
Reputation: 754
Default Re: System Dynamics 101

The entire thread is practically useless tbh.
SickAttack is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] NRank System V1.0 | Advanced Rank System | 5+ Commands | Dialog System [Much More] Nirzor Filterscripts 9 18/04/2014 09:49 PM
Y_INI Dynamics ProjectMan Scripting Help 0 22/08/2013 02:23 AM
Using file.inc to write and read dynamics dcmd_crash Help Archive 2 27/04/2010 06:21 PM


All times are GMT. The time now is 12:38 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.