6 ms·
I've tried to write games in a pure FP style in Scheme, and, like Hague, found that the difficulty is in keeping track of state in a sane and efficient way. I
by jcw 16y ago
I've tried to write games in a pure FP style in Scheme, and, like Hague, found that the difficulty is in keeping track of state in a sane and efficient way.
I suspect that Haskell's monads are a solution. Can someone with Haskell experience attest to this?
- zach 16y agoMy favorite style, which I think maps well to functional use, is to have the entirety of game state (including random number seeds, etc.) be in one "world" data structure, call it W. Then, you collect all your input (say, controller axis values) into another structure, I. So each simulation step takes you from W + I => W' which you hand off to the pre-renderer and the next simulation step. The pre-renderer will combine the game world state with static data (i.e. models and shaders) and produce game-state-free data that a renderer can display to the user. This is the basic framework I've used for twelve years when I've been able to implement it (i.e. not often at my day job). It's worked really well, but I actually have not applied it in a language that supports purely functional programming. So you can guess why I'm in this thread.
- swannodette 16y agoFWIW, this is exactly the model that Penumbra adopts. I'm curious to see how this scales with more complex games. I think there's a lot of awesome research / experimentation /documentation to be done here.
- zach 16y agoExcellent! Well, I guess we have the first article for the wiki then.