1
Fork 0

mining tweaks

This commit is contained in:
Andy Killorin 2023-12-21 22:38:48 -06:00
parent 48fc623785
commit 2e4e805ed4
Signed by: ank
GPG key ID: B6241CA3B552BCA4
3 changed files with 20 additions and 9 deletions

View file

@ -135,7 +135,7 @@ const USELESS: [&str; 5] = [
"minecraft:gravel",
"minecraft:cobblestone",
"minecraft:cobbled_deepslate",
"minecraft:diorite",
"minecraft:rhyolite",
];
/// Things that are desirable
@ -148,7 +148,19 @@ pub async fn mine(turtle: TurtleCommander, pos: Vec3, fuel: Position, storage: P
let volume = chunk.x * chunk.y * chunk.z;
let mut pos = pos;
let mut valuables = Vec::new();
async fn refuel_needed(turtle: &TurtleCommander, volume: i32, fuel: Position) -> Option<()> {
Some(if (turtle.fuel().await as f64) < (volume + (fuel.pos-turtle.pos().await.pos).abs().sum()) as f64 * 1.1 {
println!("refueling");
turtle.goto(fuel).await?;
println!("docked");
refuel(turtle.clone()).await;
})
}
loop {
refuel_needed(&turtle, volume, fuel).await?;
mine_chunk(turtle.clone(), pos, chunk).await?;
valuables.append(&mut near_valuables(&turtle, pos, chunk).await);
@ -161,12 +173,8 @@ pub async fn mine(turtle: TurtleCommander, pos: Vec3, fuel: Position, storage: P
turtle.execute(near.dig(block)?).await;
observe(turtle.clone(), block).await;
valuables.append(&mut near_valuables(&turtle, near.pos, Vec3::new(2,2,2)).await);
}
if (turtle.fuel().await as f64) < (volume + (fuel.pos-turtle.pos().await.pos).abs().sum()) as f64 * 1.1 {
println!("refueling");
turtle.goto(fuel).await?;
refuel(turtle.clone()).await;
refuel_needed(&turtle, volume, fuel).await?;
}
if dump_filter(turtle.clone(), |i| USELESS.iter().any(|u| **u == i.name)).await > 12 {

View file

@ -61,8 +61,8 @@ fn next(from: &Position, world: &WorldReadLock) -> Vec<(Position, u32)> {
let ahead = from.pos + from.dir.unit();
insert(&mut vec, ahead, from.dir, world, UNKNOWN);
let behind = from.pos - from.dir.unit();
insert(&mut vec, behind, from.dir, world, None);
//let behind = from.pos - from.dir.unit();
//insert(&mut vec, behind, from.dir, world, None);
let above = from.pos + Vec3::y();
insert(&mut vec, above, from.dir, world, UNKNOWN);
@ -81,13 +81,15 @@ pub const TRANSPARENT: [&str; 3] = [
];
/// Blocks that are fine to tunnel through
const GARBAGE: [&str; 6] = [
const GARBAGE: [&str; 8] = [
"minecraft:stone",
"minecraft:dirt",
"minecraft:andesite",
"minecraft:sand",
"minecraft:gravel",
"minecraft:sandstone",
"minecraft:deepslate",
"twigs:rhyolite",
];
/// time taken to go through uncharted territory (in turtle. calls)

View file

@ -117,6 +117,7 @@ impl Turtle {
Self {
name: self.name,
fuel: self.fuel,
fuel_limit: self.fuel_limit,
position: self.position,
pending_update: self.pending_update,
queued_movement: self.queued_movement,