behavior_machines 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/Cargo.lock +3 -3
- data/ext/behavior_machines_native/circuit/CHANGELOG.md +7 -0
- data/ext/behavior_machines_native/circuit/Cargo.toml +1 -1
- data/ext/behavior_machines_native/circuit/src/lower.rs +24 -16
- data/ext/behavior_machines_native/circuit/src/status.rs +3 -3
- data/ext/behavior_machines_native/core/CHANGELOG.md +7 -0
- data/ext/behavior_machines_native/core/Cargo.toml +1 -1
- data/ext/behavior_machines_native/core/src/observe.rs +8 -1
- data/ext/behavior_machines_native/core/src/step.rs +8 -2
- data/ext/behavior_machines_native/core/src/tree.rs +8 -1
- data/ext/behavior_machines_native/ffi/Cargo.toml +1 -1
- data/lib/behavior_machines/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38d7cc19f70e22ec58a58e07a0c371fbd0a300843e19fb0dbee69094cc6efb68
|
|
4
|
+
data.tar.gz: 7487daf6be135db2e1e26992e54c2214346858adaf5a7ae1a15b9d27f3bff186
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bc6d295f6da306f0b8b4b1e700892197a098c29da53937d2853c0d5cde9a6dd0d57c7ac53357c3c12601b8be6298d4530fe654465f7f880f5ca1a92625ffdf2
|
|
7
|
+
data.tar.gz: f99ca7e7c72327b5c6519428c17a98eb3d019f6063c4f77593cfbe78ff677d822a9a579e51dadcb022527ce423de89eb43e154a0c60e4225326e03eb3a482821
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.8.2](https://github.com/seuros/behavior_machines/compare/behavior_machines/v0.8.1...behavior_machines/v0.8.2) (2026-11-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* lower deep decorator chains without recursing in post_order ([345fb13](https://github.com/seuros/behavior_machines/commit/345fb138420843714ee77b12363a4c64f3341ecb))
|
|
9
|
+
|
|
3
10
|
## [0.8.1](https://github.com/seuros/behavior_machines/compare/behavior_machines/v0.8.0...behavior_machines/v0.8.1) (2026-11-16)
|
|
4
11
|
|
|
5
12
|
|
data/Cargo.lock
CHANGED
|
@@ -13,7 +13,7 @@ dependencies = [
|
|
|
13
13
|
|
|
14
14
|
[[package]]
|
|
15
15
|
name = "behavior-machines"
|
|
16
|
-
version = "0.4.
|
|
16
|
+
version = "0.4.1"
|
|
17
17
|
dependencies = [
|
|
18
18
|
"matryona-machines",
|
|
19
19
|
"state-machines",
|
|
@@ -21,7 +21,7 @@ dependencies = [
|
|
|
21
21
|
|
|
22
22
|
[[package]]
|
|
23
23
|
name = "behavior-machines-circuit"
|
|
24
|
-
version = "0.6.
|
|
24
|
+
version = "0.6.1"
|
|
25
25
|
dependencies = [
|
|
26
26
|
"behavior-machines",
|
|
27
27
|
"matryona-machines",
|
|
@@ -29,7 +29,7 @@ dependencies = [
|
|
|
29
29
|
|
|
30
30
|
[[package]]
|
|
31
31
|
name = "behavior_machines_native"
|
|
32
|
-
version = "0.1.
|
|
32
|
+
version = "0.1.6"
|
|
33
33
|
dependencies = [
|
|
34
34
|
"behavior-machines",
|
|
35
35
|
"magnus",
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.6.1](https://github.com/seuros/behavior_machines/compare/behavior-machines-circuit-v0.6.0...behavior-machines-circuit-v0.6.1) (2026-11-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* lower deep decorator chains without recursing in post_order ([345fb13](https://github.com/seuros/behavior_machines/commit/345fb138420843714ee77b12363a4c64f3341ecb))
|
|
9
|
+
|
|
3
10
|
## [0.6.0](https://github.com/seuros/behavior_machines/compare/behavior-machines-circuit-v0.5.0...behavior-machines-circuit-v0.6.0) (2026-11-16)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
//!
|
|
57
57
|
//! The depth does not grow with the number of children: every prefix test
|
|
58
58
|
//! reads a sum of bits, and a sum is free. Measured, an ordered composite
|
|
59
|
-
//! saturates at depth
|
|
59
|
+
//! saturates at depth 3 reactive and 6 with memory from four children up to
|
|
60
60
|
//! any width, which `lower/tests.rs` pins.
|
|
61
61
|
//!
|
|
62
62
|
//! # Indexing
|
|
@@ -114,6 +114,7 @@ struct Arbitration {
|
|
|
114
114
|
/// Per child: the walk reached it, so it was ticked.
|
|
115
115
|
reach: Vec<Bit>,
|
|
116
116
|
/// Per child: a stop strictly earlier, so a reactive composite halts it.
|
|
117
|
+
/// `NOT clear` for a reactive composite, constant zero for a memory one.
|
|
117
118
|
after_stop: Vec<Bit>,
|
|
118
119
|
/// The cursor to store for the next tick.
|
|
119
120
|
next_cursor: Affine,
|
|
@@ -244,8 +245,7 @@ impl Lowered {
|
|
|
244
245
|
pub fn new<L>(steps: impl IntoIterator<Item = Step<L>>) -> Result<Self, Refusal> {
|
|
245
246
|
let (flat, leaves, cursors) = flatten(steps, Self::MAX_NODES)?;
|
|
246
247
|
|
|
247
|
-
let
|
|
248
|
-
post_order(&flat, 0, &mut report_order);
|
|
248
|
+
let report_order = post_order(&flat);
|
|
249
249
|
let plan = Plan::new(flat.len(), leaves, cursors, report_order);
|
|
250
250
|
let mut builder = Builder::new(plan.cell_count());
|
|
251
251
|
let (raw, arbitrations) = arbitrate(&flat, &plan, &mut builder)?;
|
|
@@ -259,22 +259,28 @@ impl Lowered {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
///
|
|
262
|
+
/// The tree's nodes in post-order, children first.
|
|
263
263
|
///
|
|
264
264
|
/// This is the order the engine's observer reports nodes in, because
|
|
265
265
|
/// `Slot::tick` reports itself only after ticking its children.
|
|
266
|
+
///
|
|
267
|
+
/// Nesting depth is caller-controlled and the node limit does not bound it,
|
|
268
|
+
/// so this walks with an explicit stack rather than recursing: it visits
|
|
269
|
+
/// root, then children right to left, which is post-order reversed.
|
|
266
270
|
#[expect(clippy::indexing_slicing, reason = "see `# Indexing`")]
|
|
267
|
-
fn post_order(flat: &[Flat]
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
}
|
|
271
|
+
fn post_order(flat: &[Flat]) -> Vec<usize> {
|
|
272
|
+
let mut order = Vec::with_capacity(flat.len());
|
|
273
|
+
let mut pending = vec![0];
|
|
274
|
+
while let Some(index) = pending.pop() {
|
|
275
|
+
order.push(index);
|
|
276
|
+
match &flat[index] {
|
|
277
|
+
Flat::Leaf { .. } | Flat::Constant(_) => {}
|
|
278
|
+
Flat::Map { child, .. } => pending.push(*child),
|
|
279
|
+
Flat::Ordered { children, .. } => pending.extend(children),
|
|
275
280
|
}
|
|
276
281
|
}
|
|
277
|
-
order.
|
|
282
|
+
order.reverse();
|
|
283
|
+
order
|
|
278
284
|
}
|
|
279
285
|
|
|
280
286
|
/// Pass 2: each node's raw status, bottom-up.
|
|
@@ -364,12 +370,14 @@ fn lower_ordered(
|
|
|
364
370
|
// `none_earlier` answers one bit per input, so all three hold one entry
|
|
365
371
|
// per child.
|
|
366
372
|
for ((passed, earlier), stuck) in all_passed.iter().zip(&before).zip(&blocked) {
|
|
367
|
-
//
|
|
368
|
-
//
|
|
373
|
+
// A stop strictly earlier is exactly an earlier blocked child: the
|
|
374
|
+
// first one is where the walk stopped. So the total of earlier stops
|
|
375
|
+
// is `NOT passed`, one shared wire, rather than a sum re-formed over
|
|
376
|
+
// every earlier stop, which made a wide composite cubic to lower.
|
|
369
377
|
after_stop.push(if cursor.is_some() {
|
|
370
378
|
Bit::ZERO
|
|
371
379
|
} else {
|
|
372
|
-
|
|
380
|
+
!passed.clone()
|
|
373
381
|
});
|
|
374
382
|
reach.push(builder.and(passed, &!earlier.clone())?);
|
|
375
383
|
stop.push(builder.and(passed, stuck)?);
|
|
@@ -91,7 +91,7 @@ impl StatusBits {
|
|
|
91
91
|
}
|
|
92
92
|
|
|
93
93
|
/// Swaps success and failure, leaving running alone. Free: the
|
|
94
|
-
/// [`Inverter`](behavior_machines::
|
|
94
|
+
/// [`Inverter`](behavior_machines::Step::Inverter) decorator costs no
|
|
95
95
|
/// operations at all, it relabels two wires.
|
|
96
96
|
#[must_use]
|
|
97
97
|
pub fn inverted(self) -> Self {
|
|
@@ -104,8 +104,8 @@ impl StatusBits {
|
|
|
104
104
|
|
|
105
105
|
/// Reports any finished child as `forced`, leaving running alone. Free.
|
|
106
106
|
///
|
|
107
|
-
/// This is [`ForceSuccess`](behavior_machines::
|
|
108
|
-
/// [`ForceFailure`](behavior_machines::
|
|
107
|
+
/// This is [`ForceSuccess`](behavior_machines::Step::ForceSuccess) and
|
|
108
|
+
/// [`ForceFailure`](behavior_machines::Step::ForceFailure): the two
|
|
109
109
|
/// finished bits merge into one, which is addition of disjoint bits.
|
|
110
110
|
#[must_use]
|
|
111
111
|
pub fn forced(self, forced: Status) -> Self {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.4.1](https://github.com/seuros/behavior_machines/compare/behavior-machines-v0.4.0...behavior-machines-v0.4.1) (2026-11-16)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Bug Fixes
|
|
7
|
+
|
|
8
|
+
* lower deep decorator chains without recursing in post_order ([345fb13](https://github.com/seuros/behavior_machines/commit/345fb138420843714ee77b12363a4c64f3341ecb))
|
|
9
|
+
|
|
3
10
|
## [0.4.0](https://github.com/seuros/behavior_machines/compare/behavior-machines-v0.3.1...behavior-machines-v0.4.0) (2026-11-16)
|
|
4
11
|
|
|
5
12
|
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
use crate::Status;
|
|
2
2
|
|
|
3
3
|
/// Identifies a node within one compiled tree: its position in a depth-first,
|
|
4
|
-
|
|
4
|
+
#[cfg_attr(
|
|
5
|
+
feature = "alloc",
|
|
6
|
+
doc = " pre-order walk of the [`Node`](crate::Node) definition, with the root at 0."
|
|
7
|
+
)]
|
|
8
|
+
#[cfg_attr(
|
|
9
|
+
not(feature = "alloc"),
|
|
10
|
+
doc = " pre-order walk of the `Node` definition, with the root at 0."
|
|
11
|
+
)]
|
|
5
12
|
///
|
|
6
13
|
/// Children are numbered in declaration order: for `IfThenElse` and
|
|
7
14
|
/// `WhileDoElse` that is condition, then the branch it selects on success,
|
|
@@ -29,7 +29,10 @@ pub enum Step<L> {
|
|
|
29
29
|
/// Fails immediately.
|
|
30
30
|
AlwaysFailure,
|
|
31
31
|
/// Runs until the duration has passed since it started, then succeeds.
|
|
32
|
-
/// A zero duration succeeds immediately.
|
|
32
|
+
/// A zero duration succeeds immediately. The deadline is fixed when the
|
|
33
|
+
/// node starts; if the start plus the duration exceeds `Duration::MAX`,
|
|
34
|
+
/// that deadline never fires and the node stays running (the sum is
|
|
35
|
+
/// neither refused nor clamped).
|
|
33
36
|
Sleep(Duration),
|
|
34
37
|
/// Ticks this many children in order. Fails as soon as one fails and
|
|
35
38
|
/// succeeds once all succeed. A running child is resumed on the next
|
|
@@ -79,7 +82,10 @@ pub enum Step<L> {
|
|
|
79
82
|
/// Fails, halting the child, once the duration has passed since this node
|
|
80
83
|
/// started. The child only ticks strictly before the deadline, so a zero
|
|
81
84
|
/// duration fails without ticking it. To run without a limit, leave the
|
|
82
|
-
/// decorator out.
|
|
85
|
+
/// decorator out. The deadline is fixed when the node starts; if the
|
|
86
|
+
/// start plus the duration exceeds `Duration::MAX`, it never fires and the
|
|
87
|
+
/// child is never failed for elapsed time (the sum is neither refused nor
|
|
88
|
+
/// clamped).
|
|
83
89
|
Timeout(Duration),
|
|
84
90
|
/// Runs the child again each time it succeeds, until it has succeeded
|
|
85
91
|
/// `limit` times, then succeeds. Fails as soon as the child fails.
|
|
@@ -42,7 +42,14 @@ pub struct Tree<L, const N: usize> {
|
|
|
42
42
|
|
|
43
43
|
impl<L, const N: usize> Tree<L, N> {
|
|
44
44
|
/// Compiles a definition given as [`Step`]s in pre-order (a
|
|
45
|
-
|
|
45
|
+
#[cfg_attr(
|
|
46
|
+
feature = "alloc",
|
|
47
|
+
doc = " [`Node`](crate::Node) with feature `alloc` is such a sequence)."
|
|
48
|
+
)]
|
|
49
|
+
#[cfg_attr(
|
|
50
|
+
not(feature = "alloc"),
|
|
51
|
+
doc = " `Node` with feature `alloc` is such a sequence)."
|
|
52
|
+
)]
|
|
46
53
|
///
|
|
47
54
|
/// # Errors
|
|
48
55
|
///
|