more conserverative fuel dispatch
This commit is contained in:
parent
2e4e805ed4
commit
f7c5e3fdf5
4 changed files with 13 additions and 5 deletions
|
@ -38,3 +38,4 @@ tower-layer = "0.3.2"
|
|||
tracing = "0.1"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
typetag = "0.2.14"
|
||||
ucnlnav = { git = "https://github.com/ucnl/UCNLNav.git", version = "0.1.0" }
|
||||
|
|
|
@ -31,6 +31,7 @@ use crate::{blocks::Block, paths::route};
|
|||
mod blocks;
|
||||
mod names;
|
||||
mod mine;
|
||||
mod fell;
|
||||
mod paths;
|
||||
mod safe_kill;
|
||||
mod turtle;
|
||||
|
@ -233,7 +234,7 @@ async fn set_goal(
|
|||
Json(req): Json<Position>,
|
||||
) -> &'static str {
|
||||
let turtle = state.read().await.get_turtle(id).await.unwrap();
|
||||
tokio::spawn(async move {turtle.goto(req).await});
|
||||
tokio::spawn(async move {turtle.goto(req).await.expect("route failed")});
|
||||
|
||||
"ACK"
|
||||
}
|
||||
|
@ -265,7 +266,8 @@ async fn turtle_info(
|
|||
let cloned = Turtle::new(
|
||||
turtle.name.to_num(),
|
||||
turtle.position,
|
||||
turtle.fuel
|
||||
turtle.fuel,
|
||||
turtle.fuel_limit,
|
||||
);
|
||||
|
||||
Json(cloned)
|
||||
|
|
|
@ -136,6 +136,7 @@ const USELESS: [&str; 5] = [
|
|||
"minecraft:cobblestone",
|
||||
"minecraft:cobbled_deepslate",
|
||||
"minecraft:rhyolite",
|
||||
//"minecraft:andesite", // TODO: Reach 2k
|
||||
];
|
||||
|
||||
/// Things that are desirable
|
||||
|
@ -150,7 +151,7 @@ pub async fn mine(turtle: TurtleCommander, pos: Vec3, fuel: Position, storage: P
|
|||
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 {
|
||||
Some(if (turtle.fuel().await as f64) < (2 * volume + (fuel.pos-turtle.pos().await.pos).abs().sum()) as f64 * 1.8 {
|
||||
println!("refueling");
|
||||
turtle.goto(fuel).await?;
|
||||
println!("docked");
|
||||
|
@ -181,6 +182,9 @@ pub async fn mine(turtle: TurtleCommander, pos: Vec3, fuel: Position, storage: P
|
|||
println!("storage rtb");
|
||||
turtle.goto(storage).await?;
|
||||
dump(turtle.clone()).await;
|
||||
// while we're here
|
||||
turtle.goto(fuel).await?;
|
||||
refuel(turtle.clone()).await;
|
||||
}
|
||||
|
||||
pos += Vec3::z() * chunk.z;
|
||||
|
@ -222,7 +226,7 @@ async fn refuel(turtle: TurtleCommander) {
|
|||
if let TurtleCommandResponse::Failure = re.ret {
|
||||
// partial refuel, good enough
|
||||
println!("only received {} fuel", turtle.fuel().await);
|
||||
if turtle.fuel().await > 1000 {
|
||||
if turtle.fuel().await > 5000 {
|
||||
break;
|
||||
} else {
|
||||
turtle.execute(Wait(15)).await;
|
||||
|
|
|
@ -100,10 +100,11 @@ impl Default for Turtle {
|
|||
}
|
||||
|
||||
impl Turtle {
|
||||
pub(crate) fn new(id: u32, position: Position, fuel: usize) -> Self {
|
||||
pub(crate) fn new(id: u32, position: Position, fuel: usize, fuel_limit: usize) -> Self {
|
||||
Self {
|
||||
name: Name::from_num(id),
|
||||
fuel,
|
||||
fuel_limit,
|
||||
queued_movement: Vec3::new(0, 0, 0),
|
||||
position,
|
||||
pending_update: true,
|
||||
|
|
Loading…
Reference in a new issue