Flaky collisision detection test
What happened?
CollisionType [Sweep] correct collisions with many involved collidables (failed)
Expected: true
Actual: <false>
package:matcher expect
test/collisions/collision_type_test.dart 193:9 main.<fn>.<fn>
It is using seeds for everything, but somehow it gets different results between different runs. This happens for both broadphases.
What do you expect?
The test to always pass.
How can we reproduce this?
Run it in the CI a few times.
What steps should take to fix this?
No response
Do have an example of where the bug occurs?
No response
Relevant log output
No response
Execute in a terminal and put output into the code block below
Output of: flutter doctor -v
Affected platforms
All
Other information
No response
Are you interested in working on a PR for this?
- [ ] I want to work on this
What if we sorted the list of collidables by a stable value, like an ID or initial position, before adding them to the world in the test? This would ensure they are processed in the same order every run, which might reduce the non-determinism caused by subtle differences in the order of floating-point operations.
Additionally, using a fixed timestep, such as 1/60.0, for the game.update(dt) calls within the test loop could ensure consistency in time-dependent calculations and make the simulation results more predictable.
@0disoft did you look at the test before commenting? 😉 It's not dependent on a varying time step, it's using dt as 0 everywhere. And it is generating the component lists with a seed, so they should always be the same.