# 1.4 Determinism: the same program always gives the same result

> With the same program, the same inputs and the same seed, the engine always produces the same output, on any computer.

Web page: https://pseudolearn.app/en/spec/vision/determinismo

> **In one sentence**
>
> With the same program, the same inputs and the same seed, the engine always produces the same output, on any computer.

## 1.4.1 How it works

A program is **deterministic** if exactly the same thing happens every time you run it. In PseudoLearn this is a guarantee: the output, the way it ends, the diagnostics and the trace are identical on a phone, a laptop or in the browser.

To make that possible, the engine controls everything that could vary:

- **Randomness** comes from a source with a **seed**. Same seed, same sequence of numbers.
- Concurrent **tasks** take turns in a fixed order.
- The **clock**, files and network are requested as capabilities and can be recorded and replayed.
- **Memory** is reclaimed without the program being able to notice.

**Figure 1.4-1: Same seed, same sequence**

A box with seed 42 from which two runs leave. Both produce the sequence 1, 1, 6 and an equals sign joins them.

Two runs with the same seed produce the same sequence. Changing the seed changes the numbers, not the rules.

This specification is always built with seed 42. That is why this program writes the same numbers every time:

### Program: Three dice rolls

```pseudolearn
Algorithm Dados
  Write randomBetween(1, 6), " ", randomBetween(1, 6), " ", randomBetween(1, 6);
EndAlgorithm
```

**Output**

```text
1 1 6
```

*The program finishes normally.*

> **Analogy**
>
> A seed is like the way a deck of cards is shuffled: if two people shuffle exactly the same way, they draw the same cards. The analogy stops working in that the engine shuffles nothing; it computes each number from the previous one.

**In short**
- Same program, same inputs and same seed: same result.
- Randomness comes from a seeded source.
- Tasks, clock, files and network are controlled so as not to break determinism.
- Memory reclamation cannot be observed.

**See also**
- [12.5 Reproducible randomness](https://pseudolearn.app/en/spec/biblioteca/azar.md)
- [13.3 The task schedule](https://pseudolearn.app/en/spec/motor/agenda.md)
- [13.4 Effect order and the tape](https://pseudolearn.app/en/spec/motor/efectos.md)
