Skip to content

Commit

Permalink
performance fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lefthandedgoat committed Sep 7, 2014
1 parent ee3d6ba commit 0deab59
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
22 changes: 12 additions & 10 deletions Dojo/Canopy2048/Interactions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@ open canopy
open runner

module Interactions =
let lostSelector = css ".game-message.game-over"
let winSelector = css ".game-message.game-won"
let gameOverSelector = css ".game-message.game-won, .game-message.game-over"

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

let won () =
match someElement <| css ".game-message.game-won" with

let won () =
match someElement <| winSelector with
| None -> false
| Some(_) -> true

let gameEnded =
let driver = lazy(Seq.head browsers)
let css = ".game-message.game-won, .game-message.game-over"
let selector = OpenQA.Selenium.By.CssSelector(css)
fun () ->
driver.Value.FindElements(selector).Count > 0
let gameEnded () =
match someElement <| gameOverSelector with
| None -> false
| Some(_) -> true

let state () =
elements ".tile"
Expand Down
6 changes: 3 additions & 3 deletions Dojo/Canopy2048/Program.fs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ open Interactions
module program =

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

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

Expand Down Expand Up @@ -157,8 +157,8 @@ module program =
| Up -> press up
| Right -> press right
| Down -> press down
if lost() || won()
//if gameEnded()
//if lost() || won()
if gameEnded()
then ignore()
else play (shuffle moves) (counter + 1)

Expand Down

0 comments on commit 0deab59

Please sign in to comment.