In this project, one helpful thing I noticed was that all of the gems and portals were in the same pattern. What I did was make a function and a for loop to match this pattern:
func gem() {
for i in 1 … 2 {
moveForward()
collectGem()
}
turnLeft()
turnLeft()
moveForward()
turnRight()
moveForward()
collectGem()
turnLeft()
turnLeft()
moveForward()
moveForward()
collectGem()
}
for i in 1 … 4 {
gem()
moveForward()
}