This commit is contained in:
lemon-cat committed 2026-05-18 16:12:43 +03:00
1 parent f235fdcea6
commit b8a21f579d
2 files changed
+36 -37

No files matched your search

+33 -34
View File
@@ -15,48 +15,47 @@ fn step(g: &mut Grid, rez: &(usize, usize)) {
if let Some(k) = a.who_in(&(i, j)) { if let Some(k) = a.who_in(&(i, j)) {
match k { match k {
true => { true => {
let v = rng.gen_range(0..=3); let mut v = true;
match v { if let Some(k) = a.who_in(&(i, j + 1))
0 => { && v
if let Some(k) = a.who_in(&(i, j + 1)) { {
match k { match k {
false => { false => {
g.push_in(false, &(i, j)); g.push_in(false, &(i, j));
g.push_in(true, &(i, j + 1)); g.push_in(true, &(i, j + 1));
} v = false;
true => {}
}
} }
true => {}
} }
}
1 => { if (i + 1) < rez.0 {
if (i + 1) < rez.0 { if let Some(k) = a.who_in(&(i + 1, j + 1))
if let Some(k) = a.who_in(&(i + 1, j + 1)) { && v
match k { {
false => { match k {
g.push_in(false, &(i, j)); false => {
g.push_in(true, &(i + 1, j + 1)); g.push_in(false, &(i, j));
} g.push_in(true, &(i + 1, j + 1));
true => {} v = false;
}
} }
true => {}
} }
} }
}
3 => { if i != 0 {
if i != 0 { if let Some(k) = a.who_in(&(i - 1, j + 1))
if let Some(k) = a.who_in(&(i - 1, j + 1)) { && v
match k { {
false => { match k {
g.push_in(false, &(i, j)); false => {
g.push_in(true, &(i - 1, j + 1)); g.push_in(false, &(i, j));
} g.push_in(true, &(i - 1, j + 1));
true => {}
}
} }
true => {}
} }
} }
_ => {}
} }
} }
false => {} false => {}
@@ -76,7 +75,7 @@ fn main() {
_ = r.clear(); _ = r.clear();
_ = r.print("Hello sand!"); _ = r.print("Hello sand!");
//_ = r.frame(); //_ = r.frame();
let rez: (usize, usize) = (40, 80); let rez: (usize, usize) = (80, 40);
_ = r.resize(&rez); _ = r.resize(&rez);
let mut space = Grid::init(&rez); let mut space = Grid::init(&rez);
//space.rand(); //space.rand();
@@ -86,7 +85,7 @@ fn main() {
space.push_in(true, &(rez.0 / 2, 0)); space.push_in(true, &(rez.0 / 2, 0));
match it { match it {
InputType::comand => { InputType::comand => {
_ = r.print("print comand:"); _ = r.print("input comand:");
let input = Comand_pars(); let input = Comand_pars();
if input.is_err() { if input.is_err() {
_ = r.print(&input.err().unwrap()); _ = r.print(&input.err().unwrap());
+3 -3
View File
@@ -38,9 +38,9 @@ impl Render {
} }
pub fn frame(&mut self, g: &Grid) -> Result<(), std::io::Error> { pub fn frame(&mut self, g: &Grid) -> Result<(), std::io::Error> {
queue!(self.out, MoveTo(0, 0))?; queue!(self.out, MoveTo(0, 0))?;
for i in 0..self.rez.0 { for i in 0..self.rez.1 {
for j in 0..self.rez.1 { for j in 0..self.rez.0 {
let r = g.who_in(&(i, j)); let r = g.who_in(&(j, i));
match r { match r {
Some(true) => { Some(true) => {
queue!(self.out, Print("፨"))?; queue!(self.out, Print("፨"))?;