Trying to find an easy solution for the "Round up the switches" level. I think the while-loop is bugged - I have no explanation for the problem...
var gemcount = 0
var switchcount = 0
func movement() {
moveForward()
if isBlocked && !isBlockedRight{
turnRight()
}
if isBlocked && !isBlockedLeft{
turnLeft()
}
}
func collect() {
if isOnGem {
collectGem()
gemcount = gemcount + 1}
}
func toggle() {
if isOnClosedSwitch && switchcount != gemcount {
toggleSwitch()
switchcount = switchcount + 1}
}
while switchcount < gemcount {
movement()
collect()
toggle()
}