解説動画
解答コード
let pattern148 = [[[0]]];
function inspectStatue148() {
pattern148 = []; // パターン全体を格納するための空の配列を初期化
for (let k = 0; k < 3; k++) {
let patternLine01 = []; // 1次元配列を初期化
for (let x = 0; x < 4; x++) {
let patternLine02 = []; // 1次元配列を初期化
for (let y = 0; y < 3; y++) {
const blockType = agent.inspect(AgentInspection.Block, DOWN);
patternLine02.push(blockType); // ブロックタイプをpatternLine02に追加
agent.move(LEFT, 1);
}
patternLine01.push(patternLine02); // patternLine02をpatternLine01に追加
agent.move(RIGHT, 3);
agent.move(FORWARD, 1);
}
pattern148.push(patternLine01); // patternLine01をpatternに追加
if (k == 0) {
agent.move(FORWARD, 1);
} else if (k == 1 || k == 2) {
agent.move(BACK, 4);
agent.move(RIGHT, 5);
}
}
}
function cloneStatue148() {
pattern148.forEach(function (element) {
element.forEach(function (block) {
block.forEach(function (item) {
if (item !== AIR) { // ブロックが空気でないかチェック
agent.setItem(item, 1, 1);
agent.place(DOWN);
}
agent.move(LEFT, 1);
});
agent.move(RIGHT, block.length);
agent.move(FORWARD, 1);
});
agent.move(BACK, element.length);
agent.move(UP, 1);
});
}
player.onChat("14-8", function() {
agent.move(UP, 1);
agent.move(FORWARD, 1);
inspectStatue148();
cloneStatue148();
});