[Haskell-cafe] Nomic game in Haskell
Dan Piponi
dpiponi at gmail.com
Thu Apr 15 17:00:45 EDT 2010
Dupont asked:
> do you know Nomic?
> It's a fabulous and strange game where you have the right to change the rules in the middle of the game!
I know nomic, but as has been pointed out, it's too wide-ranging to be
captured in Haskell. So how about a game played in the Haskell type
system where you get to play whatever type you like?
Let's restrict ourselves to a total fragment of Haskell. Only allow
structural recursion and that sort of thing.
The 'board' is a Haskell type function. It'll look something like this:
type Board a b c ... y z = ...
with type variables a to z (no need to have precisely 26) and so that
the right hand side is a type, not another type function.
(A neutral third party will have to implement Board.)
There are two players. They take turns where a turn consists of
picking a concrete type to bind to precisely one previously unbound
type variable. When there are no more legal moves left, player 1 now
has to exhibit an element of the resulting type. If they succeed, they
win, otherwise player 2 wins. Void is allowed.
For example, consider
type Board a b c d e f g = (Either a b, Either c d, Either e f, g)
Player 1 must start by making g a type they know how to instantiate.
Maybe g=Int. If not, then Player 2 chooses g=Void and they will never
be able to make one of these 4-tuples. From now on, Player 2 has sente
(to use go language) because Player 1 will always have to play in the
same factor of the 4-tuple that Player 2 played in. Ultimately,
however, Player 1 can force a win.
--
Dan
More information about the Haskell-Cafe
mailing list