I have a game state represented as a map and some logic that updates that state on every game 'tic'. But I can't figure out how to structure the update function in any sane way.
What is the idiomatic pattern for structuring functions like this?
Here is some pseudo code for what I want to do:
(defn tic [g] "Return an updated game"
g1 = (update-in g [:day] inc)
g2 = (if (some-cond) (some-update-func g1) g1)
g3 = (update-in g2 [:fu] fu-update)
... many more ...
g-last)
I don't really care about the intermediate states, but using the -> macro doesn't work (since there are some conditionals).
A hack that works is using a local atom that is reset! for every 'line' in the update function. But that can't be how it's supposed to be done?!