let totalGems = randomNumberOfGems
let a = Expert()
let b = Character()
var gem = 0
world.place(a, facing: north, atColumn: 1, row: 4)
world.place(b, facing: north, atColumn: 3, row: 0)
func jumpToEdge() {
for i in 1 ... 6 {
if b.isOnGem && gem < totalGems {
b.collectGem()
gem += 1
}
if b.isBlocked {
b.jump()
} else {
b.moveForward()
}
}
}
a.turnLock(up: true, numberOfTimes: 1)
while gem != totalGems {
jumpToEdge()
if b.isBlockedLeft && b.isBlockedRight {
b.turnLeft()
b.turnLeft()
} else if b.isBlockedLeft {
b.turnRight()
b.moveForward()
b.turnRight()
} else if b.isBlockedRight {
b.turnLeft()
b.moveForward()
b.turnLeft()
}
}