From 4d31e6bf489ada618da9f907cd9f6c41c65c0ea6 Mon Sep 17 00:00:00 2001 From: Andy Killorin <37423245+Speedy6451@users.noreply.github.com> Date: Sun, 17 Dec 2023 01:16:47 -0600 Subject: [PATCH] A* in minecraft (real) --- server/src/turtle.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/server/src/turtle.rs b/server/src/turtle.rs index fe92cbe..b27e525 100644 --- a/server/src/turtle.rs +++ b/server/src/turtle.rs @@ -15,23 +15,23 @@ fn next(from: &Position, world: &World) -> Vec<(Position, u32)> { vec.push(((from.0, from.1.left()),1)); vec.push(((from.0, from.1.right()),1)); - fn insert(vec: &mut Vec<(Position, u32)>, point: Vec3, orientation: Direction, world: &World) { + fn insert(vec: &mut Vec<(Position, u32)>, point: Vec3, orientation: Direction, world: &World, unknown: Option) { world.locate_at_point(&point.into()) - .map_or(Some(UNKNOWN), |b| difficulty(&b.name)) + .map_or(unknown, |b| difficulty(&b.name)) .map(|d| vec.push(((point, orientation), d))); } let ahead = from.0 + from.1.unit(); - insert(&mut vec, ahead, from.1, world); + insert(&mut vec, ahead, from.1, world, UNKNOWN); let behind = from.0 - from.1.unit(); - insert(&mut vec, behind, from.1, world); + insert(&mut vec, behind, from.1, world, None); let above = from.0 + Vec3::y(); - insert(&mut vec, above, from.1, world); + insert(&mut vec, above, from.1, world,UNKNOWN); let below = from.0 - Vec3::y(); - insert(&mut vec, below, from.1, world); + insert(&mut vec, below, from.1, world,UNKNOWN); vec } @@ -44,11 +44,11 @@ const GARBAGE: [&str; 3] = [ ]; /// time taken to go through uncharted territory (in turtle. calls) -const UNKNOWN: u32 = 2; +const UNKNOWN: Option = Some(2); // time to go somewhere fn difficulty(name: &str) -> Option { if name == "minecraft:air" { return Some(1) }; - if GARBAGE.contains(&name) { return Some(2)}; + //if GARBAGE.contains(&name) { return Some(2)}; None }