双峰

let expert = Character()

world.place(expert, facing: .north, atColumn: 4, row: 0)

let ein = Expert()

world.place(ein, facing: .north, atColumn: 0, row: 4)

var 数据 = 0

for i in 1 ... 3 {

    ein.turnLockUp()

}

func 判断() {

    if totalGems > 数据 {

        if expert.isOnGem {

            expert.collectGem()

            数据 += 1

        }

    }

   

   

    }

func QQ() {

    for i in 1 ... 6 {

        判断()

        if expert.isBlocked {

            expert.jump()

        } else if expert.isBlocked {

            expert.moveForward()

        }

    }

}

func 直走() {

    for i in 1 ... 6 {

        判断()

        if expert.isBlocked {

            expert.jump()

        } else  {

            expert.moveForward()

        }

    }

}

func 左前() {

    判断()

    expert.turnLeft()

    expert.moveForward()

    expert.turnLeft()

}

func 右前() {

    判断()

    expert.turnRight()

    expert.moveForward()

    expert.turnRight()

}

func 回头() {

    判断()

    for i in 1 ... 2 {

        expert.turnRight()

    }

}

while totalGems !=    数据 {

   

    QQ()

    左前()

    直走()

    右前()

    QQ()

    回头()

    QQ()

    左前()

    直走()

    右前()

    QQ()

    回头()

   

}

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容