From fed2696f0696794342f1bc394a1aae9c9d70e044 Mon Sep 17 00:00:00 2001 From: Kolby Nottingham Date: Tue, 30 Apr 2024 13:31:51 -0700 Subject: [PATCH 1/7] model name fix --- src/agent/prompter.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/prompter.js b/src/agent/prompter.js index 67a96ac..b895727 100644 --- a/src/agent/prompter.js +++ b/src/agent/prompter.js @@ -164,7 +164,7 @@ export class Prompter { user_message = await this.replaceStrings(user_message, messages, null, null, null, last_goals); let user_messages = [{role: 'user', content: user_message}]; - let res = await this.model.sendRequest(user_messages, system_message); + let res = await this.chat_model.sendRequest(user_messages, system_message); let goal = null; try { @@ -180,4 +180,4 @@ export class Prompter { goal.quantity = parseInt(goal.quantity); return goal; } -} \ No newline at end of file +} From 51f401e62d570dd67a00f4cfa1978f3294ca88cf Mon Sep 17 00:00:00 2001 From: Kolby Nottingham Date: Wed, 1 May 2024 12:19:42 -0700 Subject: [PATCH 2/7] mode fixes --- src/agent/modes.js | 15 +++++++++------ src/utils/mcdata.js | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/agent/modes.js b/src/agent/modes.js index 0081682..56ecbf3 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -70,7 +70,7 @@ const modes = [ on: true, active: false, update: async function (agent) { - const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 16); + const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 8); if (enemy && await world.isClearPath(agent.bot, enemy)) { agent.bot.chat(`Aaa! A ${enemy.name}!`); execute(this, agent, async () => { @@ -86,11 +86,11 @@ const modes = [ on: true, active: false, update: async function (agent) { - const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 9); + const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 8); if (enemy && await world.isClearPath(agent.bot, enemy)) { agent.bot.chat(`Fighting ${enemy.name}!`); execute(this, agent, async () => { - await skills.defendSelf(agent.bot, 9); + await skills.defendSelf(agent.bot, 8); }); } } @@ -155,9 +155,12 @@ const modes = [ if (torches.length > 0) { const torch = torches[0]; const pos = agent.bot.entity.position; - execute(this, agent, async () => { - await skills.placeBlock(agent.bot, torch.name, pos.x, pos.y, pos.z); - }); + const curr_block = agent.bot.blockAt(pos); + if (curr_block.name === 'air') { + execute(this, agent, async () => { + await skills.placeBlock(agent.bot, torch.name, pos.x, pos.y, pos.z); + }); + } } } } diff --git a/src/utils/mcdata.js b/src/utils/mcdata.js index eeeb957..384a211 100644 --- a/src/utils/mcdata.js +++ b/src/utils/mcdata.js @@ -68,7 +68,7 @@ export function initBot(username) { export function isHuntable(mob) { if (!mob || !mob.name) return false; - const animals = ['chicken', 'cod', 'cow', 'llama', 'mooshroom', 'pig', 'pufferfish', 'rabbit', 'salmon', 'sheep', 'squid', 'tropical_fish', 'turtle']; + const animals = ['chicken', 'cow', 'llama', 'mooshroom', 'pig', 'rabbit', 'sheep']; return animals.includes(mob.name.toLowerCase()) && !mob.metadata[16]; // metadata 16 is not baby } From 0f18dd9f128f754fbd3400edcf95d32845f8830e Mon Sep 17 00:00:00 2001 From: Kolby Nottingham Date: Wed, 1 May 2024 12:38:33 -0700 Subject: [PATCH 3/7] change cowardice range --- src/agent/modes.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/agent/modes.js b/src/agent/modes.js index 56ecbf3..5550054 100644 --- a/src/agent/modes.js +++ b/src/agent/modes.js @@ -70,11 +70,11 @@ const modes = [ on: true, active: false, update: async function (agent) { - const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 8); + const enemy = world.getNearestEntityWhere(agent.bot, entity => mc.isHostile(entity), 16); if (enemy && await world.isClearPath(agent.bot, enemy)) { agent.bot.chat(`Aaa! A ${enemy.name}!`); execute(this, agent, async () => { - await skills.avoidEnemies(agent.bot, 16); + await skills.avoidEnemies(agent.bot, 24); }); } } From 6727b44afcdaa5ebcd53216742fa7f0b68e942ea Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sat, 4 May 2024 16:17:41 -0500 Subject: [PATCH 4/7] clear pathfinder on idle, improve coward mode --- src/agent/agent.js | 1 + src/agent/library/skills.js | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/agent/agent.js b/src/agent/agent.js index 042cc26..fe44a25 100644 --- a/src/agent/agent.js +++ b/src/agent/agent.js @@ -188,6 +188,7 @@ export class Agent { }); this.bot.on('idle', () => { this.bot.clearControlStates(); + this.bot.pathfinder.stop(); // clear any lingering pathfinder this.bot.modes.unPauseAll(); this.coder.executeResume(); }); diff --git a/src/agent/library/skills.js b/src/agent/library/skills.js index d62ebb2..4889357 100644 --- a/src/agent/library/skills.js +++ b/src/agent/library/skills.js @@ -15,7 +15,8 @@ async function autoLight(bot) { let nearest_torch = world.getNearestBlock(bot, 'torch', 6); if (!nearest_torch) { let has_torch = bot.inventory.items().find(item => item.name === 'torch'); - if (has_torch) { + const curr_block = agent.bot.blockAt(pos); + if (has_torch && curr_block.name === 'air') { try { log(bot, `Placing torch at ${bot.entity.position}.`); return await placeBlock(bot, 'torch', bot.entity.position.x, bot.entity.position.y, bot.entity.position.z); @@ -771,7 +772,7 @@ export async function avoidEnemies(bot, distance=16) { * @example * await skills.avoidEnemies(bot, 8); **/ - + bot.modes.pause('self_preservation'); // prevents damage-on-low-health from interrupting the bot let enemy = world.getNearestEntityWhere(bot, entity => mc.isHostile(entity), distance); while (enemy) { const follow = new pf.goals.GoalFollow(enemy, distance+1); // move a little further away @@ -781,9 +782,10 @@ export async function avoidEnemies(bot, distance=16) { await new Promise(resolve => setTimeout(resolve, 500)); enemy = world.getNearestEntityWhere(bot, entity => mc.isHostile(entity), distance); if (bot.interrupt_code) { - return false; + break; } } + bot.pathfinder.stop(); log(bot, `Moved ${distance} away from enemies.`); return true; } From 2faba65917ce756d45fe27d5d867524bfc00da3e Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sun, 5 May 2024 10:38:01 -0500 Subject: [PATCH 5/7] changed localhost default to 127... --- src/models/local.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/local.js b/src/models/local.js index f56c043..3ed880e 100644 --- a/src/models/local.js +++ b/src/models/local.js @@ -1,7 +1,7 @@ export class Local { constructor(model_name, url) { this.model_name = model_name; - this.url = url || 'http://localhost:11434'; + this.url = url || 'http://127.0.0.1:11434' this.chat_endpoint = '/api/chat'; this.embedding_endpoint = '/api/embeddings'; } From ac73a835eb645560afc8eb29abdce6883398b42e Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Sun, 5 May 2024 10:38:52 -0500 Subject: [PATCH 6/7] added semicolon --- src/models/local.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/local.js b/src/models/local.js index 3ed880e..dd3af34 100644 --- a/src/models/local.js +++ b/src/models/local.js @@ -1,7 +1,7 @@ export class Local { constructor(model_name, url) { this.model_name = model_name; - this.url = url || 'http://127.0.0.1:11434' + this.url = url || 'http://127.0.0.1:11434'; this.chat_endpoint = '/api/chat'; this.embedding_endpoint = '/api/embeddings'; } From 0ff4c91cf7aafbe43e0ca9c54784d479262b0d4c Mon Sep 17 00:00:00 2001 From: MaxRobinsonTheGreat Date: Mon, 6 May 2024 11:16:35 -0500 Subject: [PATCH 7/7] changed default settings host --- settings.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.json b/settings.json index 9d0490a..4ee3b10 100644 --- a/settings.json +++ b/settings.json @@ -1,6 +1,6 @@ { "minecraft_version": "1.20.4", - "host": "localhost", + "host": "127.0.0.1", "port": 55916, "auth": "offline", "allow_insecure_coding": false