48

Dominion Card Picker / Randomizer

Posted July 16th, 2009. Filed under

I spent today dusting off my old PHP and SQL skills. If you play the card game Dominion, you may be well aware that an expansion just released called Dominion: Intrigue that doubles the number of cards. (If you don’t play Dominion, what the hell, man? It’s the best card game since Texas Hold’Em.)

Well, there’s an issue with playing with both the base set of Dominion and the new Intrigue set. To figure out which ten cards to play with, you have to mix cards from different sets together, shuffle, draw and then put those away and get out the piles of the corresponding cards. What a chore.

So I threw together the Dominion Card Picker.

With it, you can choose which sets you want to play with (including the promo cards if you have them) and the script will shoot out a random ten cards for you to play with, including letting you know which set each belongs to so you can dig them out of the correct box.

You can also add constraints to make the selection less lame like requiring a card with an extra buy to be in the ten or at least one card that nets an extra action.

Try it out and let me know if there are bugs or any ideas to improve it.

48 Responses so far

  1. Peter Cyrus says:

    How about an option to generate a nice distribution of prices? For the complete set, that would be :
    1@ $2
    2@ $3
    3@ $4
    3@ $5
    1@ $6

  2. Bryan Rankin says:

    Zach,

    I’d like to second a request I saw on the geek. A checkbox for text only would be very useful.

    -Bryan

  3. Mark says:

    Grakthis posted this on MTGRobot:

    “tell your friend to re-format this page so it looks better on phones and other mobile platforms. it’s awful on my pre. he just needs to make it less “landscape” looking and more vertical. Also, make the page smaller and the box for entering the info bigger. Also, have him just code it as a Pre app, tia.”

  4. Zack says:

    Tell him to get an iPhone.

    jk, I’ll add it to my list.

  5. Bryan Rankin says:

    Allowing choice of a 5-5 or x-y Dominion-Intrigue split would be nice.

    A button to record a play to the geek (including card set in the comments) would be TOTALLY RAD.

  6. Myron says:

    Awesome tool. I have seen a bug. I occasionally will get duplicate cards. Two workshops, two envoys etc… when I run the tool.

  7. Soren says:

    Ditto on the duplicate card bug.

    Settings: Base + Intrigue, all options on except distribution.

    What algorithm do you use to prevent dups?

  8. Just want to say thanks for creating it. I started lunchtime gaming at work a few months ago and now we often have two games of dominion going, since I’ve started breeding gamers. Even my husband will play this one with me. This makes the card picking so much easier. Added as a favorite on my smart phone as well, and sent it to all my dominion players. Thanks again!

  9. M. Evans says:

    Really cool idea. I think I know what your next step should be. Somehow turn this into an app for Iphone or Ipod. Much easier to carry that around then a computer.

  10. apathy says:

    2 things, since part of the purpose is to limit the hunting and pecking you might want to offer two sortby options.
    Sort by alphabetical only (I just combined all my sets to make life easier)
    or Sort by Set then by Alphabetical.

    2nd is another filter – “include at least 1 attack card”

    Not sure how you did the programming, but if you have DB or arrays you should have the info to allow for the sort-by.

  11. chad56s says:

    Ditto on the sorting – I like that it sorts by cost, but if it could then sort alphabetically (i.e. sort by cost first then alphabetical) it would be greatly appreciated. Use this all the time! Thanks!

  12. Henry says:

    A way to select custom cards would be great.

  13. Ceryon says:

    When using “Another 10 cards” the option “If there is an Attack card, require a Reaction card.” isn’t remembered.

  14. FFL_King says:

    I would like an option that if a card that generates curses that a card that can potentially remove a curse also be added (either through discard a card or modify)

  15. Zack says:

    Alrighty. Added alphabetical sorting.

  16. Chris Douglas says:

    Hi there! I would like to ask your permission to use your scanned card images for a JavaScript version of Dominion Card Picker. I would like to have a tool that I can use on my netbook when I do not have an internet connection.

    Thanks,
    Chris.

  17. Zack says:

    Hi Chris. I don’t own the images. They are mostly scraped from the images on BoardGameGeek. If you haven’t been to there, I’d recommend it. All that I ask is for folks not to hotlink my images, but if you are working on an offline app that shouldn’t be a problem.

  18. Accidental Saboteur says:

    Hi, sorry, I think I may have crashed your Dominion card picker; I accidentally sent a randomize request with the Stash promo card checked while all the others were unchecked.

  19. Zack says:

    I just checked it. It shouldn’t crash, just give you an error message. Try again.

  20. Nathan says:

    May we please have an option to sort by Set? I don’t know how many times I’ve had to pull out expansion boxes multiple times because I overlooked a card. Better still, keep all the current output, and sort, but add a set-sorted, text-only list to the side, such as:

    Dominion:
    Village
    Witch
    Library

    Intrigue:
    Wishing Well
    Tribute

    Seaside:
    Native Village
    Lighthouse
    Cutpurse
    Navigator
    Treasury

    Thank you! Eternally helpful tool!

  21. Gwommy says:

    Hey Zack!

    I love the Dominion card randomizer, especially since I can bring it up on my phone where ever I go to play Dominion. Anyway, I was curious as to when Alchemy will be up and running for random selection? I’d suggest having an extra option for requiring there to be at least 3-5 Alchemy cards(as suggested in the rule book), although I’m sure some players wouldn’t mind playing with only 1 or 2 of them, like myself. Thanks!

  22. Zack says:

    Hi Gwommy,

    I keep looking for all the image files to show up on BGG. I need those first as I don’t have the set yet and cannot scan them myself. I promise it won’t be too long, hang in there!

  23. Mark Diehr says:

    Hey Zack, I’ll be getting some better Alchemy scans from Donald in a couple days, I can send you a zip or something.

    Also, can you re-point your base-set cards from http://dominion.diehrstraits.com/scans/1e/village.jpg to http://dominion.diehrstraits.com/scans/base/village.jpg ? I am reorganizing how things are set up on my site. I will keep the old directory there until you switch it over.

  24. Mark Diehr says:

    Oh, a bug: If you uncheck Alchemy it still adds in Alchemy cards unless you uncheck the setting for 3-5 cards beneath it.

  25. Zack says:

    Mark: Fixed

  26. Michael Duggan says:

    I’m not sure if this is a bug or not. With Alchemy and 3-5 cards checked, I never seem to get a set /without/ Alchemy cards. Is this intentional?

  27. Zack says:

    Actually, that was intentional, but I will be changing it the next time I update.

  28. Michael Duggan says:

    Thanks. Should have mentioned my thanks for this tool. It is a real time-saver for our lunchtime games.

  29. Andrew says:

    I’d like to second the request for a sorting option that sorts by set.

  30. Gwommy says:

    Another thing that would be useful as an optional parameter is that if you’re playing with curses, include a card to be able to trash them.

    Cards that can give curses include:
    Familiar
    Sea Hag
    Swindler
    Torturer
    Witch
    Embargo(non-attack)

    Cards that can trash or remove curses:
    Ambassador
    Apprentice
    Chapel
    Lookout
    Masquerade
    Remodel
    Salvager
    Steward
    Trading Post
    Transmute
    Upgrade

  31. Brad says:

    Frequently, my lunchtime group has enough people to play two games out of the base set and the expansions. Can you make an option of generating two sets of ten cards with no overlaps?

  32. Ed says:

    A friend of mine got tired of the same old card game we play every weekened and got this, i m getting really addictive to this and playing 24/7, i found this program to be extremely helpful…as ppl suggested, it would be awesome if you can turn this into a iphone app.

  33. David says:

    I snagged Prosperity at GenCon. What would you need from me to get those posted too?

  34. Zack says:

    I picked it up there too. Prosperity will be added when I get time to code the changes. It will probably happen in two phases: one release to get the cards in and one to knock out some new restrictions/filters.

  35. Brian says:

    Great tool, thank you! I would love to have the ability to save fun card sets in a permanent hot link. For example, I just played a really fun set of cards, and I want to save it in case I want to play it again, or so I can send it to my friends so they can try it. One way to implement this would be to assign like… a 4-digit hexadecimal number to each card, and then when someone clicks “save”, you create a link with the 40 hex digits needed to recreate the game. Parsing the link to display the cards would obviously be trivial. THANKS!

  36. Bruce says:

    In Prosperity, one must pick a random card from the 10 chosen stacks to determine if the new treasure and victory cards will be used. Please add an indicator of which card was chosen first, or a “random sorting” option.

  37. Bruce says:

    After thinking about it a bit more, I find that an unsorted option has many uses. Let’s say I want to generate a deck which includes two specific cards. If you bring back the option of leaving the cards unsorted, I can take just the first eight results plus my two predetermined cards.

  38. Jesse says:

    First, I want to say thanks for creating this tool! I’d actually been thinking for several weeks about making my own php script and database for doing exactly this kind of pseudo-random game creation, and on a whim did a search and came across this site. The available options are good ones, and being able to select just specific expansions is very helpful.

    I apologize in advance for the following *very* long list of suggested extra options.. as I mentioned, I’ve been thinking about this for a while :P But that said, there are a number of extra ‘requirements’ (and a few small tweaks on the current ones) that I can think of that would help produce ‘good’ (this is an opinion) card combinations:

    1. Change the ‘If there is at least one Attack Card, require a Moat’ to:

    If there is at least one Attack Card, require a Reaction or Lighthouse card.

    2. Add a ‘If there are no Attack Cards, require no Reaction or Lighthouse cards’ option. – Reaction cards without Attack Cards in the game typically aren’t very useful.

    3. Add a ‘Require no more than one Reaction or Lighthouse card’ option. – Multiple Reaction cards are typically redundant.

    4. Add a ‘Require no more than one game-slowing Attack card’ option. – Some Attack cards (and combinations of Attack cards) dramatically slow the game down. In my experience, these ‘game-slowing’ Attacks include anything that trashes cards (e.g. Saboteur, Thief, Pirate Ship, etc.), reduces your hand size (guaranteed) (e.g. Militia, Ghost Ship, Torturer, etc.), or gives curses (e.g. Witch, Familiar, etc.). More than one of these in a game often makes for exceptionally-slow and un-enjoyable games. Other attack cards, however, have a very minimal effect on game speed, for example the Spy, Bureaucrat, Cutpurse, etc.

    5. Add a ‘Require no more than x Attack cards’ option. – I’m not quite sure what x should be.. perhaps 2 or 3? This one is similar to 4 above.. too many Attack cards slows the pace of the game down dramatically.

    6. Add a ‘Require at least one card of cost 2, 3, 4, and 5′ option. – This option is about giving viable gameplay choices regardless of how many coins you end up with for the turn.

    7. Add a ‘Require no more than x cards of the same cost’ option. – Again, I’m not quite sure what x should be.. but ending up with 5+ cost 5 cards often makes for a very unbalanced game, with few gameplay choices at key points in the game (e.g. early gameplay). Even 3 cost 2 cards in a game makes for a lot of redundant/useless cards, as well. Maybe make x variable based on the cost of the card (e.g. no more than 2 cost 2, no more than 2 cost 3, no more than 3 cost 4, etc.)?

  39. Jesse says:

    Just as a quick edit on #7 above, after some thinking on it, it seems like the following maximums would work well:

    Cost 2 coins – Max of 2 cards
    Cost 3 coins – Max of 3 cards
    Cost 4 coins – Max of 3 cards
    Cost 5 coins – Max of 4 cards
    Cost includes a potion – no Max
    Cost >5 coins – No max (Maybe Prosperity would change this?)

  40. Jesse says:

    One more thought after playing around with the randomizer a bit.. how are the ‘require’ options being enforced? I guess what I’m asking is if the randomizer first selects any ‘required’ cards, and then randomly selects the remaining cards, or if it first randomly generates most of the cards and then decides if it needs to pseudo-randomly add in a required card?

    The ‘require at least one card that allows you to trash other cards’ setting, for example, seems to very frequently produce a game with multiple trash-ability cards, rather than just one. Am I just seeing random chance, or is it picking that trash-ability card first, thus skewing the likelihood of multiple trash-ability cards? Ideally, the randomizer should draw out 9 cards at random, check to see if any of them meet the trash-ability criteria, and only pseudo-randomly add a trash-ability card if none of the first 9 meet the criteria.

  41. Jesse says:

    I had a little time this morning, so after thinking about it I put together a logic chart for how the current options and the above suggested ones could be combined, while still preserving as much as possible a true random draw (i.e. limit the effect of pseudo-random drawing cards on card type distribution). Most of the logic is in .php already. For easy reference, I numbered the (now) 10 options:

    1). Require at least 1 +buy card
    2). Require at least 1 +2 actions card
    3). Require at least 1 card that allows you to trash other cards
    4). If there are any Attacks, require a Reaction (or Lighthouse) card.
    5). If there are no Attacks, don’t allow any Reaction (or Lighthouse) cards.
    6). Require no more than 1 Reaction (or Lighthouse) cards.
    7). Require no more than 1 ‘game-slowing’ Attack card.
    8). Require no more than x (3?) Attack cards.
    9). Require at least one card of cost 2, cost 3, cost 4, and cost 5
    10). Require no more than 2 cards of cost 2, no more than 3 cards of cost 3, no more than 3 cards of cost 4, and no more than 4 cards of cost 5.

    Note: in the following logic, the statement ‘true_random_draw_a_card’ is not quite correct. This mysql statement includes a restriction based on options 6,7,8, and 10. If any of those max card limits have been reached, remove those card types from the true_random_draw_a_card query.

    $free_draw = 10;

    if (option 1) $free_draw–;
    if (option 2) $free_draw–;
    if (option 3) $free_draw–;
    if (option 4)
    $free_draw–;
    else if (option 5)
    $free_draw–;
    if (option 9) $free_draw -= 4;

    for ($free_draw)
    true_random_draw_a_card;

    if (option 9) && (option 9 requirements are NOT met)
    Draw a card of each cost not yet met
    $free_draw += 4;

    if (# of cards drawn < $free_draw)
    true_random_draw_a_card until we reach $free_draw total cards

    if (option 1) && (option 1 requirements are NOT met)
    Draw a card with +Buy on it
    $free_draw++;

    if (# of cards drawn < $free_draw)
    true_random_draw_a_card until we reach $free_draw total cards

    if (option 2) && (option 2 requirements are NOT met)
    Draw a card with +2 Actions on it
    $free_draw++;

    if (# of cards drawn < $free_draw)
    true_random_draw_a_card until we reach $free_draw total cards

    if (option 3) && (option 3 requirements are NOT met)
    Draw a card with trash-ability on it
    $free_draw++;

    if (# of cards drawn < $free_draw)
    true_random_draw_a_card until we reach $free_draw total cards

    if (! option 4) && (! option 5)
    true_random_draw to 10 cards <- should be done already.
    else
    {
    true_random_draw to 9 cards
    if (option 4) && (Attack card has been drawn) && (NO Reactions have been drawn)
    draw Reaction card
    else
    {
    if (option 5) && (NO Attacks have been drawn)
    {
    if (option 4)
    draw non-Reaction, non-Attack card
    else
    draw non-Reaction card
    }
    else true_random_draw_a_card;
    }
    }

    I'm not 100% sure on the very last part.. it will require a little testing to be sure it's drawing the last card correctly in all cases.

    It's still not quite as true-random as might be possible.. the more options of the 'at least x' type you select, the more likely you are to over-select for those types, but short of a veto-style method with lots of drawing a full set of cards and then putting some back, I don't see a better method for preserving distribution.

  42. Jesse says:

    huh.. wacky.. the text parser cleaned up my $free_draw decrement calls.. those should be minus-minus :P

  43. Jesse says:

    bleh the above logic needs some cleaning.. at each check for an option (for 9,1,2,3), if the option is selected and not yet met, it needs to draw from only the possible cards that meet the requirement. If the option is selected but already met, though, it needs to do a true_random_draw. That should fix it ;)

  44. Dree says:

    Hi Zack,

    All I’m missing is an option to language selection. It would make this site of universal statue and you would be immortalized.
    Others can translated it to their language. If I would deliver you a complete list of translated kingdom card names,it could make a kickoff.

  45. Zack says:

    All,

    I promise I’m reading and considering all your suggestions. It is a busy time for me now and so I do not know what I will have time to slap together, but be sure I am not ignoring you. :-)

    Dree, what languages would you need / could you supply? (I wouldn’t be able to change the images, of course).

  46. Dree says:

    I could provide you with Dutch for starters, and hope others will follow and provide you other translations.
    Its my language and i own the cards.
    German would also be easy I think.

  47. Michael says:

    Hi,

    Great application! If you were going to let users set parameters on the cost of cards, why not let them choose their own upper and lower limit? So, for example, someone might think that there should be between 2 and 4 cards that cost 4, while someone else might think there should be between 1 and 6 cards that cost 4.

Leave a Comment