mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-31 03:13:03 +02:00
3 big changes. 1:blueprint removed from blueprint.explain() 2:construction validation no longer includes air particles 3:autodeletes blueprint before construction task.
This commit is contained in:
parent
78843c9a26
commit
baaab58f98
3 changed files with 40 additions and 10 deletions
|
@ -8,7 +8,6 @@ export class ConstructionTaskValidator {
|
|||
validate() {
|
||||
try {
|
||||
//todo: somehow make this more of a percentage or something
|
||||
//todo: change air validation
|
||||
console.log('Validating task...');
|
||||
let valid = false;
|
||||
let score = 0;
|
||||
|
@ -71,12 +70,14 @@ export class Blueprint {
|
|||
}
|
||||
explain() {
|
||||
var explanation = "";
|
||||
|
||||
// todo: we need to limit this to be a certain amount of levels to not overload memory...
|
||||
for (let item of this.data.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`;
|
||||
// let placement_string = this._getPlacementString(item.placement);
|
||||
// explanation += `\n${placement_string}\n`;
|
||||
}
|
||||
return explanation;
|
||||
}
|
||||
|
@ -165,22 +166,29 @@ export class Blueprint {
|
|||
const x = startCoords[0] + xOffset;
|
||||
const y = startCoords[1];
|
||||
const z = startCoords[2] + zOffset;
|
||||
|
||||
|
||||
try {
|
||||
const blockAtLocation = bot.blockAt(new Vec3(x, y, z));
|
||||
if (!blockAtLocation || blockAtLocation.name !== blockName) {
|
||||
const actualBlockName = blockAtLocation ? bot.registry.blocks[blockAtLocation.type].name : "air";
|
||||
|
||||
// Skip if both expected and actual block are "air"
|
||||
if (blockName === "air" && actualBlockName === "air") {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (actualBlockName !== blockName) {
|
||||
mismatches.push({
|
||||
level: levelData.level,
|
||||
coordinates: [x, y, z],
|
||||
expected: blockName,
|
||||
actual: blockAtLocation ? bot.registry.blocks[blockAtLocation.type].name : 'air' // Assuming air if no block
|
||||
actual: actualBlockName
|
||||
});
|
||||
} else {
|
||||
matches.push({
|
||||
level: levelData.level,
|
||||
coordinates: [x, y, z],
|
||||
expected: blockName,
|
||||
actual: blockAtLocation ? bot.registry.blocks[blockAtLocation.type].name : 'air' // Assuming air if no block
|
||||
actual: actualBlockName
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
|
@ -292,7 +300,7 @@ export class Blueprint {
|
|||
};
|
||||
|
||||
return { commands, nearbyPosition };
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ import { getPosition } from './library/world.js'
|
|||
import settings from '../../settings.js';
|
||||
import { Vec3 } from 'vec3';
|
||||
import { ConstructionTaskValidator, Blueprint } from './construction_tasks.js';
|
||||
import {autoBuild, autoDelete} from "../../test/test_blueprint_layout.js";
|
||||
|
||||
//todo: modify validator code to return an object with valid and score -> do more testing hahah
|
||||
//todo: figure out how to log these things to the same place as bots/histories
|
||||
|
@ -185,6 +186,7 @@ export class Task {
|
|||
then set a random block to dirt and teleport the bot to stand on that block for starting the construction,
|
||||
This was done by MaxRobinson in one of the youtube videos.
|
||||
*/
|
||||
|
||||
|
||||
if (this.data.type !== 'construction') {
|
||||
const pos = getPosition(bot);
|
||||
|
@ -212,6 +214,23 @@ export class Task {
|
|||
let other_name = available_agents.filter(n => n !== name)[0];
|
||||
await executeCommand(this.agent, `!startConversation("${other_name}", "${this.conversation}")`);
|
||||
}
|
||||
|
||||
|
||||
if (this.data.type === 'construction'){
|
||||
//Ensures construction is cleaned out first. -> relies on cheats which are turned off?
|
||||
if (this.blueprint){
|
||||
const result = this.blueprint.autoDelete();
|
||||
// const result = clearHouse(blueprint)
|
||||
const commands = result.commands;
|
||||
const nearbyPosition = result.nearbyPosition;
|
||||
for (const command of commands) {
|
||||
bot.chat(command);
|
||||
}
|
||||
}
|
||||
else{
|
||||
console.log('no construction blueprint?')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -55,6 +55,7 @@ function generateConstructionTasks() {
|
|||
const roomCounts = [4, 6, 8];
|
||||
const windowStyles = [0, 1, 2];
|
||||
const carpetStyles = [0, 1, 2];
|
||||
const timeout = 600 // 10 min base?
|
||||
|
||||
for (let m = 0; m < materialLevels; m++) {
|
||||
for (let r = 0; r < roomCounts.length; r++) {
|
||||
|
@ -86,8 +87,10 @@ function generateConstructionTasks() {
|
|||
goal: "Make a house with the blueprint",
|
||||
conversation: "Let's share materials and make a house with the blueprint",
|
||||
agent_count: 2,
|
||||
blueprint: blueprint,
|
||||
initial_inventory: createInitialInventory(blueprint, 2)
|
||||
initial_inventory: createInitialInventory(blueprint, 2),
|
||||
timeout: timeout+(300*r), // 5 minute per additional level of complexity
|
||||
blueprint: blueprint, //todo: make a pointer?
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue