> For the complete documentation index, see [llms.txt](https://machinations.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://machinations.gitbook.io/docs/getting-started/framework-basics.md).

# Framework Basics

Machinations building blocks

At its core, the Machinations framework is based on:&#x20;

{% hint style="info" %}
6 types of Basic Nodes

1. **Pools** **collect** Resources
2. **Sources** **create** Resources
3. **Drains** **consume/destroy** Resources
4. **Converters** **transmute** various types of Resources into another
5. **Traders** **exchange** Resources
6. **Gates** **redistribute** Resources
   {% endhint %}

:heavy\_plus\_sign:&#x20;

{% hint style="info" %}
2 types of Connections:

1. **Resource Connections determine how** **Resources** **flow** through a diagram
2. **State Connections modify the state** of diagram elements
   {% endhint %}

{% hint style="success" %}

## :joystick: Public Diagram

Go through the text below and check out these examples: [Framework: Basic Nodes and Connectors](https://bit.ly/machinations-basics)

You can [Run](/docs/simulations/simulations.md) the diagram and Add it to your Machinations
{% endhint %}

## ◉ Resources

All game systems consist of elements in a constant flow of Resources.

Resources can be anything from money and property in Monopoly, ammo and HP in an FPS, or XP and equipment in an RPG.&#x20;

{% hint style="success" %}
Resources, together with the entities or actions that cause them to be produced, consumed and exchanged, make up the *games' internal economy*.
{% endhint %}

{% hint style="info" %}
*Any* Resource flow can be represented in a Machinations diagram.

Entities are represented by [Nodes](/docs/getting-started/framework-basics.md#nodes) and the way in which Resources are produced, consumed and exchanged is determined by [Connections](/docs/getting-started/framework-basics.md#connections).
{% endhint %}

## ⦽ Nodes&#x20;

:wrench: Below is an example of how Sources, Pools and Drains work. Notice the Nodes are linked together by Resource Connections (arrows) with a Label representing the rule by which the Resources will flow between Nodes.

![Sources, Pools and Drains](https://2667914601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGZcALyOGDKb9q0wdJ5%2F-LglSDzHYs2Cz0rKkKcD%2F-LglZNaAy9LDv2a1mfOC%2Fbasic-nodes.gif?alt=media\&token=5a72adc1-edc1-48e9-8a09-9d880250d276)

1. The Source, once clicked, produces 3 Resources which will be transferred to the Pool
2. The Drain consumes 3 Resources from the Pool
3. The Random Source randomly produces between 1 and 6 Resources each time it's clicked. The D6 Label notation stands for "Die 6". To establish the flow rate for each step, Machinations simulates the throw of a 6-faces die and the Source produces the resulted number of Resources
4. The Drain All Drain consumes all Resources in the Pool

:book: More on:

{% content-ref url="/pages/-LHI7hHtgov2Y62YMaXV" %}
[Pools](/docs/basic-nodes/pools.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LHI9OGNIajUVLzof530" %}
[Sources](/docs/basic-nodes/sources.md)
{% endcontent-ref %}

{% content-ref url="/pages/-LHI9bKiSxDRXitbJUw1" %}
[Drains](/docs/basic-nodes/drains.md)
{% endcontent-ref %}

:wrench: Here's a visual of how Converters and Traders work.

![](https://2667914601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGZcALyOGDKb9q0wdJ5%2F-LgliumRI6M3SvcQedvW%2F-LglkLUyxZHvc1SMIvFH%2Fconverter%26trader.gif?alt=media\&token=1a0d479b-e5aa-4aa8-8027-5168985ff2da)

1. The Converter transmutes 3 Resources from the origin Pool into 1 other Resource
2. The Trader exchanges 2 Coins for 3 Wood and moves these Resources into their respective repository: Coins to Pocket; Wood to Woodshed

:book: Dive into:

{% content-ref url="/pages/-LHIAPR7P-4f0PoiINrx" %}
[Converters & Traders](/docs/converters-and-traders.md)
{% endcontent-ref %}

:wrench: Gates are more complex Nodes, but the basic is that they redistribute Resources **deterministically** or **probabilistically**.

![](https://2667914601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGZcALyOGDKb9q0wdJ5%2F-LgliumRI6M3SvcQedvW%2F-Lglo26F1qSguMCIFuvP%2Fgates.gif?alt=media\&token=922745ef-9202-4aab-b2f0-7c030ac2925e)

1. The Deterministic Gate redistributes 9 Resources from the origin Pool and transfers them to each of the target Pool, according to the Labels, which in this case represent the **weights** of the outcomes
2. The Probabilistic Gate redistributes the 10 Resources from the origin Pool and transfers them to each of the target Pools according to the probability on their Labels

:book: Further reading:

{% content-ref url="/pages/-LHIA5sBBhzMkqrUOVFC" %}
[Gates](/docs/gates.md)
{% endcontent-ref %}

## ⇶ Connections

All the examples above feature **Resource Connections**. Full arrows that determine the way in which Resources flow through the diagram. More on this:

{% content-ref url="/pages/-LHIU0eTn2CLB54Xan4N" %}
[Resource Connections](/docs/connections/resource-connections.md)
{% endcontent-ref %}

:wrench: **State Connections**, on the other hand, modify the state of an element. Here's how:

![](https://2667914601-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LGZcALyOGDKb9q0wdJ5%2F-LglvXqwNUwvVNgM5yJW%2F-LglxqwnP-hy5igeOR9l%2Fbasicloop-state-connection.gif?alt=media\&token=bdcddff0-45a5-477d-bf81-f64e608ea58b)

In the example above, the State Connection modifies the Label on the Resource Connection, and alters the flow of Resources function to the number of Resources in the Pool. As such, it adds to the initial Label parameter (1) the number of Resources stored by the Pool after each Time Step.

There's more to State Connections than this, tough. They can modify Nodes' state and act like triggers or activators.&#x20;

:book: More on:

{% content-ref url="/pages/-LHIUD2DzTO-2kKZ1r-F" %}
[State Connections](/docs/connections/state-connections.md)
{% endcontent-ref %}
