30-3

俯瞰図

解説動画

※回答のブロックIDは236→237、35→41が正しいです。v1.21では236→152、159→133になっています。

解答画像

※回答のブロックIDは236→237、35→41が正しいです。v1.21では236→152、159→133になっています。

解答コード

player.onChat("30-3", function () {
    red = 0
    blue = 0
    yellow = 0
    green = 0
    while (!(agent.detect(AgentDetection.Block, FORWARD))) {
        agent.move(FORWARD, 1)
        if (agent.inspect(AgentInspection.Block, RIGHT) == 237) {
            red += 1
        }
        if (agent.inspect(AgentInspection.Block, LEFT) == 237) {
            red += 1
        }
        if (agent.inspect(AgentInspection.Block, RIGHT) == 22) {
            blue += 1
        }
        if (agent.inspect(AgentInspection.Block, LEFT) == 22) {
            blue += 1
        }
        if (agent.inspect(AgentInspection.Block, RIGHT) == 41) {
            yellow += 1
        }
        if (agent.inspect(AgentInspection.Block, LEFT) == 41) {
            yellow += 1
        }
        if (agent.inspect(AgentInspection.Block, RIGHT) == 159) {
            green += 1
        }
        if (agent.inspect(AgentInspection.Block, RIGHT) == 159) {
            green += 1
        }
    }
    if (red > blue && blue > yellow && yellow > green) {
        agent.move(RIGHT, 1)
    } else {
        agent.move(LEFT, 1)
    }
})

※回答のブロックIDは236→237、35→41が正しいです。

教え方のポイント

それぞれのクエストの復習ステージ

  • 過去の動画を見て使えそうな考え方を探させてみるのもあり