解説動画
解答コード
function floor(depth: number, width: number) {
for (let i = 0; i < width; i++) {
for (let j = 0; j < depth; j++) {
agent.move(FORWARD, 1);
agent.place(DOWN);
}
agent.move(BACK, depth);
agent.move(LEFT, 1);
}
}
function roof(depth: number, width: number, steps: number) {
agent.move(UP, 1);
for (let k = 0; k < steps; k++) {
floor(depth, width);
agent.move(UP, 1);
agent.move(RIGHT, width - 1);
agent.move(FORWARD, 1);
depth -= 2;
width -= 2;
}
}
player.onChat("9-8", function (depth, width, steps) {
roof(depth, width, steps);
});