egonSchiele / dominion

A Dominion simulator in Haskell
Other
111 stars 11 forks source link

Question: Inefficient cards representation #3

Closed ajwheeler closed 10 years ago

ajwheeler commented 10 years ago

Would you be interested in me replacing _cards in GameState with a more efficient data structure? Perhaps with this library. I realize that it's not a huge deal since the number of cards in a game isn't massive, but I think it would be bennificial.

egonSchiele commented 10 years ago

I'm not familiar with that library...could you explain the benefits?

ajwheeler commented 10 years ago

Many of the functions are for fancy combinatorics, but the core of the library is the multiset (a mathematical set that can contain multiples of elements). It's basically a [(a, Int)] but with some nice helper functions.

I think something like this is a more natural fit for keeping track of all the cards. Of course there are other good options (perhaps a Map Card Int).

ajwheeler commented 10 years ago

There is also the option of directly using a list of tuples. Data.List provides a nice function

lookup :: Eq a => a -> [(a, b)] -> Maybe b
egonSchiele commented 10 years ago

The Map option sounds good to me. If you send over a pull request, I'll merge it in.