homework is completed

This commit is contained in:
lemon-cat committed 2026-05-18 15:54:41 +03:00
1 parent 6ffbfbb7bf
commit f235fdcea6
3 files changed
+68 -20

No files matched your search

+8 -4
View File
@@ -1,5 +1,3 @@
use std::clone;
use rand::Rng;
#[derive(Clone)]
pub struct Grid {
@@ -15,10 +13,16 @@ impl Grid {
}
}
pub fn push_in(&mut self, p: bool, pos: &(usize, usize)) {
if (pos.1 * self.rez.0 + pos.0) > (self.rez.0 * self.rez.1) {
return;
}
self.grd[pos.1 * self.rez.0 + pos.0] = p;
}
pub fn who_in(&self, pos: &(usize, usize)) -> bool {
return self.grd[pos.1 * self.rez.0 + pos.0] == true;
pub fn who_in(&self, pos: &(usize, usize)) -> Option<bool> {
if (pos.1 * self.rez.0 + pos.0) > (self.rez.0 * self.rez.1) {
return None;
}
return Some(self.grd[pos.1 * self.rez.0 + pos.0] == true);
}
pub fn rand(&mut self) {
let mut rng = rand::thread_rng();