mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-07-01 06:05:19 +02:00
refactor tasks to task folder, readd license
This commit is contained in:
parent
bfd55a6791
commit
475311d8e6
9 changed files with 40 additions and 22 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2024 Kolby Nottingham
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
|
@ -14,7 +14,7 @@ import { handleTranslation, handleEnglishTranslation } from '../utils/translator
|
||||||
import { addBrowserViewer } from './vision/browser_viewer.js';
|
import { addBrowserViewer } from './vision/browser_viewer.js';
|
||||||
import settings from '../../settings.js';
|
import settings from '../../settings.js';
|
||||||
import { serverProxy } from './agent_proxy.js';
|
import { serverProxy } from './agent_proxy.js';
|
||||||
import { Task } from './tasks.js';
|
import { Task } from './tasks/tasks.js';
|
||||||
import { say } from './speak.js';
|
import { say } from './speak.js';
|
||||||
|
|
||||||
export class Agent {
|
export class Agent {
|
||||||
|
@ -62,7 +62,6 @@ export class Agent {
|
||||||
} else {
|
} else {
|
||||||
taskStart = Date.now();
|
taskStart = Date.now();
|
||||||
}
|
}
|
||||||
// incorporate new restart time into task
|
|
||||||
this.task = new Task(this, task_path, task_id, taskStart);
|
this.task = new Task(this, task_path, task_id, taskStart);
|
||||||
this.blocked_actions = settings.blocked_actions.concat(this.task.blocked_actions || []);
|
this.blocked_actions = settings.blocked_actions.concat(this.task.blocked_actions || []);
|
||||||
blacklistCommands(this.blocked_actions);
|
blacklistCommands(this.blocked_actions);
|
||||||
|
|
|
@ -2,7 +2,7 @@ import * as world from '../library/world.js';
|
||||||
import * as mc from '../../utils/mcdata.js';
|
import * as mc from '../../utils/mcdata.js';
|
||||||
import { getCommandDocs } from './index.js';
|
import { getCommandDocs } from './index.js';
|
||||||
import convoManager from '../conversation.js';
|
import convoManager from '../conversation.js';
|
||||||
import { checkLevelBlueprint, checkBlueprint } from '../task_types/construction_tasks.js';
|
import { checkLevelBlueprint, checkBlueprint } from '../tasks/construction_tasks.js';
|
||||||
import { load } from 'cheerio';
|
import { load } from 'cheerio';
|
||||||
|
|
||||||
const pad = (str) => {
|
const pad = (str) => {
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
import { readFileSync , writeFileSync, existsSync} from 'fs';
|
import { readFileSync , writeFileSync, existsSync} from 'fs';
|
||||||
import { executeCommand } from './commands/index.js';
|
import { executeCommand } from '../commands/index.js';
|
||||||
import { getPosition } from './library/world.js';
|
import { getPosition } from '../library/world.js';
|
||||||
import settings from '../../settings.js';
|
import settings from '../../../settings.js';
|
||||||
import { Vec3 } from 'vec3';
|
import { ConstructionTaskValidator, Blueprint } from './construction_tasks.js';
|
||||||
import { ConstructionTaskValidator, Blueprint } from './task_types/construction_tasks.js';
|
import { CookingTaskInitiator } from './cooking_tasks.js';
|
||||||
import { CookingTaskInitiator } from './task_types/cooking_tasks.js';
|
|
||||||
|
|
||||||
const PROGRESS_FILE = './hells_kitchen_progress.json';
|
const PROGRESS_FILE = './hells_kitchen_progress.json';
|
||||||
|
|
||||||
|
@ -237,27 +236,23 @@ export class Task {
|
||||||
constructor(agent, task_path, task_id, taskStartTime = null) {
|
constructor(agent, task_path, task_id, taskStartTime = null) {
|
||||||
this.agent = agent;
|
this.agent = agent;
|
||||||
this.data = null;
|
this.data = null;
|
||||||
console.log("task start time", taskStartTime);
|
|
||||||
if (taskStartTime !== null)
|
if (taskStartTime !== null)
|
||||||
this.taskStartTime = taskStartTime;
|
this.taskStartTime = taskStartTime;
|
||||||
else
|
else
|
||||||
this.taskStartTime = Date.now();
|
this.taskStartTime = Date.now();
|
||||||
|
|
||||||
console.log(this.taskStartTime);
|
|
||||||
this.validator = null;
|
this.validator = null;
|
||||||
this.reset_function = null;
|
this.reset_function = null;
|
||||||
this.blocked_actions = [];
|
this.blocked_actions = [];
|
||||||
this.task_id = task_id;
|
this.task_id = task_id;
|
||||||
console.log('Task ID:', task_id);
|
|
||||||
|
|
||||||
|
if (task_path && task_id) {
|
||||||
|
console.log('Starting task', task_id);
|
||||||
|
if (task_id.endsWith('hells_kitchen')) {
|
||||||
// Reset hells_kitchen progress when a new task starts
|
// Reset hells_kitchen progress when a new task starts
|
||||||
if (task_id && task_id.endsWith('hells_kitchen')) {
|
|
||||||
hellsKitchenProgressManager.resetTask(task_id);
|
hellsKitchenProgressManager.resetTask(task_id);
|
||||||
console.log('Reset Hells Kitchen progress for new task');
|
console.log('Reset Hells Kitchen progress for new task');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (task_path && task_id) {
|
|
||||||
this.data = this.loadTask(task_path, task_id);
|
this.data = this.loadTask(task_path, task_id);
|
||||||
this.task_type = this.data.type;
|
this.task_type = this.data.type;
|
||||||
if (this.task_type === 'construction' && this.data.blueprint) {
|
if (this.task_type === 'construction' && this.data.blueprint) {
|
||||||
|
@ -292,6 +287,9 @@ export class Task {
|
||||||
if (this.conversation)
|
if (this.conversation)
|
||||||
this.blocked_actions.push('!endConversation');
|
this.blocked_actions.push('!endConversation');
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
console.log('No task.');
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
|
@ -31,4 +31,4 @@ The generation code is documented to help with customization.
|
||||||
- `profiles/task_construct.json` - Default configuration profile
|
- `profiles/task_construct.json` - Default configuration profile
|
||||||
- `tasks/construction_tasks/test_multiagent_construction_tasks.json` - Training task definitions (initalized with 5 variants)
|
- `tasks/construction_tasks/test_multiagent_construction_tasks.json` - Training task definitions (initalized with 5 variants)
|
||||||
- `tasks/construction_tasks/test_multiagent_construction_tasks.json` - Test task definitions (initalized with 1 variant)
|
- `tasks/construction_tasks/test_multiagent_construction_tasks.json` - Test task definitions (initalized with 1 variant)
|
||||||
- `src/agent/task_types/construction_tasks.js` - Blueprint Class, Construction Validation Class, and Procedural Generation Function
|
- `src/agent/tasks/construction_tasks.js` - Blueprint Class, Construction Validation Class, and Procedural Generation Function
|
|
@ -1,6 +1,6 @@
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import path from 'path';
|
import path from 'path';
|
||||||
import {proceduralGeneration} from "../../src/agent/task_types/construction_tasks.js";
|
import {proceduralGeneration} from "../../src/agent/tasks/construction_tasks.js";
|
||||||
|
|
||||||
//note 'main' (script to run generation of tasks) is at bottom of page
|
//note 'main' (script to run generation of tasks) is at bottom of page
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import mineflayer from 'mineflayer';
|
import mineflayer from 'mineflayer';
|
||||||
import { worldToBlueprint, blueprintToTask } from '../../src/agent/task_types/construction_tasks.js';
|
import { worldToBlueprint, blueprintToTask } from '../../src/agent/tasks/construction_tasks.js';
|
||||||
import fs from 'fs';
|
import fs from 'fs';
|
||||||
import { start } from 'repl';
|
import { start } from 'repl';
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue