
I'm having a go at making a functional board game (the back-end logic for one, at least) and as with all good projects it raises lots of questions. But I'll keep it to one this time. Does anyone know of functional-style implementations of chess/draughts/go/anything else that might give me ideas? I am writing a game of Thud (yes, from the Terry Pratchett book...) but I don't hold much hope of their being a functional-style Thud game already in existence! Cheers, D. -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net

Ralph Glass has a Xiang Qi board: http://xiangqiboard.blogspot.com/
On Mon, Apr 21, 2008 at 11:22 AM, Dougal Stanton
I'm having a go at making a functional board game (the back-end logic for one, at least) and as with all good projects it raises lots of questions. But I'll keep it to one this time.
Does anyone know of functional-style implementations of chess/draughts/go/anything else that might give me ideas? I am writing a game of Thud (yes, from the Terry Pratchett book...) but I don't hold much hope of their being a functional-style Thud game already in existence!
Cheers,
D.
-- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
-- I try to take things like a crow; war and chaos don't always ruin a picnic, they just mean you have to be careful what you swallow. -- Jessica Edwards

Hello Dougal, Monday, April 21, 2008, 7:22:49 PM, you wrote:
Does anyone know of functional-style implementations of chess/draughts/go/anything else that might give me ideas? I am writing
once we have seen 100-line chess published in this list -- Best regards, Bulat mailto:Bulat.Ziganshin@gmail.com

bulat.ziganshin:
Hello Dougal,
Monday, April 21, 2008, 7:22:49 PM, you wrote:
Does anyone know of functional-style implementations of chess/draughts/go/anything else that might give me ideas? I am writing
once we have seen 100-line chess published in this list
There's more than a dozen games here, http://haskell.org/haskellwiki/Applications_and_libraries/Games including hsChess.

Bertrand Felgenhauer[1] wrote a peg solitaire game[2] using Prompt[3]
to interact with the user.
Here's the core game loop:
-- move a peg into a certain direction
data Move = Move Pos Dir
-- solitaire interface
data Request a where
RMove :: Board -> [Move] -> Request Move -- select a move from given list
RDone :: Board -> Int -> Request () -- game over
-- implement the game logic
game :: Prompt Request ()
game = game' start
-- find possible moves, end game if there are none, otherwise ...
game' :: Board -> Prompt Request ()
game' b = do
let options = filter (validMove b) allMoves
if null options then prompt $ RDone b (length (pegs b))
else game'' b options
-- ... prompt for a move and execute it
game'' b options = do
Move (x, y) d <- prompt $ RMove b options
let (dx, dy) = delta d
game' (Board (board b // [((x, y), Empty),
((x + dx, y + dy), Empty),
((x + 2*dx, y + 2*dy), Peg)]))
-- ryan
[1] http://www.haskell.org/pipermail/haskell-cafe/2008-January/038301.html
[2] http://int-e.home.tlink.de/haskell/solitaire.tar.gz
[3] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/MonadPrompt-1.0.0...
On Mon, Apr 21, 2008 at 8:22 AM, Dougal Stanton
I'm having a go at making a functional board game (the back-end logic for one, at least) and as with all good projects it raises lots of questions. But I'll keep it to one this time.
Does anyone know of functional-style implementations of chess/draughts/go/anything else that might give me ideas? I am writing a game of Thud (yes, from the Terry Pratchett book...) but I don't hold much hope of their being a functional-style Thud game already in existence!
Cheers,
D.
-- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

On Mon, Apr 21, 2008 at 5:08 PM, Ryan Ingram
Bertrand Felgenhauer[1] wrote a peg solitaire game[2] using Prompt[3] to interact with the user.
Thanks to everyone for the suggestions, particularly the Games page on the Haskell wiki which didn't appear in all my googling atttempts. Also, I had been hoping to have a go with Prompt after I saw it first time round but couldn't remember what it was called! So thanks to Ryan for bringing it up again. Cheers, D. -- Dougal Stanton dougal@dougalstanton.net // http://www.dougalstanton.net

Hi Dougal,
Does anyone know of functional-style implementations of chess/draughts/go/anything else that might give me ideas?
there's the Mate-in-N solver in the nofib suite: ftp://www.cs.york.ac.uk/pub/haskell/nofib.tar.gz It takes quite a simple approach, representing the board as two lists (white and black) of piece/square pairs, where a square is just a pair of ints. Matt.
participants (6)
-
Bulat Ziganshin
-
Don Stewart
-
Dougal Stanton
-
Jefferson Heard
-
Matthew Naylor
-
Ryan Ingram