Fork me on GitHub
#clojure-gamedev
<
2019-11-04
>
Noah Bogart16:11:02

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"

Noah Bogart16:11:45

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

Noah Bogart16:11:56

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

Noah Bogart16:11:48

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

Lone Ranger17:11:53

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

Lone Ranger17:11:34

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

Lone Ranger17:11:32

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

Noah Bogart19:11:22

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