clojure-gamedev

NoahTheDuke 2019-11-04T16:11:02.003200Z

next question, friends! i have sequence of phases that happen "in order", which I've wired together normally. However, as this is a complex card game, various card effects can interrupt or change the order of those phases. For example, normally after the "approach server" phase, you "access cards" (sorry for terminology). However, a card effect says "the first time the "approach server" phase happens, move them back to the "approach ice" phase"

NoahTheDuke 2019-11-04T16:11:45.004Z

it's a state machine, but the available state machine tools that i've seen are a little more rigid than what I'm looking for

NoahTheDuke 2019-11-04T16:12:56.004800Z

does anyone have experience rolling your own finite state machine for this purpose? I experimented with multimethods, but writing the dispatch felt awkward

NoahTheDuke 2019-11-04T16:13:48.005400Z

should I just write a massive dispatch function that tries to take all of the exceptions into account?

unbalanced 2019-11-04T17:18:53.006400Z

ya know -- letfn in conjunction with trampoline is not a bad way to do it. Now -- I don't know how well that would work on the scale of a full game. But it works really well for simple state machines

unbalanced 2019-11-04T17:19:34.007Z

if you happen to have a copy of "Joy of Clojure" they cover how to implement mutually recursive state machines with that technique

unbalanced 2019-11-04T17:20:32.007700Z

(there's a link to the code from "Joy of Clojure")

NoahTheDuke 2019-11-04T19:03:22.008100Z

this is a great reason to finally buy a copy! thank you, i'll check that out