Last active
October 23, 2016 17:12
-
-
Save imbradmiller/eb70ad73b5984e1f03d278a2c83a9e19 to your computer and use it in GitHub Desktop.
It takes two counting steps
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
let expert = Expert() | |
let character = Character() | |
var gemCon = 0 | |
var switchCon = 0 | |
var steps = 0 | |
func lockSmith() { | |
if steps == 5 { | |
expert.turnRight() | |
expert.turnLockUp() | |
expert.turnLeft() | |
} | |
if steps == 15 { | |
expert.turnRight() | |
expert.turnLockDown() | |
expert.turnLockDown() | |
} | |
} | |
func expertSteps() { | |
if expert.isBlocked && !expert.isBlockedRight { | |
expert.turnRight() | |
} else if !expert.isBlockedLeft { | |
expert.turnLeft() | |
} | |
if !expert.isBlocked { | |
expert.moveForward() | |
steps += 1 | |
} | |
lockSmith() | |
} | |
func characterNav() { | |
character.moveForward() | |
character.moveForward() | |
if character.isOnGem { | |
character.collectGem() | |
gemCon += 1 | |
character.moveForward() | |
character.moveForward() | |
} | |
if character.isOnClosedSwitch { | |
character.toggleSwitch() | |
switchCon += 1 | |
} | |
} | |
while gemCon < 1 && switchCon < 1 { | |
expertSteps() | |
if steps == 15 { | |
characterNav() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment