So, I was reading a bit about continuations the other day, and, since I've been thinking about good ways of expressing chess strategies in Haskell, I thought that I'd play around a bit with something like continuations for game-playing strategies. The idea is that you have combinators that allow you full access to the strategies which remain to be applied. In this way, strategies can "activate" and "de-activate" other strategies. Here's a simple little toy app for Tic-Tac-Toe (Naughts and Crosses):<br>
<br><a href="http://codepad.org/nN9JsxFK">http://codepad.org/nN9JsxFK</a><br><br>You can run main on 'example', and see that it searches every line and fails. And, as you can see, it aborts after finding a win in example2. This would be easily extensible to say things like "if you've seen a blocking move, and you don't have a win, then play the blocking move", and of course the other deep intricacies of the game.<br>
<br>My question is, is this, in fact, related to continuations somehow? Could continuations simplify it? Or am I doing something completely different?<br>