Skip to content

Instantly share code, notes, and snippets.

@mlms13
Created February 8, 2018 21:24
Show Gist options
  • Save mlms13/3107c725681af1b319a760b04bae1c44 to your computer and use it in GitHub Desktop.
Save mlms13/3107c725681af1b319a760b04bae1c44 to your computer and use it in GitHub Desktop.
Function to optimize tapping lands in MTG based on other cards you might want to cast
data ManaSymbol
= Generic
| Specific SpecificMana
| Split ManaColor ManaColor
data SpecificMana = Colorless | Colored ManaColor
data ManaColor = W | U | R | B | G
newtype Land = Land (List SpecificMana)
newtype Card = Card (List ManaSymbol)
newtype Hand = Hand (List Card)
-- Given the following:
-- - a `Card` to be cast
-- - a `Hand` of other cards that are available
-- - a `List` of `Land` cards that you are able to tap
-- Return a `List` of `Land` cards to be tapped in order to produce the needed
-- mana to to cast the `Card` or `Nil` if the card can't be cast. Optimize the
-- mana-tapping so that the greatest number of other cards in hand can be cast.
bestLandTap :: Card -> Hand -> List Land -> List Land
bestLandTap (Card cardSymbols) (Hand otherCards) lands =
-- So, clearly this doesn't do anything. I'm also realizing that lands with
-- activated abilities (e.g. manlands) should be treated specially. Also,
-- this function should know about available mana from non-land sources.
Nil -- TODO!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment