summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTanner Robison <[email protected]>2026-07-13 06:31:09 +0000
committerTanner Robison <[email protected]>2026-07-13 06:32:12 +0000
commitf139bf96eb735a584c013f61f2d1922e20677da2 (patch)
tree217ddf9a43c330334cf774166d182770fef83c7d
parent4ae19b36b9b63557b38836fcbc25a3bca2b8c428 (diff)
Smoother rendering
got smoother rendering by only rendering every 10k time steps or something like that
-rw-r--r--README.md3
-rwxr-xr-xabellian_sandpilebin16088 -> 16088 bytes
-rw-r--r--abellian_sandpile.c19
3 files changed, 14 insertions, 8 deletions
diff --git a/README.md b/README.md
index 31fdbd4..94e116a 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,4 @@
# Abelian Sandpile model
+
+Highly recommend to lower font size for the simulation, But keep in mind the lower
+the font size the longer it takes to see results
diff --git a/abellian_sandpile b/abellian_sandpile
index 88df3e2..592bc2e 100755
--- a/abellian_sandpile
+++ b/abellian_sandpile
Binary files differ
diff --git a/abellian_sandpile.c b/abellian_sandpile.c
index 3117b0d..5293cae 100644
--- a/abellian_sandpile.c
+++ b/abellian_sandpile.c
@@ -60,12 +60,15 @@ int main() {
fprintf(stderr, "Failed to initialize grid");
}
- uint32_t time_steps = 20000000;
+ uint32_t time_steps = 4000000000; //4 billion time steps
for (int i = 0; i < time_steps; i++) {
// drop a 'grain' of sand of top of sandpile
- positions[10][60] += 1;
- get_new_positions(terminal_height, terminal_width, positions,
- new_positions);
+ for (int j = 0; j < 100000; j++) {
+ positions[terminal_height / 2][terminal_width / 2] += 1;
+ get_new_positions(terminal_height, terminal_width, positions,
+ new_positions);
+ }
+ printf("time step: %u", (unsigned int)time_steps);
printf(CLEAR_GRID);
render(terminal_height, terminal_width, positions, new_positions);
}
@@ -120,13 +123,13 @@ int render(int height, int width, int (*positions)[width],
if (new_positions[i][j] == 0) {
printf(" "); // Empty cell
} else if (new_positions[i][j] == 1) {
- printf(COLOR_WHITE "."); // Cell with value 1
+ printf(COLOR_WHITE "o"); // Cell with value 1
} else if (new_positions[i][j] == 2) {
- printf(COLOR_YELLOW "o"); // Cell with value 2
+ printf(COLOR_YELLOW "0"); // Cell with value 2
} else if (new_positions[i][j] == 3) {
- printf(COLOR_ORANGE "0"); // Cell with value 3
+ printf(COLOR_ORANGE "@"); // Cell with value 3
} else if (new_positions[i][j] >= 4) {
- printf(COLOR_RED "4"); // Cell with value 4 or more
+ printf(COLOR_RED "#"); // Cell with value 4 or more
}
}
printf("\n"); // Move to the next line after each row