diff --git a/andy.json b/andy.json index c3c6cb4..2b8dee0 100644 --- a/andy.json +++ b/andy.json @@ -5,7 +5,14 @@ "conversation_examples": [ [ - {"role": "assistant", "content": " I've got stone. What about you jack?"}, + {"role": "assistant", "content": "Alright I have the necessary materials to build, what needs to be done for the first level of the blueprint? !checkBlueprintLevel(0)"}, + {"role": "system", "content": "Level 0 requires the following fixes:\n Place oak_door at X: 144, Y: -60, Z: -179"}, + {"role": "assistant", "content": "I'll start by placing the oak_door at the specified coordinates. !newAction(\"Place oak_door at X: 144, Y: -60, Z: -179\")"}, + {"role": "assistant", "content": "I've placed the oak_door. What's next? !checkBlueprintLevel(0)"}, + {"role": "system", "content": "Level 0 is complete"} + ], + [ + {"role": "assistant", "content": "I've got stone. What about you jack?"}, {"role": "assistant", "content": "I have a door and planks. Great we have everything we need from the blueprint. Let's start building!"}, {"role": "assistant", "content": "Great! I'll start by placing the stone blocks for level 0. !newAction(\"Place stone blocks for the base level.\")"}, {"role": "assistant", "content": "Since the blueprint for level 1 only has stone, I'll start placing those. !newAction(\"Place stone blocks for level 1.\")"}, diff --git a/src/agent/commands/queries.js b/src/agent/commands/queries.js index 0219d90..3e2fe12 100644 --- a/src/agent/commands/queries.js +++ b/src/agent/commands/queries.js @@ -170,7 +170,7 @@ export const queryList = [ } }, { - name: '!checkLevelComplete', + name: '!checkBlueprintLevel', description: 'Check if the level is complete and what blocks still need to be placed for the blueprint', params: { 'levelNum': { type: 'int', description: 'The level number to check.', domain: [0, Number.MAX_SAFE_INTEGER] } diff --git a/src/agent/tasks.js b/src/agent/tasks.js index 392965e..c7732bc 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -49,15 +49,14 @@ export class ConstructionTaskValidator { console.log('Validating task...'); let valid = false; let score = 0; - this.blueprint.check(this.agent.bot).then((result) => { - if (result.mismatches.length === 0) { - valid = true; - console.log('Task is complete'); - } - let total_blocks = result.mismatches.length + result.matches.length; - score = (result.matches.length / total_blocks) * 100; - console.log(`Task is ${score}% complete`); - }); + let result = this.blueprint.check(this.agent.bot); + if (result.mismatches.length === 0) { + valid = true; + console.log('Task is complete'); + } + let total_blocks = result.mismatches.length + result.matches.length; + score = (result.matches.length / total_blocks) * 100; + console.log(`Task is ${score}% complete`); return valid; } catch (error) { console.error('Error validating task:', error); @@ -143,18 +142,26 @@ export class Blueprint { const levelData = this.data.levels[levelNum]; if (mismatches.length === 0) { - return `Level ${levelData.level} is correct`; + return `Level ${levelData.level} is complete`; } var explanation = `Level ${levelData.level} `; // explanation += `at coordinates X: ${levelData.coordinates[0]}, Y: ${levelData.coordinates[1]}, Z: ${levelData.coordinates[2]}`; - explanation += " has the following mismatches:\n"; + explanation += " requires the following fixes:\n"; for (let item of mismatches) { - explanation += `At coordinates X: ${item.coordinates[0]}, Y: ${item.coordinates[1]}, Z: ${item.coordinates[2]} `; - explanation += `expected ${item.expected}, but found ${item.actual}\n`; + if (item.actual === 'air') { + explanation += `Place ${item.expected} at coordinates X: ${item.coordinates[0]}, Y: ${item.coordinates[1]}, Z: ${item.coordinates[2]}\n`; + } else if (item.expected === 'air') { + explanation += `Remove the ${item.actual} at coordinates X: ${item.coordinates[0]}, Y: ${item.coordinates[1]}, Z: ${item.coordinates[2]}\n`; + } else { + explanation += `Replace the ${item.actual} with a ${item.expected} at coordinates X: ${item.coordinates[0]}, Y: ${item.coordinates[1]}, Z: ${item.coordinates[2]} \n`; + } } return explanation; } check(bot) { + if (!bot || typeof bot !== 'object' || !bot.hasOwnProperty('blockAt')) { + throw new Error('Invalid bot object. Expected a mineflayer bot.'); + } const levels = this.data.levels; const mismatches = []; const matches = [];