diff --git a/src/agent/construction_tasks.js b/src/agent/construction_tasks.js index 9c2cfa4..245f587 100644 --- a/src/agent/construction_tasks.js +++ b/src/agent/construction_tasks.js @@ -8,7 +8,6 @@ export class ConstructionTaskValidator { validate() { try { //todo: somehow make this more of a percentage or something - //todo: change air validation console.log('Validating task...'); let valid = false; let score = 0; @@ -71,12 +70,14 @@ export class Blueprint { } explain() { var explanation = ""; + + // todo: we need to limit this to be a certain amount of levels to not overload memory... for (let item of this.data.levels) { var coordinates = item.coordinates; explanation += `Level ${item.level}: `; explanation += `Start at coordinates X: ${coordinates[0]}, Y: ${coordinates[1]}, Z: ${coordinates[2]}`; - let placement_string = this._getPlacementString(item.placement); - explanation += `\n${placement_string}\n`; + // let placement_string = this._getPlacementString(item.placement); + // explanation += `\n${placement_string}\n`; } return explanation; } @@ -165,22 +166,29 @@ export class Blueprint { const x = startCoords[0] + xOffset; const y = startCoords[1]; const z = startCoords[2] + zOffset; - + try { const blockAtLocation = bot.blockAt(new Vec3(x, y, z)); - if (!blockAtLocation || blockAtLocation.name !== blockName) { + const actualBlockName = blockAtLocation ? bot.registry.blocks[blockAtLocation.type].name : "air"; + + // Skip if both expected and actual block are "air" + if (blockName === "air" && actualBlockName === "air") { + continue; + } + + if (actualBlockName !== blockName) { mismatches.push({ level: levelData.level, coordinates: [x, y, z], expected: blockName, - actual: blockAtLocation ? bot.registry.blocks[blockAtLocation.type].name : 'air' // Assuming air if no block + actual: actualBlockName }); } else { matches.push({ level: levelData.level, coordinates: [x, y, z], expected: blockName, - actual: blockAtLocation ? bot.registry.blocks[blockAtLocation.type].name : 'air' // Assuming air if no block + actual: actualBlockName }); } } catch (err) { @@ -292,7 +300,7 @@ export class Blueprint { }; return { commands, nearbyPosition }; - } + } } diff --git a/src/agent/tasks.js b/src/agent/tasks.js index 136b438..b9e3b7d 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -4,6 +4,7 @@ import { getPosition } from './library/world.js' import settings from '../../settings.js'; import { Vec3 } from 'vec3'; import { ConstructionTaskValidator, Blueprint } from './construction_tasks.js'; +import {autoBuild, autoDelete} from "../../test/test_blueprint_layout.js"; //todo: modify validator code to return an object with valid and score -> do more testing hahah //todo: figure out how to log these things to the same place as bots/histories @@ -185,6 +186,7 @@ export class Task { then set a random block to dirt and teleport the bot to stand on that block for starting the construction, This was done by MaxRobinson in one of the youtube videos. */ + if (this.data.type !== 'construction') { const pos = getPosition(bot); @@ -212,6 +214,23 @@ export class Task { let other_name = available_agents.filter(n => n !== name)[0]; await executeCommand(this.agent, `!startConversation("${other_name}", "${this.conversation}")`); } + + + if (this.data.type === 'construction'){ + //Ensures construction is cleaned out first. -> relies on cheats which are turned off? + if (this.blueprint){ + const result = this.blueprint.autoDelete(); + // const result = clearHouse(blueprint) + const commands = result.commands; + const nearbyPosition = result.nearbyPosition; + for (const command of commands) { + bot.chat(command); + } + } + else{ + console.log('no construction blueprint?') + } + } } } diff --git a/test/construction_tasks/generate_multiagent_construction_tasks.js b/test/construction_tasks/generate_multiagent_construction_tasks.js index d0f20dc..dc10243 100644 --- a/test/construction_tasks/generate_multiagent_construction_tasks.js +++ b/test/construction_tasks/generate_multiagent_construction_tasks.js @@ -55,6 +55,7 @@ function generateConstructionTasks() { const roomCounts = [4, 6, 8]; const windowStyles = [0, 1, 2]; const carpetStyles = [0, 1, 2]; + const timeout = 600 // 10 min base? for (let m = 0; m < materialLevels; m++) { for (let r = 0; r < roomCounts.length; r++) { @@ -86,8 +87,10 @@ function generateConstructionTasks() { goal: "Make a house with the blueprint", conversation: "Let's share materials and make a house with the blueprint", agent_count: 2, - blueprint: blueprint, - initial_inventory: createInitialInventory(blueprint, 2) + initial_inventory: createInitialInventory(blueprint, 2), + timeout: timeout+(300*r), // 5 minute per additional level of complexity + blueprint: blueprint, //todo: make a pointer? + }; } }