blob: 2ee7c0027ac5fb259cc2a19c3a2b3ec0dba01efb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
use rand::RngExt;
use crate::sim::cell_sim::sim::UpdateCtx;
#[inline]
pub fn sim_update(ctx: &mut UpdateCtx) {
// only allow upward movement some of the time to limit movement speed
if ctx.rng.random_range(0.0..1.0) > 0.8 && ctx.candidates_swap(&[(0, -1)]) {
return;
}
// same for each horizontal direction
if ctx.rng.random_range(0.0..1.0) > 0.8
&& ctx.candidates_swap(&[(1 - ctx.seqno_parity as i32 * 2, 0)])
{
return;
}
if ctx.rng.random_range(0.0..1.0) > 0.8
&& ctx.candidates_swap(&[(-1 + ctx.seqno_parity as i32 * 2, 0)])
{}
}
|