greenPortal.isActive = false
func back() {
if isBlocked {
turnLeft()
turnLeft()
moveForward()
}
}
func xC() {
for i in 1 ... 4 {
turnLeft()
moveForward()
if isOnGem {
collectGem()
} else if isOnClosedSwitch {
toggleSwitch()
}
turnLeft()
turnLeft()
moveForward()
}
}
turnLeft()
moveForward()
moveForward()
xC()
moveForward()
greenPortal.isActive = true
back()
greenPortal.isActive = false
xC()
moveForward()
greenPortal.isActive = true
back()
turnRight()
orangePortal.isActive = false
moveForward()
moveForward()
moveForward()
xC()
moveForward()
orangePortal.isActive = true
back()
orangePortal.isActive = false
xC()