1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
use crateCalcError;
/// Exposes information which is used to calculate interactions between cells and the domain.
/// Trait describing force-interactions between cellular agents.
/// Allows reacting to multiple neighbors
///
/// Information of neighbors is first accumulated via the [NeighborSensing::accumulate_information]
/// function and finally, the cell reacts to the gathered data via the
/// [NeighborSensing::react_to_neighbors] function.
/// Finally, the accumulator is cleared with [NeighborSensing::clear_accumulator].
///
/// ## Neighbor Counting
/// ```
/// use cellular_raza_concepts::*;
///
/// struct Cell {/* .. */};
///
/// impl<Pos, Inf> NeighborSensing<Pos, usize, Inf> for Cell
/// where
/// Cell: InteractionInformation<Inf>,
/// {
/// fn accumulate_information(
/// &self,
/// _: &Pos,
/// _: &Pos,
/// _: &Inf,
/// neighbors: &mut usize
/// ) -> Result<(), CalcError> {
/// Ok(*neighbors += 1)
/// }
///
/// fn react_to_neighbors(&mut self, neighbors: &usize) -> Result<(), CalcError> {
/// /* .. */
/// Ok(())
/// }
///
/// fn clear_accumulator(neighbors: &mut usize) {
/// *neighbors = 0;
/// }
/// }
///
/// ```