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)) {
match k {
true => {
let v = rng.gen_range(0..=3);
match v {
0 => {
if let Some(k) = a.who_in(&(i, j + 1)) {
match k {
false => {
g.push_in(false, &(i, j));
g.push_in(true, &(i, j + 1));
}
true => {}
}
let mut v = true;
if let Some(k) = a.who_in(&(i, j + 1))
&& v
{
match k {
false => {
g.push_in(false, &(i, j));
g.push_in(true, &(i, j + 1));
v = false;
}
true => {}
}
}
1 => {
if (i + 1) < rez.0 {
if let Some(k) = a.who_in(&(i + 1, j + 1)) {
match k {
false => {
g.push_in(false, &(i, j));
g.push_in(true, &(i + 1, j + 1));
}
true => {}
}
if (i + 1) < rez.0 {
if let Some(k) = a.who_in(&(i + 1, j + 1))
&& v
{
match k {
false => {
g.push_in(false, &(i, j));
g.push_in(true, &(i + 1, j + 1));
v = false;
}
true => {}
}
}
}
3 => {
if i != 0 {
if let Some(k) = a.who_in(&(i - 1, j + 1)) {
match k {
false => {
g.push_in(false, &(i, j));
g.push_in(true, &(i - 1, j + 1));
}
true => {}
}
if i != 0 {
if let Some(k) = a.who_in(&(i - 1, j + 1))
&& v
{
match k {
false => {
g.push_in(false, &(i, j));
g.push_in(true, &(i - 1, j + 1));
}
true => {}
}
}
_ => {}
}
}
false => {}
@@ -76,7 +75,7 @@ fn main() {
_ = r.clear();
_ = r.print("Hello sand!");
//_ = r.frame();
let rez: (usize, usize) = (40, 80);
let rez: (usize, usize) = (80, 40);
_ = r.resize(&rez);
let mut space = Grid::init(&rez);
//space.rand();
@@ -86,7 +85,7 @@ fn main() {
space.push_in(true, &(rez.0 / 2, 0));
match it {
InputType::comand => {
_ = r.print("print comand:");
_ = r.print("input comand:");
let input = Comand_pars();
if input.is_err() {
_ = r.print(&input.err().unwrap());