mining tweaks
This commit is contained in:
parent
48fc623785
commit
2e4e805ed4
3 changed files with 20 additions and 9 deletions
|
@ -135,7 +135,7 @@ const USELESS: [&str; 5] = [
|
||||||
"minecraft:gravel",
|
"minecraft:gravel",
|
||||||
"minecraft:cobblestone",
|
"minecraft:cobblestone",
|
||||||
"minecraft:cobbled_deepslate",
|
"minecraft:cobbled_deepslate",
|
||||||
"minecraft:diorite",
|
"minecraft:rhyolite",
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Things that are desirable
|
/// 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 volume = chunk.x * chunk.y * chunk.z;
|
||||||
let mut pos = pos;
|
let mut pos = pos;
|
||||||
let mut valuables = Vec::new();
|
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 {
|
loop {
|
||||||
|
refuel_needed(&turtle, volume, fuel).await?;
|
||||||
|
|
||||||
mine_chunk(turtle.clone(), pos, chunk).await?;
|
mine_chunk(turtle.clone(), pos, chunk).await?;
|
||||||
|
|
||||||
valuables.append(&mut near_valuables(&turtle, 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;
|
turtle.execute(near.dig(block)?).await;
|
||||||
observe(turtle.clone(), block).await;
|
observe(turtle.clone(), block).await;
|
||||||
valuables.append(&mut near_valuables(&turtle, near.pos, Vec3::new(2,2,2)).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 {
|
refuel_needed(&turtle, volume, fuel).await?;
|
||||||
println!("refueling");
|
|
||||||
turtle.goto(fuel).await?;
|
|
||||||
refuel(turtle.clone()).await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if dump_filter(turtle.clone(), |i| USELESS.iter().any(|u| **u == i.name)).await > 12 {
|
if dump_filter(turtle.clone(), |i| USELESS.iter().any(|u| **u == i.name)).await > 12 {
|
||||||
|
|
|
@ -61,8 +61,8 @@ fn next(from: &Position, world: &WorldReadLock) -> Vec<(Position, u32)> {
|
||||||
let ahead = from.pos + from.dir.unit();
|
let ahead = from.pos + from.dir.unit();
|
||||||
insert(&mut vec, ahead, from.dir, world, UNKNOWN);
|
insert(&mut vec, ahead, from.dir, world, UNKNOWN);
|
||||||
|
|
||||||
let behind = from.pos - from.dir.unit();
|
//let behind = from.pos - from.dir.unit();
|
||||||
insert(&mut vec, behind, from.dir, world, None);
|
//insert(&mut vec, behind, from.dir, world, None);
|
||||||
|
|
||||||
let above = from.pos + Vec3::y();
|
let above = from.pos + Vec3::y();
|
||||||
insert(&mut vec, above, from.dir, world, UNKNOWN);
|
insert(&mut vec, above, from.dir, world, UNKNOWN);
|
||||||
|
@ -81,13 +81,15 @@ pub const TRANSPARENT: [&str; 3] = [
|
||||||
];
|
];
|
||||||
|
|
||||||
/// Blocks that are fine to tunnel through
|
/// Blocks that are fine to tunnel through
|
||||||
const GARBAGE: [&str; 6] = [
|
const GARBAGE: [&str; 8] = [
|
||||||
"minecraft:stone",
|
"minecraft:stone",
|
||||||
"minecraft:dirt",
|
"minecraft:dirt",
|
||||||
"minecraft:andesite",
|
"minecraft:andesite",
|
||||||
"minecraft:sand",
|
"minecraft:sand",
|
||||||
"minecraft:gravel",
|
"minecraft:gravel",
|
||||||
"minecraft:sandstone",
|
"minecraft:sandstone",
|
||||||
|
"minecraft:deepslate",
|
||||||
|
"twigs:rhyolite",
|
||||||
];
|
];
|
||||||
|
|
||||||
/// time taken to go through uncharted territory (in turtle. calls)
|
/// time taken to go through uncharted territory (in turtle. calls)
|
||||||
|
|
|
@ -117,6 +117,7 @@ impl Turtle {
|
||||||
Self {
|
Self {
|
||||||
name: self.name,
|
name: self.name,
|
||||||
fuel: self.fuel,
|
fuel: self.fuel,
|
||||||
|
fuel_limit: self.fuel_limit,
|
||||||
position: self.position,
|
position: self.position,
|
||||||
pending_update: self.pending_update,
|
pending_update: self.pending_update,
|
||||||
queued_movement: self.queued_movement,
|
queued_movement: self.queued_movement,
|
||||||
|
|
Loading…
Reference in a new issue