Last active
June 26, 2016 23:50
-
-
Save ChadSki/5d7241a17c00740840b8b4be17f6fcee to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rec TakeAction (gs:GameState) : bool = | |
// -snip- | |
// Not sure which card to choose, so let's try them all! | |
// `None` represents not imprinting a card. | |
// Stop if a possibility wins the game (`List.exists` will short-circuit). | |
None :: (gs.Hand |> Seq.distinct | |
|> Seq.map (fun card -> Some card) | |
|> Seq.toList) | |
|> List.exists (function | |
| None -> | |
log "Entering hypothetical: nothing was imprinted." | |
TakeAction gs | |
| Some imprint -> | |
let imprintColor = Color (Cost imprint) | |
log (sprintf "Entering hypothetical: imprinting %s for %s." | |
(CardLabel imprint) (ColorLabel imprintColor)) | |
let hypotheticalGameState = gs.Clone() | |
hypotheticalGameState.Hand <- RemoveOneCard gs.Hand imprint | |
hypotheticalGameState.Moxen <- (imprintColor, false) :: gs.Moxen | |
TakeAction hypotheticalGameState) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment