Skip to content
Prev Previous commit
Next Next commit
style: rustfmt the HTN tick and perception observation
Co-authored-by: Andrew Brown <lazyxeon@users.noreply.github.com>
  • Loading branch information
cursoragent and lazyxeon committed Oct 15, 2026
commit 87490499d95bc9ee05ae3463e68ed2d34ce50c63
24 changes: 13 additions & 11 deletions astraweave-ai/src/htn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,11 @@ pub fn fill_observation(tiles: &NavTiles, buf: &mut ObservationBuf) {
buf.breach_len += 1;
}
buf.lost_cover_len = 0;
for cover in tiles.lost_cover.iter().take(tiles.lost_cover_count as usize) {
for cover in tiles
.lost_cover
.iter()
.take(tiles.lost_cover_count as usize)
{
if buf.lost_cover_len == 16 {
break;
}
Expand Down Expand Up @@ -348,15 +352,15 @@ pub fn plan_route(
);
let waypoints = tiles.query_path(scratch, start, goal);
if waypoints < 2 {
out.slots[0] = ActionSlot::Wait { duration_milli: 500 };
out.slots[0] = ActionSlot::Wait {
duration_milli: 500,
};
out.len = 1;
return;
}
*budget = budget.saturating_sub(1);
if let Some(portal) = best_breach(tiles, scratch, hooks) {
Comment on lines +361 to +362
out.slots[0] = ActionSlot::UseBreach {
portal_id: portal,
};
out.slots[0] = ActionSlot::UseBreach { portal_id: portal };
out.len = 1;
}
let mut far = scratch.waypoints[0];
Expand Down Expand Up @@ -400,7 +404,9 @@ fn best_breach(tiles: &NavTiles, scratch: &NavScratch, hooks: &SpatialHooks<'_>)
let score = -site.x_milli;
let take = match best {
None => true,
Some((best_id, best_score)) => score > best_score || (score == best_score && id < best_id),
Some((best_id, best_score)) => {
score > best_score || (score == best_score && id < best_id)
}
};
if take {
best = Some((id, score));
Expand Down Expand Up @@ -481,11 +487,7 @@ fn legacy_steps(snap: &WorldSnapshot, plan_id: String) -> PlanIntent {
};
};
let me = &snap.me;
let cd = me
.cooldowns
.get("throw:smoke")
.copied()
.unwrap_or(0.0);
let cd = me.cooldowns.get("throw:smoke").copied().unwrap_or(0.0);
let dx = (enemy.pos.x - me.pos.x).abs();
let dy = (enemy.pos.y - me.pos.y).abs();
let dist = dx + dy;
Expand Down
2 changes: 1 addition & 1 deletion astraweave-ai/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,12 @@ pub mod veilweaver;
#[cfg(feature = "planner_advanced")]
pub mod goap;

pub use astraweave_nav::bridge_and_ford;
pub use core_loop::*;
pub use ecs_ai_plugin::{build_app_with_ai, AiPlanningPlugin};
pub use htn::{SpatialTick, HTN_EXPANSIONS_PER_TICK};
pub use orchestrator::*;
pub use tool_sandbox::*;
pub use astraweave_nav::bridge_and_ford;

#[cfg(feature = "llm_orchestrator")]
pub use async_task::AsyncTask;
Expand Down
17 changes: 8 additions & 9 deletions astraweave-core/src/perception.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,13 @@ fn assemble_snapshot(
}

fn pois_from_observation(observation: &ObservationBuf) -> Vec<Poi> {
let mut pois = Vec::with_capacity(
observation.breach_len as usize + observation.lost_cover_len as usize,
);
for breach in observation.breaches.iter().take(observation.breach_len as usize) {
let mut pois =
Vec::with_capacity(observation.breach_len as usize + observation.lost_cover_len as usize);
for breach in observation
.breaches
.iter()
.take(observation.breach_len as usize)
{
pois.push(Poi {
k: "breach".into(),
Comment on lines +320 to +321
pos: IVec2 {
Expand Down Expand Up @@ -563,11 +566,7 @@ mod tests {
y: 9,
};
observation.breach_len = 1;
observation.lost_cover[0] = ObservedCover {
id: 3,
x: 2,
y: 2,
};
observation.lost_cover[0] = ObservedCover { id: 3, x: 2, y: 2 };
observation.lost_cover_len = 1;
observation.weaving[0] = WeaveEffectHook {
effect_id: 1,
Expand Down