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

No files matched your search

+14 -15
View File
@@ -15,37 +15,39 @@ 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)) {
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)) {
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)) {
if let Some(k) = a.who_in(&(i - 1, j + 1))
&& v
{
match k {
false => {
g.push_in(false, &(i, j));
@@ -56,9 +58,6 @@ fn step(g: &mut Grid, rez: &(usize, usize)) {
}
}
}
_ => {}
}
}
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());
+3 -3
View File
@@ -38,9 +38,9 @@ impl Render {
}
pub fn frame(&mut self, g: &Grid) -> Result<(), std::io::Error> {
queue!(self.out, MoveTo(0, 0))?;
for i in 0..self.rez.0 {
for j in 0..self.rez.1 {
let r = g.who_in(&(i, j));
for i in 0..self.rez.1 {
for j in 0..self.rez.0 {
let r = g.who_in(&(j, i));
match r {
Some(true) => {
queue!(self.out, Print("፨"))?;