Created
November 4, 2011 20:48
-
-
Save harold/1340446 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
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