From 0eba82951bf0a2fa3a45131f130beefbe3575ada Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Thu, 11 Jan 2024 18:04:59 -0600 Subject: [PATCH] added follow, collect, attack commands --- src/agent/commands.js | 2 +- src/agent/commands/actions.js | 73 +++++++++++++---------------------- src/examples.json | 10 ++--- 3 files changed, 33 insertions(+), 52 deletions(-) diff --git a/src/agent/commands.js b/src/agent/commands.js index 88dcc7e..b7e6cf4 100644 --- a/src/agent/commands.js +++ b/src/agent/commands.js @@ -81,7 +81,7 @@ export async function executeCommand(agent, message) { export function getCommandDocs() { let docs = `\n*COMMAND DOCS\n You can use the following commands to perform actions and get information about the world. Use the commands with the syntax: !commandName or !commandName("arg1", 1.2, ...) if the command takes arguments.\n - Do not use codeblocks. Only use one command in each response, trailing commands will be ignored. Use these commands frequently in your responses!\n`; + Do not use codeblocks. Only use one command in each response, trailing commands and comments will be ignored. Use these commands frequently in your responses!\n`; for (let command of commandList) { docs += command.name + ': ' + command.description + '\n'; if (command.params) { diff --git a/src/agent/commands/actions.js b/src/agent/commands/actions.js index 98b3af2..e13c06a 100644 --- a/src/agent/commands/actions.js +++ b/src/agent/commands/actions.js @@ -40,50 +40,31 @@ export const actionsList = [ return await skills.goToPlayer(agent.bot, player_name); }) }, - // { - // name: '!followPlayer', - // description: 'Follow the nearest player.', - // perform: wrapExecution(async (agent, player_name) => { - // await skills.followPlayer(agent.bot, player_name); - // }) - // }, - // { - // name: '!collectwood', - // description: 'Collect 3 wood logs of any type.', - // perform: wrapExecution(async (agent) => { - // let blocks = world.getNearbyBlockTypes(agent.bot); - // for (let block of blocks) { - // if (block.includes('log')) { - // await skills.collectBlock(agent.bot, block, 3); - // return; - // } - // } - // return 'No wood nearby.'; - // }) - // }, - // { - // name: '!collectstone', - // description: 'Collect 3 cobblestone blocks.', - // perform: wrapExecution(async (agent) => { - // let inventory = world.getInventoryCounts(agent.bot); - // for (const item in inventory) { - // if (inventory[item] && inventory[item] > 0 && item.includes('pickaxe')) { - // if (await skills.equip(agent.bot, 'pickaxe')) - // await skills.collectBlock(agent.bot, 'stone', 3); - // return; - // } - // } - // return 'No pickaxe in inventory.'; - // }) - // }, - // { - // name: '!fightmob', - // description: 'Fight the nearest mob.', - // perform: wrapExecution(async (agent) => { - // let mobs = world.getNearbyMobTypes(agent.bot); - // if (mobs.length == 0) - // return 'No mobs nearby.'; - // await skills.attackMob(agent.bot, mobs[0], true); - // }) - // } + { + name: '!followPlayer', + description: 'Endlessly follow the nearest player. Ex: !followPlayer("stevie")', + params: {'player_name': '(string) The name of the player to follow.'}, + perform: wrapExecution(async (agent, player_name) => { + await skills.followPlayer(agent.bot, player_name); + }) + }, + { + name: '!collectBlocks', + description: 'Collect the nearest blocks of a given type.', + params: { + 'type': '(string) The block type to collect. Ex: !collectBlocks("stone", 10)', + 'num': '(number) The number of blocks to collect.' + }, + perform: wrapExecution(async (agent, type, num) => { + await skills.collectBlock(agent.bot, type, num); + }) + }, + { + name: '!attack', + description: 'Attack and kill the nearest entity of a given type.', + params: {'type': '(string) The type of entity to attack.'}, + perform: wrapExecution(async (agent, type) => { + await skills.attackMob(agent.bot, type, true); + }) + } ]; diff --git a/src/examples.json b/src/examples.json index df329e1..9950928 100644 --- a/src/examples.json +++ b/src/examples.json @@ -15,7 +15,7 @@ {"role": "user", "content": "greg: Collect 10 wood"}, {"role": "assistant", "content": "Let me see what's nearby... !blocks"}, {"role": "system", "content": "NEARBY_BLOCKS\n- oak_log\n- dirt\n- cobblestone"}, - {"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone. I'll collect oak logs. !newAction"} + {"role": "assistant", "content": "I see some oak logs, dirt, and cobblestone. I'll collect oak logs. !collectBlocks('oak_log', 10)"} ], [ @@ -27,7 +27,7 @@ [ {"role": "user", "content": "zZZn98: come here"}, - {"role": "assistant", "content": "!goToPlayer('sumixam0')"}, + {"role": "assistant", "content": "On my way! !goToPlayer('zZZn98')"}, {"role": "system", "content": "Code execution finished successfully."}, {"role": "assistant", "content": "Here!"} ], @@ -41,19 +41,19 @@ [ {"role": "user", "content": "joe: Follow me!"}, - {"role": "assistant", "content": "Sure! !newAction"} + {"role": "assistant", "content": "Sure! !followPlayer('joe')"} ], [ {"role": "user", "content": "hanky: kill that zombie!"}, - {"role": "assistant", "content": "I'm attacking! !newAction"}, + {"role": "assistant", "content": "I'm attacking! !attack('zombie')"}, {"role": "system", "content": "Code Output:\nNo zombie nearby"}, {"role": "assistant", "content": "I could not find a zombie nearby."} ], [ {"role": "user", "content": "billybob: stop"}, - {"role": "assistant", "content": "!newAction"} + {"role": "assistant", "content": "Sure. !stop"} ], [