let expert = Character()
world.place(expert, facing: .north, atColumn: 4, row: 0)
let ein = Expert()
world.place(ein, facing: .north, atColumn: 0, row: 4)
var 数据 = 0
for i in 1 ... 3 {
ein.turnLockUp()
}
func 判断() {
if totalGems > 数据 {
if expert.isOnGem {
expert.collectGem()
数据 += 1
}
}
}
func QQ() {
for i in 1 ... 6 {
判断()
if expert.isBlocked {
expert.jump()
} else if expert.isBlocked {
expert.moveForward()
}
}
}
func 直走() {
for i in 1 ... 6 {
判断()
if expert.isBlocked {
expert.jump()
} else {
expert.moveForward()
}
}
}
func 左前() {
判断()
expert.turnLeft()
expert.moveForward()
expert.turnLeft()
}
func 右前() {
判断()
expert.turnRight()
expert.moveForward()
expert.turnRight()
}
func 回头() {
判断()
for i in 1 ... 2 {
expert.turnRight()
}
}
while totalGems != 数据 {
QQ()
左前()
直走()
右前()
QQ()
回头()
QQ()
左前()
直走()
右前()
QQ()
回头()
}