this worked for me. the else to handle the switches in this level isn't very reusable though
func navigateAroundWall() {
if !isBlocked {
moveForward()
} else if isBlockedRight && isBlocked {
turnLeft()
} else if isBlockedLeft && isBlocked {
turnRight()
}
}
while !isOnOpenSwitch {
navigateAroundWall()
if isOnGem || isOnClosedSwitch {
if isOnGem {
collectGem()
} else {
toggleSwitch()
turnLeft()
moveForward()
toggleSwitch()
moveForward()
}
}
}