diff --git a/andy.json b/andy.json index 97b45b4..ecb4c28 100644 --- a/andy.json +++ b/andy.json @@ -1,6 +1,6 @@ { "name": "andy", - "model": "gpt-4o-mini" + "model": "gpt-4o" } \ No newline at end of file diff --git a/example_tasks.json b/example_tasks.json index b579233..4dccc70 100644 --- a/example_tasks.json +++ b/example_tasks.json @@ -49,5 +49,60 @@ "number_of_target": 1, "type": "techtree", "timeout": 300 + }, + "construction_house": { + "type": "construction", + "goal": "Make a house with a blueprint below", + "blueprint": { + "materials": { + "plank": { + "id": "oak_plank", + "number": 40 + }, + "door": { + "id": "oak_door", + "number": 1 + } + }, + "levels": [ + { + "level": 0, + "coordinates": [142, -60, -179], + "placement": + [ + ["plank", "plank", "door", "plank", "plank"], + ["plank", "air", "air", "air", "plank"], + ["plank", "air", "air", "air", "plank"], + ["plank", "plank", "plank", "plank", "plank"] + ] + }, + { + "level": 1, + "coordinates": [142, -59, -179], + "placement": + [ + ["plank", "plank", "air", "plank", "plank"], + ["plank", "air", "air", "air", "plank"], + ["plank", "air", "air", "air", "plank"], + ["plank", "plank", "plank", "plank", "plank"] + ] + }, + { + "level": 2, + "coordinates": [142, -58, -179], + "placement": + [ + ["plank", "plank", "plank", "plank", "plank"], + ["plank", "air", "air", "air", "plank"], + ["plank", "air", "air", "air", "plank"], + ["plank", "plank", "plank", "plank", "plank"] + ] + } + ] + }, + "initial_inventory": { + "oak_planks": 40, + "oak_door": 1 + } } } \ No newline at end of file diff --git a/settings.js b/settings.js index 4895833..faa1741 100644 --- a/settings.js +++ b/settings.js @@ -28,7 +28,7 @@ export default "language": "en", // translate to/from this language. Supports these language names: https://cloud.google.com/translate/docs/languages "show_bot_views": false, // show bot's view in browser at localhost:3000, 3001... - "allow_insecure_coding": false, // allows newAction command and model can write/run code on your computer. enable at own risk + "allow_insecure_coding": true, // allows newAction command and model can write/run code on your computer. enable at own risk "code_timeout_mins": 10, // minutes code is allowed to run. -1 for no timeout "max_messages": 15, // max number of messages to keep in context diff --git a/src/agent/tasks.js b/src/agent/tasks.js index 881b933..d0ea520 100644 --- a/src/agent/tasks.js +++ b/src/agent/tasks.js @@ -3,7 +3,6 @@ import { executeCommand } from './commands/index.js'; import { getPosition } from './library/world.js' import settings from '../../settings.js'; - export class TaskValidator { constructor(data, agent) { this.target = data.target; @@ -36,6 +35,38 @@ export class TaskValidator { } } +export class Blueprint { + constructor(blueprint) { + this.blueprint = blueprint; + } + explain() { + var explanation = ""; + for (let item of this.blueprint.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`; + } + return explanation; + } + + _getPlacementString(placement) { + var placement_string = "[\n"; + for (let row of placement) { + placement_string += "["; + for (let i = 0; i < row.length - 1; i++) { + let item = row[i]; + placement_string += `${item}, `; + } + let final_item = row[row.length - 1]; + placement_string += `${final_item}],\n`; + } + placement_string += "]"; + return placement_string; + } +} + export class Task { constructor(agent, task_path, task_id) { @@ -193,3 +224,14 @@ export class Task { } } } + +export function giveBlueprint(agent, blueprint) { + let bot = agent.bot; + let name = agent.name; + let blueprint_name = blueprint.name; + let blueprint_count = blueprint.count; + bot.chat(`/clear ${name}`); + console.log(`Cleared ${name}'s inventory.`); + bot.chat(`/give ${name} ${blueprint_name} ${blueprint_count}`); + console.log(`Gave ${name} ${blueprint_count} ${blueprint_name}(s).`); +} diff --git a/test/test_blueprint.js b/test/test_blueprint.js new file mode 100644 index 0000000..01c9196 --- /dev/null +++ b/test/test_blueprint.js @@ -0,0 +1,22 @@ +import { Blueprint } from '../src/agent/tasks.js'; +import { readFileSync } from 'fs'; + +//load file from example_tasks.json +const object = JSON.parse(readFileSync('example_tasks.json', 'utf8')); +console.log(object.construction_house.blueprint); +const blueprint = new Blueprint(object.construction_house.blueprint); +const placement = object.construction_house.blueprint.levels[0].placement; +console.log(placement); +var placement_string = "[\n"; +for (let row of placement) { + placement_string += "["; + for (let i = 0; i < row.length - 1; i++) { + let item = row[i]; + placement_string += `${item}, `; + } + let final_item = row[row.length - 1]; + placement_string += `${final_item}],\n`; +} +placement_string += "]"; +console.log(placement_string); +console.log(blueprint.explain()); \ No newline at end of file