Created
October 22, 2016 17:33
-
-
Save imbradmiller/e47115c8ae153ae6557cf2477d4719a6 to your computer and use it in GitHub Desktop.
Train Your Expert
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() | |
var gemCon = 0 | |
var steps = 0 | |
func blocked() { | |
if !expert.isBlockedRight { | |
expert.turnRight() | |
} else if expert.isBlocked { | |
expert.turnLeft() | |
expert.turnLeft() | |
} | |
} | |
func gemCollector() { | |
if expert.isOnGem { | |
expert.collectGem() | |
gemCon += 1 | |
} | |
} | |
func stepCounter(){ | |
steps += 1 | |
} | |
while gemCon != 6 { | |
stepCounter() | |
expert.moveForward() | |
gemCollector() | |
if steps == 10 { | |
expert.turnLockDown() | |
} | |
blocked() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment