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.
A box with seed 42 from which two runs leave. Both produce the sequence 1, 1, 6 and an equals sign joins them.
This specification is always built with seed 42. That is why this program writes the same numbers every time:
ProgramThree dice rolls
Algorithm Dados
Write randomBetween(1, 6), " ", randomBetween(1, 6), " ", randomBetween(1, 6);
EndAlgorithmOutput
1 1 6
The program finishes normally.
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.