world.place(Stair(), facing: south, atColumn: 3, row: 3)
world.place(Stair(), facing: south, atColumn: 3, row: 1)
world.place(Stair(), facing: east, atColumn: 5, row: 6)
world.place(Stair(), facing: north, atColumn: 2, row: 7)
world.place(Stair(), facing: west, atColumn: 1, row: 4)
func turnAround() {
turnLeft()
turnLeft()
}
func move2TurnLeft() {
move(distance: 2)
turnLeft()
}
func toggleSwitches() {
toggleSwitch()
while !isBlocked {
moveForward()
toggleSwitch()
}
turnAround()
move2TurnLeft()
move2TurnLeft()
move(distance: 2)
}
func goToSwitch() {
move(distance: 2)
turnRight()
}
move(distance: 4)
turnLeft()
moveForward()
for i in 1 ... 3 {
goToSwitch()
toggleSwitches()
}
youtu.be