Skip to content

Commit

Permalink
Performance updates
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Sep 1, 2014
1 parent 01ba69a commit ee3d6ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Dojo/Canopy2048/Interactions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ open runner
module Interactions =

let lost () =
match someElement ".game-message.game-over" with
match someElement <| css ".game-message.game-over" with
| None -> false
| Some(_) -> true

let won () =
match someElement ".game-message.game-won" with
match someElement <| css ".game-message.game-won" with
| None -> false
| Some(_) -> true

Expand Down
12 changes: 9 additions & 3 deletions Dojo/Canopy2048/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ open Interactions

module program =

configuration.optimizeBySkippingIFrameCheck <- true
configuration.optmizeByDisablingCoverageReport <- true

"starting a game of 2048" &&& fun _ ->

printfn "Game started."
Expand Down Expand Up @@ -143,8 +146,11 @@ module program =
move, float(score1)+score2*0.5 )
scores |> List.maxBy snd

let rec play moves =
let sw = System.Diagnostics.Stopwatch.StartNew()
let rec play moves counter =
let move = getBestMove 3 (state()) moves

printfn "%i moves in %f ms" counter sw.Elapsed.TotalMilliseconds
printfn "%A" move
match fst move with
| Left -> press left
Expand All @@ -154,9 +160,9 @@ module program =
if lost() || won()
//if gameEnded()
then ignore()
else play (shuffle moves)
else play (shuffle moves) (counter + 1)

play [Up; Right; Left; Down]
play [Up; Right; Left; Down] 0


// Just to make sure the test function
Expand Down

0 comments on commit ee3d6ba

Please sign in to comment.