Merge branch 'main' into procedural_generation_save

This commit is contained in:
Isadora White 2025-03-04 11:10:42 -08:00 committed by GitHub
commit 2bdaf6e232
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 12 additions and 58 deletions

View file

@ -1,7 +1,7 @@
{ {
"name": "andy", "name": "andy",
"model": "gpt-4o", "model": "gpt-4o-mini",
"conversation_examples": [ "conversation_examples": [
[ [

View file

@ -1,7 +1,6 @@
{ {
"name": "jill", "name": "jill",
"model": "gpt-4o-mini",
"model": "gpt-4o",
"conversation_examples": [ "conversation_examples": [
[ [

View file

@ -668,7 +668,6 @@ export class Agent {
this.history.save(); this.history.save();
process.exit(code); process.exit(code);
} }
async checkTaskDone() { async checkTaskDone() {
if (this.task.data) { if (this.task.data) {
let res = this.task.isDone(); let res = this.task.isDone();

View file

@ -332,6 +332,8 @@ export class CookingTaskInitiator {
['minecraft:cooked_mutton', 64], ['minecraft:cooked_mutton', 64],
['minecraft:cooked_salmon', 64], ['minecraft:cooked_salmon', 64],
['minecraft:cooked_cod', 64] ['minecraft:cooked_cod', 64]
['minecraft:gold_ingot', 64],
['minecraft:oak_planks', 64],
]; ];
// Fill the chest with random cooking items // Fill the chest with random cooking items

View file

@ -26,6 +26,7 @@ function checkItemPresence(data, agent) {
function isTargetDictionaryWithQuantities(target) { function isTargetDictionaryWithQuantities(target) {
return typeof target === 'object' && return typeof target === 'object' &&
!Array.isArray(target) && !Array.isArray(target) &&
target !== null && target !== null &&
Object.values(target).every(value => typeof value === 'number'); Object.values(target).every(value => typeof value === 'number');
} }
@ -94,7 +95,6 @@ function checkItemPresence(data, agent) {
for (const [item, requiredCount] of Object.entries(requiredQuantities)) { for (const [item, requiredCount] of Object.entries(requiredQuantities)) {
const itemName = item.toLowerCase(); const itemName = item.toLowerCase();
const currentCount = inventoryCount[itemName] || 0; const currentCount = inventoryCount[itemName] || 0;
if (currentCount < requiredCount) { if (currentCount < requiredCount) {
allTargetsMet = false; allTargetsMet = false;
missingItems.push({ missingItems.push({
@ -158,16 +158,17 @@ export class Task {
} }
this.taskTimeout = this.data.timeout || 300; this.taskTimeout = this.data.timeout || 300;
this.taskStartTime = Date.now(); this.taskStartTime = Date.now();
// Set validator based on task_type
if (this.task_type === 'construction') { if (this.task_type === 'construction') {
this.validator = new ConstructionTaskValidator(this.data, this.agent); this.validator = new ConstructionTaskValidator(this.data, this.agent);
} else if (this.task_type === 'cooking' || this.task_type === 'techtree') { } else if (this.task_type === 'cooking' || this.task_type === 'techtree') {
this.validator = new CookingCraftingTaskValidator(this.data, this.agent); this.validator = new CookingCraftingTaskValidator(this.data, this.agent);
} else { } else {
this.validator = null; this.validator = null;
} }
if (this.data.blocked_actions) { if (this.data.blocked_actions) {
this.blocked_actions = this.data.blocked_actions[this.agent.count_id.toString()] || []; this.blocked_actions = this.data.blocked_actions[this.agent.count_id.toString()] || [];
} else { } else {
@ -179,7 +180,7 @@ export class Task {
if (this.conversation) if (this.conversation)
this.blocked_actions.push('!endConversation'); this.blocked_actions.push('!endConversation');
} }
this.name = this.agent.name; this.name = this.agent.name;
this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name); this.available_agents = settings.profiles.map((p) => JSON.parse(readFileSync(p, 'utf8')).name);
} }
@ -272,7 +273,6 @@ export class Task {
} else { } else {
this.initiator = null; this.initiator = null;
} }
await this.teleportBots(); await this.teleportBots();
//wait for a bit so bots are teleported //wait for a bit so bots are teleported
@ -347,7 +347,7 @@ export class Task {
let human_player_name = null; let human_player_name = null;
let bot = this.agent.bot; let bot = this.agent.bot;
// Finding if there is a human player on the server // Finding if there is a human player on the server
for (const playerName in bot.players) { for (const playerName in bot.players) {
const player = bot.players[playerName]; const player = bot.players[playerName];
@ -362,12 +362,11 @@ export class Task {
console.log(`Teleporting ${this.name} to human ${human_player_name}`) console.log(`Teleporting ${this.name} to human ${human_player_name}`)
bot.chat(`/tp ${this.name} ${human_player_name}`) bot.chat(`/tp ${this.name} ${human_player_name}`)
} }
await new Promise((resolve) => setTimeout(resolve, 200)); await new Promise((resolve) => setTimeout(resolve, 200));
// now all bots are teleport on top of each other (which kinda looks ugly) // now all bots are teleport on top of each other (which kinda looks ugly)
// Thus, we need to teleport them to random distances to make it look better // Thus, we need to teleport them to random distances to make it look better
/* /*
Note : We don't want randomness for construction task as the reference point matters a lot. Note : We don't want randomness for construction task as the reference point matters a lot.
Another reason for no randomness for construction task is because, often times the user would fly in the air, Another reason for no randomness for construction task is because, often times the user would fly in the air,
@ -375,7 +374,6 @@ export class Task {
This was done by MaxRobinson in one of the youtube videos. This was done by MaxRobinson in one of the youtube videos.
*/ */
if (this.data.type !== 'construction') { if (this.data.type !== 'construction') {
const pos = getPosition(bot); const pos = getPosition(bot);
@ -394,7 +392,6 @@ export class Task {
} }
} }
if (this.data.type === 'construction'){ if (this.data.type === 'construction'){
//Ensures construction is cleaned out first. -> relies on cheats which are turned off? //Ensures construction is cleaned out first. -> relies on cheats which are turned off?
if (this.blueprint){ if (this.blueprint){
@ -410,48 +407,5 @@ export class Task {
console.log('no construction blueprint?') console.log('no construction blueprint?')
} }
} }
}
}
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).`);
}
/**
* Auto-builds blueprint in minecraft world
* @param agent
* @param blueprint must be of the blueprint class
*/
export function buildBlueprint(agent, blueprint){
let bot = agent.bot
const result = blueprint.autoBuild();
// const result = clearHouse(blueprint)
const commands = result.commands;
const nearbyPosition = result.nearbyPosition;
for (const command of commands) {
bot.chat(command);
} }
} }
/**
* auto-deletes a built blueprint
* @param agent
* @param blueprint must be of the blueprint class
*/
export function deleteBlueprint(agent, blueprint){
let bot = agent.bot
const result = blueprint.autoDelete()
const commands = result.commands;
const nearbyPosition = result.nearbyPosition;
for (const command of commands) {
bot.chat(command);
}
}