mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 06:15:32 +02:00
construction task fixes
This commit is contained in:
parent
a61c6da134
commit
21dfa0a9d3
2 changed files with 63 additions and 49 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -19,14 +19,10 @@ experiments/
|
||||||
andy_*.json
|
andy_*.json
|
||||||
jill_*.json
|
jill_*.json
|
||||||
src/models/logs/*
|
src/models/logs/*
|
||||||
<<<<<<< HEAD
|
|
||||||
server_data/*
|
server_data/*
|
||||||
server_data_*/*
|
server_data_*/*
|
||||||
=======
|
|
||||||
server_data*
|
|
||||||
results/*
|
results/*
|
||||||
>>>>>>> d70491e5974a973b96c47f0515c2722b82c9b253
|
|
||||||
tasks/construction_tasks/test_multiagent_construction_tasks.json
|
tasks/construction_tasks/test_multiagent_construction_tasks.json
|
||||||
tasks/construction_tasks/train_multiagent_construction_tasks.json
|
tasks/construction_tasks/train_multiagent_construction_tasks.json
|
||||||
tasks/construction_tasks/test/**
|
tasks/construction_tasks/test/**
|
||||||
tasks/construction_tasks/train/**
|
tasks/construction_tasks/train/**
|
|
@ -634,51 +634,46 @@ export function proceduralGeneration(m = 20,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// out of commission
|
//still a little buggy
|
||||||
function addStairs(matrix, x, y, z, direction) {
|
function addStairs(matrix, x, y, z, length, width, material) {
|
||||||
let dz = 0; // Change in Z direction
|
|
||||||
let dx = 0; // Change in X direction
|
|
||||||
let facing = '';
|
|
||||||
|
|
||||||
// Determine direction and facing
|
|
||||||
switch (direction) {
|
|
||||||
case 'north':
|
|
||||||
dz = -1;
|
|
||||||
facing = 'oak_stairs[facing=north]';
|
|
||||||
break;
|
|
||||||
case 'south':
|
|
||||||
dz = 1;
|
|
||||||
facing = 'oak_stairs[facing=south]';
|
|
||||||
break;
|
|
||||||
case 'east':
|
|
||||||
dx = 1;
|
|
||||||
facing = 'oak_stairs[facing=east]';
|
|
||||||
break;
|
|
||||||
case 'west':
|
|
||||||
dx = -1;
|
|
||||||
facing = 'oak_stairs[facing=west]';
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
console.error('Invalid stair direction');
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Bore stair pattern downwards until we hit a floor or the matrix edge
|
|
||||||
let currentZ = z;
|
let currentZ = z;
|
||||||
while (currentZ > 0 && matrix[currentZ - 1][x][y] === 'air') {
|
let currentX = x + 1;
|
||||||
// Place stone as foundation
|
let currentY = y + 1;
|
||||||
matrix[currentZ - 1][x][y] = 'stone';
|
let direction = 0;
|
||||||
|
let stepCount = 0;
|
||||||
|
const maxSteps = length * width; // Safety limit
|
||||||
|
|
||||||
// Place stair above the stone
|
while (currentZ >= 0 && currentX < x + length - 1 && currentY < y + width - 1 && stepCount < maxSteps) {
|
||||||
matrix[currentZ][x][y] = facing;
|
// Place stair block
|
||||||
|
matrix[currentZ][currentX][currentY] = material || 'stone';
|
||||||
|
|
||||||
// Move down diagonally
|
// Clear 3 blocks above for headroom
|
||||||
x += dx;
|
for (let i = 1; i <= 3; i++) {
|
||||||
y += dz;
|
if (currentZ + i < matrix.length) {
|
||||||
currentZ--;
|
matrix[currentZ + i][currentX][currentY] = 'air';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check if we've hit the edge
|
// Move to next position based on direction
|
||||||
if (x < 0 || x >= matrix[0].length || y < 0 || y >= matrix[0][0].length) break;
|
if (direction === 0) {
|
||||||
|
currentX++;
|
||||||
|
if (currentX >= x + length - 1) {
|
||||||
|
currentX = x + length - 2;
|
||||||
|
direction = 1;
|
||||||
|
} else {
|
||||||
|
currentZ--;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
currentY++;
|
||||||
|
if (currentY >= y + width - 1) {
|
||||||
|
currentY = y + width - 2;
|
||||||
|
direction = 0;
|
||||||
|
} else {
|
||||||
|
currentZ--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
stepCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -817,9 +812,11 @@ export function proceduralGeneration(m = 20,
|
||||||
|
|
||||||
embellishments(carpetStyle, windowStyle, matrix, newX, newY, newZ, newLength, newWidth, newDepth, material)
|
embellishments(carpetStyle, windowStyle, matrix, newX, newY, newZ, newLength, newWidth, newDepth, material)
|
||||||
|
|
||||||
addLadder(matrix, lastRoom.x + Math.floor(lastRoom.length / 2),
|
// addLadder(matrix, lastRoom.x + Math.floor(lastRoom.length / 2),
|
||||||
lastRoom.y + Math.floor(lastRoom.width / 2),
|
// lastRoom.y + Math.floor(lastRoom.width / 2),
|
||||||
newZ); // Adding the ladder
|
// newZ); // Adding the ladder
|
||||||
|
|
||||||
|
addStairs(matrix, newX, newY, newZ, newLength, newWidth, material)
|
||||||
|
|
||||||
|
|
||||||
lastRoom = {x: newX, y: newY, z: newZ, length: newLength, width: newWidth, depth: newDepth};
|
lastRoom = {x: newX, y: newY, z: newZ, length: newLength, width: newWidth, depth: newDepth};
|
||||||
|
@ -998,3 +995,24 @@ function matrixToBlueprint(matrix, startCoord) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// testing code
|
||||||
|
|
||||||
|
// let blueprint = proceduralGeneration(10,10,20)
|
||||||
|
// const b = new Blueprint(blueprint)
|
||||||
|
// const result = b.autoBuild();
|
||||||
|
// const commands = result.commands;
|
||||||
|
// const nearbyPosition = result.nearbyPosition;
|
||||||
|
//
|
||||||
|
// import {initBot} from "../../utils/mcdata.js";
|
||||||
|
// let bot = initBot("andy");
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// bot.on('spawn', async () => {
|
||||||
|
// console.log("nearby position", nearbyPosition);
|
||||||
|
// bot.chat(`/tp @andy ${nearbyPosition.x} ${nearbyPosition.y} ${nearbyPosition.z}`);
|
||||||
|
// for (const command of commands) {
|
||||||
|
// bot.chat(command);
|
||||||
|
// }
|
||||||
|
// });
|
Loading…
Add table
Reference in a new issue