[Haskell] Helpful libraries to implement a board game?

Paul Johnson paul at cogito.org.uk
Sun Apr 19 17:49:04 EDT 2009


Frank Rosemeier wrote:
>
> Dear Haskellers,
>
> I would like to implement a board game for a single player in Haskell.
> The pieces may be moved one step in any direction if there is no piece 
> next to it,
> and the goal is to rearrange the pieces to their home positions.
> The Haskell program should find an optimal solution (with minimal 
> number of moves).
>
> Can anybody recommend some helpful libraries for this task?
> Any hints are very welcome!
This sounds like a homework problem, so I'll be a bit vague.

This is a job for a combination of the list and state monads.  Something 
of type ListT (State GameState) will probably be important.  You just 
need to define the GameState type and something to give you a list of 
legal next moves :: GameState -> [GameState].

After that, its trivial.

Paul.


More information about the Haskell mailing list