7 ms·
Cool! Is it deterministic? Does it do destructive updates?
by mobiletelephone 9y ago
Cool!
Is it deterministic?
Does it do destructive updates?
- xchip 9y agoThanks! What do you mean by deterministic/destructive updates?
- kroltan 9y agoNo idea what destructive updates are, but determinism is when you can run multiple times in multiple environments and get the same results
- xchip 9y agothen yes, it is deterministic :)
- reificator 9y agoI don't mean to be rude, but if you don't know the term I'd put money on it not being deterministic. Especially if you're running in JavaScript on multiple browsers. A single step that isn't consistent in behavior across every setup is enough to make the entire process non-deterministic.
- mobiletelephone 9y agoDestructive updates are where computing the next step in the simulation destroys or overwrites the previous step. This is destructive: this.position += this.velocity
- gugagore 9y agoThe alternative being to store a history of the simulation?
- T-hawk 9y agoThe alternative is to treat the simulation as a series of immutable instants. Every step of the simulation is encapsulated and represented as a data structure. So the core loop would look something like nextState = advanceFrame(currentState) , where currentState is immutable and contains every piece of information needed to calculate nextState. Then you can do whatever you want with that series of immutable instants. You might pass that data structure to a function for rendering, or for storing history, or whatever else. You might even do something clever like pass two consecutive steps into your rendering function, so you can calculate motion blur between them. Treating each simulation step as an instance of a data structure means you decouple the simulation state and time from your program state and time. Novice programmers often use global variables to hold the state of a simulation or game, but there's a smarter way to do it. You insert a layer of abstraction between your program's control flow and the simulation's time flow.