9-7 村の自慢①

解説動画

解答コード

function pillar(height: number) {
    for (let i = 0; i < height; i++) {
        agent.place(FORWARD);
        agent.move(UP, 1);
    }
}

function wall2(height: number, width: number) {
    for (let j = 0; j < width; j++) {
        pillar(height);
        agent.move(DOWN, height);
        agent.move(RIGHT, 1);
    }
}

function stairs2(height: number, width: number, steps: number) {
    for (let k = 0; k < steps; k++) {
        wall2(height, width);
        agent.move(RIGHT, width);
        agent.move(BACK, 1);
        height -= 1;
    }
}

player.onChat("9-7", function (height, width, steps) {
    stairs2(height, width, steps);
});