       useRandomly = !RandUtil.getRandomInt(0, 3)
       return hasAlchemyCard or useRandomly
 
+   replaceSetIdInCardId = (cardId, setId) ->
+       return setId + '_' + cardId.split('_')[1]
+
 
    window.Randomizer = {
       createKingdom: createKingdom

      TREASURE_7: 'treasure7',
      TREASURE_8: 'treasure8'
   }

   NUM_CARDS_IN_KINGDOM = 10


            useShelters: shouldUseSpecialtyCardFromSet(DARK_AGES_SET_ID, setsToUse)
         }
      }

   removeDuplicateCards = (cards) ->
      # Removes duplicate cards; keep setA's version.
      for setA, setB of SetsWithDuplicates
         setACards = cards.filter(filterByIncludedSetIds([setA]))
         setBCardIds = (replaceSetIdInCardId(card.id, setB) for card in setACards)
         cards = cards.filter(filterByExcludedIds(setBCardIds))

      return cards

   adjustKingdomForAlchemyCards = (kingdom, cardsToUse, requiredCardIds, excludeCardIds) ->      
      alchemyCards = kingdom.cards.filter(filterByIncludedSetIds([ALCHEMY_SET_ID]))
