- commit
- 0c1cb9e63b28a3fed4722c3340eb13cf97889503
- parent
- 5658dccc44a9d60cfdc2d3e75311aa73eddac4e0
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2022-02-07 16:31
fix off-by-one at end
Diffstat
| M | flood.rs | 8 | +++++--- |
1 files changed, 5 insertions, 3 deletions
diff --git a/flood.rs b/flood.rs
@@ -124,7 +124,7 @@ fn play(seed: u64) -> bool {
124 124 map[i] = rng.gen_range(0, 6);
125 125 }
126 126
127 -1 for step in 0..STEPS {
-1 127 for step in 0..=STEPS {
128 128 // clear screen and move cursor to top left
129 129 print!("\x1b[2J\x1b[H");
130 130 render_status(step);
@@ -133,8 +133,10 @@ fn play(seed: u64) -> bool {
133 133 if map.iter().all(|x| *x == map[0]) {
134 134 return true;
135 135 }
136 -1 let new = input_num("> ", 1, 7) - 1;
137 -1 flood(&mut map, new);
-1 136 if step < STEPS {
-1 137 let new = input_num("> ", 1, 7) - 1;
-1 138 flood(&mut map, new);
-1 139 }
138 140 }
139 141 return false;
140 142 }