Skip to content

Instantly share code, notes, and snippets.

@ChadSki
Last active June 26, 2016 23:50
Show Gist options
  • Save ChadSki/5d7241a17c00740840b8b4be17f6fcee to your computer and use it in GitHub Desktop.
Save ChadSki/5d7241a17c00740840b8b4be17f6fcee to your computer and use it in GitHub Desktop.
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