# Advanced Nodes

### Getting Started

### Examples

### Simulations

### Connections

### Advanced Nodes

### Nodes Properties

### Custom Variables

### Collaboration

### Accounts

### Unity Plugin (UP) & API

### Evolution

## Sorting Gates

Sorting Gates redistribute Resources without collecting them.

Sorting Gates have **Resource Connections** as outputs.

π‘ Depending on the **Sorting Gate’s distribution mode** AND its **Resource Connections’ Formula**, it will sort the Resources going through them.

The algorithm is applied for **each Resource** going through the Gate, even if there are more than 1 Resources going through it in one Step.

βπ§Β E.g.: If there are 10 Resources going through a Gate in 1 Step, each of these Resources will be redistributed according to the **algorithm set by the Gate’s distribution mode, Output Connections’ type, and Output Connections’ Formulas.**

Here are all types of Sorting Gates and their expected actions.

**Deterministic Sorting Gates sort Resources** according to the Formulas on their output Resource Connections.

A Deterministic Gate with Resource Connections as input and outputs, for which the Formulas on the Output Resource Connections have **numeric values** that set the **weights **for the redistribution algorithm.

π‘ The **order** in which Resources are being sent towards their targets depends on the order in which the resource connections going from the gate towards its targets were added to the diagram.

Notice the difference between the 2 examples below:

**Here’s how the sorting algorithm works:**

- The sorting algorithm will be applied to each of the Resources going in
- The first Resources will be redistributed towards the upper Pool, through the connection that was added first. They will continue to be directed towards it until the weight is reached. In this case, the first 2 Resources will go towards the first Pool. 1 part out of 4 (1+3) of 8 Resources (1/4 of 8)
- The rest of the Resources will go towards the other Pool. 3 parts out of 4 of 8 Resources (3/4 of 8)

If the Resources and their weights do not result in an integer amount of Resources, the algorithm will “even the score” throughout multiple Steps.

**Here’s an example:**

- Mathematically, the redistribution of the 10 Resources would amount to 10*1/4 (2.5) Resources towards the first Pool and 10*3/4 (7.5) Resources towards the second.
- Pools cannot collect fractions of a Resource. Therefore the algorithm will send a combination of either 3 and 7 Resources OR 2 and 8 Resources during each consecutive Step of the execution.
- In the example above, in the model on the right, we use Drains to empty the pools at the beginning of each step – Go through this example using Step Play.

A Deterministic Gate with Resource Connections as input and outputs, for which the Formulas on the Output Resource Connections have **weighted rate values** that set the **probabilities AND the weights **for the redistribution algorithm.

π‘ The order in which the Resources are redistributed towards the targets is given by the probabilities on the Output Resource Connections’ Formulas.

π§ Each Resource going through the Gate will be redistributed according to the probabilities on the output Resource Connections – this is obvious in the example on the left. The Resources will also be redistributed weighted – see the example on the right.

π‘ To better understand this, add this example to your Machinations and perform a Batch Play on both examples above.

If the **SUM** of the weighted rates **is below 100%**, the algorithm will **drop/destroy** the Resources that exceed the redistribution rates.

If the **SUM** of the weighted rates **exceeds 100%**, the algorithm will **normalize** the rates.

π§ In the example above, the working rates are normalised, and become: (50/130*100)%; (60/130*100)% and (20/130*100)%.

A Deterministic Gate with Resource Connections as input and outputs, for which the Formula on the Output Resource Connections have **conditional values** that set the **rules **for the redistribution algorithm.

π‘ Deterministic Gates with conditional outcomes take into account the** sequence of Resources/Step**.

π§ Each Resource that goes through a Gate within a Step will be given an order number (1st Resource, 2nd Resource, etc.) and redistributed accordingly.

Here’s what happens: the algorithm redistributes each Resource depending on its order number – the first 3 Resources go through the <4 Connection, while everything else goes through the >=4 Connection.

In the example above, changing the Gate’s Input Connection Formula so that **>4 Resources are produced and redistributed during a Step** will determine the algorithm to ALWAYS redistribute the Resources towards the >=4 Connection.

A Random Gate with Resource Connections as input and outputs, for which the Formulas on the Output Resource Connections have **numeric values** that set the **weights **for the redistribution algorithm.

π‘ For each Resource passing through, the Gate the algorithm will throw a die with a number of faces equal to the SUM of weights on the Output Connections. This will determine towards which Connection the Resource will be redistributed also taking into account the weights determined by the Connections’ Formulas.

The number displayed by the Gate during execution is NOT the result of the die throw, but the order number of the branch the Resource will be distributed through.

π§ Here’s what happens in the example above: For each Resource, the algorithm uses a die with 4 faces (1+3). If the die throws 1, the Gate redistributes the Resource towards the 1st Resource Connection. If the die throws either one of 2, 3, or 4, the Resource will be redistributed towards the second Resource Connection.

**Use the pie charts below to visualise the algorithm. **The pie chart in the middle represents the 4-faced die and the equal chances for it to throw either one of the numbers on it: 25% chance for each face. The outer pie chart’s sections represent the weights according to which the Resources will be redistributed towards the Output Connections, considering the result of the die throw.

A Random Gate with Resource Connections as input and outputs, for which the Formulas on the Output Resource Connections have **percentage values**.

π‘ For each Resource passing through the Gate, the algorithm throws a 100-faced die. This will determine towards which Connection the Resource will be redistributed also taking into account the weighted rates on the Connections’ Formulas.

The number displayed by the Gate during execution is NOT the result of the die throw, but the order number of the branch the Resource will be distributed through.

π§ Here’s what happens in the example above: For each Resource, the algorithm throws the 100-faced die, any result that falls between 1 and 40 will go through the first Resource Connection, all else will go through the second connection.

Same as with the previous example, consider these 2 pie charts to visualise the algorithm.

The 100-faced die is the pie chart in the middle, and each of its sections represents the probability of the die to throw 1 of its faces (1% for each). All faces between 1-40 will be redistributed towards the 40% weighted rate Pool, whilst all others will go through to the 60% weighted rate Pool.

If the **SUM** of the weighted rates **is below 100%**, the algorithm will **drop/destroy** the Resources that exceed the redistribution rates.

If the **SUM** of the weighted rates **exceeds 100%**, the algorithm will **normalize** the rates. (See Deterministic Gates with probable outcomes for how normalization works)

A Random Gate with Resource Connections as input and outputs for which the Formulas on the Output Resource Connections have **conditional values**.

π‘ For each resource going through the Gate, the algorithm throws a die with a number of faces equal to the die set at diagram level `(Diagram Properties > Dice`

) and then redistributes the Resources according to which condition the number on the die meets.

In this case, **the Gate displays the result of the die throw.**

π§ In the example above, the die is a D10. The throws that result in a number that’s below 4 will go through the <4 branch, all else through the >=4 one.