Learning Rust with falling sand
  • Rust 97.3%
  • Shell 2.7%
Find a file
2024-06-16 19:54:15 +02:00
.github/workflows Rename CI build workflow 2024-04-27 17:04:58 +02:00
doc Improve readme, add scripts 2024-06-16 17:01:01 +02:00
scripts Improve readme, add scripts 2024-06-16 17:01:01 +02:00
src Improve readme, add scripts 2024-06-16 17:01:01 +02:00
.gitignore Add expect tests 2024-06-13 15:55:39 +02:00
Cargo.toml Add expect tests 2024-06-13 15:55:39 +02:00
LICENSE init 2024-04-26 12:26:43 +02:00
package-lock.json Multithreading working with one thread!! Massive news!! 2024-06-06 15:43:03 +02:00
README.md Correct grammar 2024-06-16 19:54:15 +02:00
rustfmt.toml Refactor to appease the borrow checker 2024-06-04 22:04:35 +02:00

Sable

Basic falling sand simulation. Sand grains fall according to three simple rules:

  1. If the space below a grain is empty, fall straight down.

  2. Otherwise, if the space below and left is empty, fall there. Otherwise, do the same for below and right. The priority between left and right can be randomly chosen.

  3. Otherwise, remain in place.

Running

The simulation can either run in real-time in a window, or as a one-shot. For the latter, this can either produce a BMP image, or write the final values to the terminal.

(In the examples below, custom flags are used but not shown. They can be inspected using the --help flag.)

$ sable realtime

BMP image

$ sable bmp

BMP image

$ sable terminal
0    4    4    4    3
4    4    3    2    2
3    3    2    2    1
2    1    1    1    1