
Hi! I would like to know if anybody has already thought of or tried to code an EDSL for card games. Ideally you should be able to write the rules the games and get "for free": - Game generator: given an input deck, construct the initial state of the game. - Random game generator: besides just creating a random deck and using the item above, it should be nice to be able to randomly construct the game from the final positions. This should guarantee that all random games are solvable. - "Hints" generator: IOW list possible moves given a game state. - Playable game: probably the EDSL should include at least some information to be able to properly place the cards on the screen. - Game solver: this is somewhat harder to do efficiently, but an inneficient one should be doable. - Demo mode: related to the above, an auto-play distract-me mode. - Tutorial mode: show a screen for each of the rules written? - ...anything more? Just curious, this looks like a perfect job for an EDSL. Also, I guess anybody trying to do something like this should read PySol's code to have some ideas. -- Felipe.

You might peek at my library HCard (it's on Hackage), it uses associated datatypes to allow for a very general playing-card interface. It was only ever a toy to play w/ Assoc. types for me, but I imagine it could be a decent starting point for someone interested in turning it into a real EDSL. It's got a cribbage counter example program bundled with it. /Joe On Nov 7, 2009, at 5:54 AM, Felipe Lessa wrote:
Hi!
I would like to know if anybody has already thought of or tried to code an EDSL for card games. Ideally you should be able to write the rules the games and get "for free":
- Game generator: given an input deck, construct the initial state of the game.
- Random game generator: besides just creating a random deck and using the item above, it should be nice to be able to randomly construct the game from the final positions. This should guarantee that all random games are solvable.
- "Hints" generator: IOW list possible moves given a game state.
- Playable game: probably the EDSL should include at least some information to be able to properly place the cards on the screen.
- Game solver: this is somewhat harder to do efficiently, but an inneficient one should be doable.
- Demo mode: related to the above, an auto-play distract-me mode.
- Tutorial mode: show a screen for each of the rules written?
- ...anything more?
Just curious, this looks like a perfect job for an EDSL. Also, I guess anybody trying to do something like this should read PySol's code to have some ideas.
-- Felipe. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Hi Felipe
Close (or maybe not...), Martin Erwig and Eric Walkingshaw have a few
papers on embedding a DSL in Haskell for game theory available from
Martin's web site:
http://web.engr.oregonstate.edu/~erwig/papers/abstracts.html
Best wishes
Stephen
2009/11/7 Felipe Lessa
Hi!
I would like to know if anybody has already thought of or tried to code an EDSL for card games. Ideally you should be able to write the rules the games and get "for free":

Hi Felipe, Interesting idea. But I guess you should clarify what kind of card games you want to support. E.g, a DSL for trick taking games like Bridge, Skat or Doppelkopf might be different from one that's good for Canasta or Rummy. Or do you aim at Solitaire? I'd suggest starting with a very small scope of the domain for a very first version. Good luck writing a `solver' for Doppelkopf! Cheers, Matthias.

On Sat, Nov 07, 2009 at 08:46:07AM -0500, Matthias Görgens wrote:
Interesting idea. But I guess you should clarify what kind of card games you want to support. E.g, a DSL for trick taking games like Bridge, Skat or Doppelkopf might be different from one that's good for Canasta or Rummy. Or do you aim at Solitaire? I'd suggest starting with a very small scope of the domain for a very first version.
Hmm, good catch. I was thinking about solitaire, i.e. single player, games. Multiplayer card games certainly have their own set of interesting challenges. If I ever get to develop something capable of expressing nicely Patience, Spider, Pyramid and Black Hole I'll be more than satisfied :). Cheers, -- Felipe.

On Sat, Nov 7, 2009 at 8:07 AM, Felipe Lessa
On Sat, Nov 07, 2009 at 08:46:07AM -0500, Matthias Görgens wrote:
Interesting idea. But I guess you should clarify what kind of card games you want to support. E.g, a DSL for trick taking games like Bridge, Skat or Doppelkopf might be different from one that's good for Canasta or Rummy. Or do you aim at Solitaire? I'd suggest starting with a very small scope of the domain for a very first version.
Hmm, good catch. I was thinking about solitaire, i.e. single player, games. Multiplayer card games certainly have their own set of interesting challenges.
If I ever get to develop something capable of expressing nicely Patience, Spider, Pyramid and Black Hole I'll be more than satisfied :).
I'd be interested in something which could model games of Dominion [1], as it's my current addiction; it's a (non-collectable) card game where you build and tune your deck as you play, and aside from money and victory point cards (which are always available) randomly has available ten possible "action" card types to buy each game (out of the total set of action card types — 76, as of the latest expansion). There have already been various basic analyses of various possible strategies assuming simple rules; if a strategy can't beat the "baseline" strategy "Big Money" (which involves buying nothing but money and victory points the entire game), it should probably be scrapped. [1] http://www.boardgamegeek.com/boardgame/36218

Hi Tom, Did you make any progress on your Dominion quest? I guess you could start by modeling `Big Money' and add the other cards (and interaction) from there. Also I guess there is a common baseline of things that are inherent in a lot of card games --- mechanics that cards support: Shuffling, having two sides, hiding one of two sides, picking a random card from a subset (or at least one where you can only see one side), placing cards in constellations on a table (with one side up). I guess with a bit of type system trickery you can even make sure that strategies don't look at the sides of the cards they are not supposed to look at --- without having to do any other information hiding like only providing access by getter functions. Matthias.

2009/12/3 Matthias Görgens
Hi Tom,
Did you make any progress on your Dominion quest? I guess you could start by modeling `Big Money' and add the other cards (and interaction) from there.
No, I'm still trying to tune a "partitionM" function I wrote. (I'm still a beginner.) ^_^ I'd like to write a Dominion library or some more generic superset at some point, though.

Am Donnerstag 03 Dezember 2009 19:23:24 schrieb Tom Tobin:
2009/12/3 Matthias Görgens
: Hi Tom,
Did you make any progress on your Dominion quest? I guess you could start by modeling `Big Money' and add the other cards (and interaction) from there.
No, I'm still trying to tune a "partitionM" function I wrote.
Maybe we can help?
(I'm still a beginner.) ^_^ I'd like to write a Dominion library or some more generic superset at some point, though.

Yah! We like helping! On Dec 3, 2009, at 2:37 PM, Daniel Fischer wrote:
Am Donnerstag 03 Dezember 2009 19:23:24 schrieb Tom Tobin:
2009/12/3 Matthias Görgens
: Hi Tom,
Did you make any progress on your Dominion quest? I guess you could start by modeling `Big Money' and add the other cards (and interaction) from there.
No, I'm still trying to tune a "partitionM" function I wrote.
Maybe we can help?
(I'm still a beginner.) ^_^ I'd like to write a Dominion library or some more generic superset at some point, though.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Am Donnerstag 03 Dezember 2009 21:24:11 schrieb Tom Tobin:
On Thu, Dec 3, 2009 at 1:37 PM, Daniel Fischer
wrote: Am Donnerstag 03 Dezember 2009 19:23:24 schrieb Tom Tobin:
No, I'm still trying to tune a "partitionM" function I wrote.
Maybe we can help?
Sure; should I post it to haskell-beginners?
Here, there, most of us are subscribed to both lists.

On Thu, Dec 3, 2009 at 2:29 PM, Daniel Fischer
Am Donnerstag 03 Dezember 2009 21:24:11 schrieb Tom Tobin:
On Thu, Dec 3, 2009 at 1:37 PM, Daniel Fischer
wrote: Am Donnerstag 03 Dezember 2009 19:23:24 schrieb Tom Tobin:
No, I'm still trying to tune a "partitionM" function I wrote.
Maybe we can help?
Sure; should I post it to haskell-beginners?
Here, there, most of us are subscribed to both lists.
I posted it to the beginners list, subject "partitionM".
participants (6)
-
Daniel Fischer
-
Felipe Lessa
-
Joe Fredette
-
Matthias Görgens
-
Stephen Tetley
-
Tom Tobin