You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. **Live web visualizer**: Attach via ```BT::with_telemetry(port)```
(default 127.0.0.1) or ```BT::with_telemetry_at(addr, port)``` — opens
an embedded HTML page at ```http://{addr}:{port}/``` that renders the
tree over a WebSocket. Rationale for choosing websockets, along with
advantages I wrote here:
#55 (comment)
2. **Zero-overhead when off**: Whole feature is hidden behind
```visualize```
To see a live demo:
1. ```cargo run --bin visualizer_smoke```
2. On your local web browser, open ```http://127.0.0.1:8910/```
I also added a whole bunch of tests for prevent regression. Also, a huge
chunk of this PR is me adding a tracer to all bt nodes. While there is
graphviz and json serialization support, without an actual tracer it
would be impossible to know the live state of each node
(running/pass/fail/idle) at every tick. Existing code only gave static
structure of the tree, not the live state of the entire tree along with
every single node's status at each tick.
Disclaimer: Used claude code to generate documentation and the unit
tests.
https://github.com/user-attachments/assets/aadbb7be-9fbe-4833-b5db-8da4cf8ecfbe
// Suppress unused-variable warnings on the no-op path (visualize off,
142
+
// or visualize on but no sender attached).
143
+
let _ = (e, f);
144
+
TickRoute::NotHandled
68
145
}
69
146
70
147
/// Retrieve an immutable reference to the blackboard for
@@ -94,6 +171,18 @@ impl<A: Clone, B> BT<A, B> {
94
171
let initial_behavior = self.initial_behavior.to_owned();
95
172
self.state = State::new(initial_behavior);
96
173
self.finished = false;
174
+
// tick_count is intentionally NOT reset — it identifies tick events
175
+
// across the BT's lifetime, including across reset_bt boundaries.
176
+
// dropped_traces resets per-run: it's a diagnostic for the current session.
177
+
#[cfg(feature = "visualize")]
178
+
{
179
+
self.telemetry.dropped_traces = 0;
180
+
}
181
+
}
182
+
183
+
/// Returns the total number of ticks this BT has completed (across resets).
184
+
pubfntick_count(&self) -> u64{
185
+
self.tick_count
97
186
}
98
187
99
188
/// Whether this behavior tree is in a completed state (the last tick returned
@@ -102,57 +191,3 @@ impl<A: Clone, B> BT<A, B> {
102
191
self.finished
103
192
}
104
193
}
105
-
106
-
#[cfg(feature = "visualize")]
107
-
impl<A:Clone + Debug,B:Debug>BT<A,B>{
108
-
/// Compile the behavior tree into a [graphviz](https://graphviz.org/) compatible [DiGraph](https://docs.rs/petgraph/latest/petgraph/graph/type.DiGraph.html).
0 commit comments