Skip to content

Instantly share code, notes, and snippets.

@harold
Created November 4, 2011 20:48
Show Gist options
  • Save harold/1340446 to your computer and use it in GitHub Desktop.
Save harold/1340446 to your computer and use it in GitHub Desktop.
namespace MonsterBrain
type turnoption = Doms.TurnOption
type MonsterBrain() =
let calcCoeff (o:turnoption) =
let first = o.board.[0]
let last = o.board.[o.board.Count-1]
let mutable hasFirst = false
let mutable hasLast = false
for d in o.hand do
if first = d.l || first = d.r then hasFirst <- true
if last = d.l || last = d.r then hasLast <- true
if hasFirst && hasLast then 20 else 1
let scoreOption (o:turnoption) =
(o.played.l + o.played.r) * calcCoeff o
interface Doms.IPlayer with
member this.GetName() = "F# MonsterBrain"
member this.GetMove( inTurnOptions ) =
fst (Seq.maxBy (fun (d) -> scoreOption (snd d))
(Seq.mapi (fun i t -> (i, t)) inTurnOptions))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment