summaryrefslogtreecommitdiffstats
path: root/CLI/rust/src/game_of_life/simulation/universe.rs
diff options
context:
space:
mode:
authora14m <[email protected]>2021-04-08 00:49:28 +0200
committera14m <[email protected]>2021-04-08 00:49:28 +0200
commit7c3b1bd867271ecbae8f0e84b36835b4e6f8021e (patch)
tree2e36073da1e094a3c6e0a1ed0e74c774e520676d /CLI/rust/src/game_of_life/simulation/universe.rs
parentd906586bf36638b220ab1a2849a9482393779e1e (diff)
Fix indexing the correct vec
Due to most test using square planes it didn't have much effect till debugging Display trait cropped printing. The effect of this bug was that the universe was cropped to match the height length but calculations were not wrong, just cropped
Diffstat (limited to 'CLI/rust/src/game_of_life/simulation/universe.rs')
-rw-r--r--CLI/rust/src/game_of_life/simulation/universe.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/CLI/rust/src/game_of_life/simulation/universe.rs b/CLI/rust/src/game_of_life/simulation/universe.rs
index dab1915..6059dc6 100644
--- a/CLI/rust/src/game_of_life/simulation/universe.rs
+++ b/CLI/rust/src/game_of_life/simulation/universe.rs
@@ -82,7 +82,7 @@ mod display {
impl Index<isize> for Universe {
type Output = Plane<bool>;
fn index(&self, idx: isize) -> &Plane<bool> {
- let len = self.current.0.len() as isize;
+ let len = self.current.len() as isize;
&self.current[circular_index(idx, len) as isize]
}
}
@@ -170,7 +170,7 @@ impl Universe {
/// set the current state to the next future generation
pub(crate) fn evolve(mut self) -> Self {
for row in 0..self.current.len() {
- for col in 0..self.current.0.len() as isize {
+ for col in 0..self.current[row].len() as isize {
let living_neighbors = self
.neighbors(row, col)
.iter()