3 ms·
Conceptually it's very easy: World(t+1) = Sim(World(t)) but performance in practice is going to suffer a lot compared to in-place mutation, for any simulation
by Jare 11y ago
Conceptually it's very easy:
World(t+1) = Sim(World(t))
but performance in practice is going to suffer a lot compared to in-place mutation, for any simulation that has a great degree of temporal coherence. I don't know of real world examples of game developed with immutable / reactive patterns, outside of thought experiments like Carmack's (Or Tim Sweeney's), or a few simple games in Haskell, Elm, etc. But I'd love to hear of more examples.
(Edit: some parts of games and game engines use this sort of "double buffer" approach for other purposes: smoothing and interpolation mostly, of visual frames in between logic ticks, or for network prediction. But in the cases I have seen or coded, most of the world state is not interpolated and not duplicated)
- stcredzero 11y agoI am not yet a professional game developer, but I did write a multiplayer server in Clojure. It had most of the features of the current version, which was ported to golang: https://secure.emergencevector.com:8000/ https://secure.emergencevector.com:8000/ (Be sure to mouse click on the map, otherwise your arrow key keystrokes may never get read due to focus.) I got pretty similar performance out of Clojure's persistent collections as I got out of mutable state in a traditional game loop in golang. (Though to be honest, in neither case was that enough performance. 150 to 250 concurrent users, potentially all in the same location, interacting.)