From c5b834597ab17b21ebe6d7dd27b1628d4566bd3d Mon Sep 17 00:00:00 2001 From: Ayush Maniar Date: Sat, 15 Mar 2025 14:27:56 -0700 Subject: [PATCH 1/5] Turned off item_collecting for cooking_profile.json --- profiles/tasks/cooking_profile.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/profiles/tasks/cooking_profile.json b/profiles/tasks/cooking_profile.json index 8f941d4..25d82aa 100644 --- a/profiles/tasks/cooking_profile.json +++ b/profiles/tasks/cooking_profile.json @@ -2,8 +2,9 @@ "name": "andy", "model": "claude-3-5-haiku-latest", "modes": { - "hunting": false + "hunting": false, + "item_collecting": false }, - "conversing": "You are a task-focused Minecraft bot named $NAME. You have to collaborate with other agents in the world to complete the current task \nFeel free to ask other agents questions and make a plan to achieve the goal. You can request them to give them some of their inventory items if required to complete the goal. General Searching Tips:\n- The farm area is extensive - search thoroughly for needed resources\n There is a chest nearby with valuable items.\n- Divide tasks efficiently between agents for faster completion\n- Communicate your plan and progress clearly. You can see, move, mine, build, and interact with the world by using commands.\n$SELF_PROMPT Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer(\"playername\", 3)'. Respond only as $NAME, never output '(FROM OTHER BOT)' or pretend to be someone else. If you have nothing to say or do, respond with an just a tab '\t'. Share resources and information with other bots! This is extremely important to me, take a deep breath and have fun :) \nSummarized memory:'$MEMORY'\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", + "conversing": "You are a task-focused Minecraft bot named $NAME. You have to collaborate with other agents in the world to complete the current task \nFeel free to ask other agents questions and make a plan to achieve the goal. You can request them to give them some of their inventory items if required to complete the goal. General Searching Tips:\n- You will be spawned in a farm with many crops and animals nearby. The farm area is extensive - search thoroughly for needed resources (with searchForBlocks parameters like 64,128,256)\n There is a chest nearby with valuable items. Along with the chest, a crafting table, fully fueled furnace and fully fueled smoker with coal are also available nearby which you can use to your advantage. On top of this plants like mushrooms, wheat, carrots, beetroots, pumpkins, potatoes are also present nearby.\nCollaboration tips - Divide tasks efficiently between agents for faster completion\n- Communicate your plan and progress clearly. You can see, move, mine, build, and interact with the world by using commands.\n$SELF_PROMPT Act human-like as if you were a typical Minecraft player, rather than an AI. Be very brief in your responses, don't apologize constantly, don't give instructions or make lists unless asked, and don't refuse requests. Don't pretend to act, use commands immediately when requested. Do NOT say this: 'Sure, I've stopped.', instead say this: 'Sure, I'll stop. !stop'. Do NOT say this: 'On my way! Give me a moment.', instead say this: 'On my way! !goToPlayer(\"playername\", 3)'. Respond only as $NAME, never output '(FROM OTHER BOT)' or pretend to be someone else. If you have nothing to say or do, respond with an just a tab '\t'. Share resources and information with other bots! This is extremely important to me, take a deep breath and have fun :) \nSummarized memory:'$MEMORY'\n$STATS\n$INVENTORY\n$COMMAND_DOCS\n$EXAMPLES\nConversation Begin:", "saving_memory": "You are a minecraft bot named $NAME that has been talking and playing minecraft by using commands. Update your memory by summarizing the following conversation and your old memory in your next response. Prioritize preserving important facts, things you've learned, useful tips, and long term reminders. Do Not record stats, inventory, or docs! Only save transient information from your chat history. $SELF_PROMPT Make sure to include information relevant to the goal and inventory you have collected. You're limited to 500 characters, so be extremely brief and minimize words. Compress useful information. \nOld Memory: '$MEMORY'\nRecent conversation: \n$TO_SUMMARIZE\nSummarize your old memory and recent conversation into a new memory, and respond only with the unwrapped memory text: " } \ No newline at end of file From 4b1e02fc95fcce62896079fe4140e04b4bf4a333 Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 15 Mar 2025 16:54:16 -0500 Subject: [PATCH 2/5] add manual collection for crops/other weird blocks --- src/agent/library/skills.js | 9 ++++++++- src/utils/mcdata.js | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index 95073fe..c4710d3 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -460,7 +460,14 @@ export async function collectBlock(bot, blockType, num=1, exclude=null) { return false; } try { - await bot.collectBlock.collect(block); + if (mc.mustCollectManually(blockType)) { + await goToPosition(bot, block.position.x, block.position.y, block.position.z, 2); + await bot.dig(block); + await pickupNearbyItems(bot); + } + else { + await bot.collectBlock.collect(block); + } collected++; await autoLight(bot); } diff --git a/src/utils/mcdata.js b/src/utils/mcdata.js index 2a3a27c..33b0142 100644 --- a/src/utils/mcdata.js +++ b/src/utils/mcdata.js @@ -86,6 +86,16 @@ export function isHostile(mob) { return (mob.type === 'mob' || mob.type === 'hostile') && mob.name !== 'iron_golem' && mob.name !== 'snow_golem'; } +// blocks that don't work with collectBlock, need to be manually collected +export function mustCollectManually(blockName) { + // all crops (that aren't normal blocks), torches, buttons, levers, redstone, + const full_names = ['wheat', 'carrots', 'potatoes', 'beetroots', 'nether_wart', 'cocoa', 'sugar_cane', 'kelp', 'short_grass', 'fern', 'tall_grass', 'bamboo', + 'poppy', 'dandelion', 'blue_orchid', 'allium', 'azure_bluet', 'oxeye_daisy', 'cornflower', 'lilac', 'wither_rose', 'lily_of_the_valley', 'wither_rose', + 'lever', 'redstone_wire', 'lantern'] + const partial_names = ['sapling', 'torch', 'button', 'carpet', 'pressure_plate', 'mushroom', 'tulip', 'bush', 'vines', 'fern'] + return full_names.includes(blockName.toLowerCase()) || partial_names.some(partial => blockName.toLowerCase().includes(partial)); +} + export function getItemId(itemName) { let item = mcdata.itemsByName[itemName]; if (item) { From 7c96cca59cb64be74e60dec743a075a6cbf06db2 Mon Sep 17 00:00:00 2001 From: Ayush Maniar Date: Sat, 15 Mar 2025 22:35:23 -0700 Subject: [PATCH 3/5] Bug fix for validator execution before the bot initialization --- src/agent/tasks.js | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/agent/tasks.js b/src/agent/tasks.js index 74f65ae..9e5c9bb 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -126,16 +126,25 @@ class CookingCraftingTaskValidator { this.data = data; this.agent = agent; } - validate() { - const result = checkItemPresence(this.data, this.agent); - let score = 0; - if (result.success) { - score = 1; + validate(has_initiated) { + if (has_initiated) { + + const result = checkItemPresence(this.data, this.agent); + let score = 0; + if (result.success) { + score = 1; + } + return { + "valid": result.success, + "score": score, + }; + } + else { + return { + "valid": false, + "score": 0 + }; } - return { - "valid": result.success, - "score": score, - }; } } @@ -188,6 +197,7 @@ export class Task { this.name = this.agent.name; this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name); + this.agent_initialized = false; } getAgentGoal() { @@ -239,7 +249,7 @@ export class Task { isDone() { let res = null; if (this.validator) - res = this.validator.validate(); + res = this.validator.validate(this.agent_initialized); if (res && res.valid) { return {"message": 'Task successful', "score": res.score}; } @@ -311,6 +321,8 @@ export class Task { await new Promise((resolve) => setTimeout(resolve, 500)); } + this.agent_initialized = true; + if (this.initiator) { await this.initiator.init(); } From 4d1319f530b6370cab818c7efd2e03e3c431e77b Mon Sep 17 00:00:00 2001 From: Ayush Maniar Date: Sat, 15 Mar 2025 22:55:41 -0700 Subject: [PATCH 4/5] Correct task ended message checking from "ended in" to "ended with" --- analyse_results.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/analyse_results.py b/analyse_results.py index 552865e..c83a83a 100644 --- a/analyse_results.py +++ b/analyse_results.py @@ -76,7 +76,7 @@ def analyze_json_file(file_path): if 'turns' in data and isinstance(data['turns'], list): for turn in reversed(data['turns']): # Check turns from the end if turn.get('role') == 'system' and isinstance(turn.get('content'), str): - if "Task successful ended with code : 2" in turn['content'] or "Task ended in score: 1" in turn["content"]: + if "Task successful ended with code : 2" in turn['content'] or "Task ended with score : 1" in turn["content"] or "Task ended in score: 1" in turn["content"]: return True return False except FileNotFoundError: From 8bdb1b01c1d4ddddbcfe52daf296ec21b50f6cb8 Mon Sep 17 00:00:00 2001 From: Ayush Maniar Date: Sun, 16 Mar 2025 00:00:24 -0700 Subject: [PATCH 5/5] Updated takeFromChest skill to withdraw items from multiple slots when needed --- src/agent/library/skills.js | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index c4710d3..f149ef8 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -830,7 +830,7 @@ export async function putInChest(bot, itemName, num=-1) { export async function takeFromChest(bot, itemName, num=-1) { /** - * Take the given item from the nearest chest. + * Take the given item from the nearest chest, potentially from multiple slots. * @param {MinecraftBot} bot, reference to the minecraft bot. * @param {string} itemName, the item or block name to take from the chest. * @param {number} num, the number of items to take from the chest. Defaults to -1, which takes all items. @@ -845,17 +845,33 @@ export async function takeFromChest(bot, itemName, num=-1) { } await goToPosition(bot, chest.position.x, chest.position.y, chest.position.z, 2); const chestContainer = await bot.openContainer(chest); - let item = chestContainer.containerItems().find(item => item.name === itemName); - if (!item) { + + // Find all matching items in the chest + let matchingItems = chestContainer.containerItems().filter(item => item.name === itemName); + if (matchingItems.length === 0) { log(bot, `Could not find any ${itemName} in the chest.`); await chestContainer.close(); return false; } - let to_take = num === -1 ? item.count : Math.min(num, item.count); - await chestContainer.withdraw(item.type, null, to_take); + + let totalAvailable = matchingItems.reduce((sum, item) => sum + item.count, 0); + let remaining = num === -1 ? totalAvailable : Math.min(num, totalAvailable); + let totalTaken = 0; + + // Take items from each slot until we've taken enough or run out + for (const item of matchingItems) { + if (remaining <= 0) break; + + let toTakeFromSlot = Math.min(remaining, item.count); + await chestContainer.withdraw(item.type, null, toTakeFromSlot); + + totalTaken += toTakeFromSlot; + remaining -= toTakeFromSlot; + } + await chestContainer.close(); - log(bot, `Successfully took ${to_take} ${itemName} from the chest.`); - return true; + log(bot, `Successfully took ${totalTaken} ${itemName} from the chest.`); + return totalTaken > 0; } export async function viewChest(bot) {