Fix: off-by-one error in alignment averaging

The "length" is actually the `enumerate()` index, which is one less than
the item count. The previous version was not using the average, and may
have been deviding by 0 for boids with exactly one neighbor.
This commit is contained in:
2025-09-03 14:09:40 -05:00
parent 76a6b4f999
commit bc0630b4ae

View File

@@ -251,7 +251,7 @@ fn alignment(
// Skip to next boid if the current one has no neighbors.
let avg = if len > 0 {
sum / (len as f32)
sum / ((len + 1) as f32)
} else {
continue;
};