Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Thanks! What do you mean by deterministic/destructive updates?


No idea what destructive updates are, but determinism is when you can run multiple times in multiple environments and get the same results


then yes, it is deterministic :)


I 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.


Destructive updates are where computing the next step in the simulation destroys or overwrites the previous step.

This is destructive:

    this.position += this.velocity


The alternative being to store a history of the simulation?


The 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: