18 Commits

Author SHA1 Message Date
Aryadev Chavali
a635d19cfa +LICENSE 2023-08-28 19:58:21 +01:00
Aryadev Chavali
0965b02fed (main)+comments 2023-08-27 22:10:05 +01:00
Aryadev Chavali
65bb0e0f66 (main)+kill threads when avalanche has completed
After the so-called "avalanche", where the fractal has finished
forming as there are no more candidates for toppling, we no longer
need the threads to be working.  As an intensive operation, it makes
no sense to continue processing when we are sure there is no further
dynamic behaviour possible.

Using a tick based solution, every DELTA ticks we check if the
avalanche is completed.  If so, we clean up all the threads AND ensure
that we no longer need to be checking for avalanches.
2023-08-27 22:06:44 +01:00
Aryadev Chavali
2d11304ab4 ~file-handler->files,(main~>files)~migrated png save code to files.c 2023-08-27 21:53:28 +01:00
Aryadev Chavali
026aa887f9 +further multithreading
I split the grid into 4 quadrants which are managed by their own
thread.  Improves speed and uses more resources correctly.
2023-08-26 00:51:17 +01:00
Aryadev Chavali
1bc283b195 +write to image support
Writes output to "data.png"
2023-08-26 00:50:08 +01:00
Aryadev Chavali
0a5d5fc87c ~modified step,~state data is now unsigned 64 bit integer
Stopped adding a grain of sand per step.

Collapsing should work properly for any amount of sand grains,
regardless of whether it's 4 or 4000.  Previous code fixed it at 4
always, and how it distributed was so as well.  Now we distribute as
much sand as we can.

This comes from the idea that, instead of incrementing while
rendering, let's just set some n pixels in the centre and see how the
model distributes them.
2023-08-25 22:57:33 +01:00
Aryadev Chavali
21c03264e6 (main|file-handler)~fixed some stuff
Big bug with file handler: I can write data well, but reading it
causes some trace error which I cannot be bothered to fix.  So I'll
just work on making the step function way more efficient.
2023-08-25 20:03:23 +01:00
Aryadev Chavali
58970e8a68 (file-handler)+implemented write_to_file
First line is the data width, then the sand particles of each cell per
row.
2023-08-25 19:19:50 +01:00
Aryadev Chavali
f155f0e088 (file-handler)+impl file for file handling
In particular I've implemented a standardised complete FILE * reader
without relying on fseek (which may not work for pipes).
2023-08-25 19:08:32 +01:00
Aryadev Chavali
64f8df2592 (main~>lib.h)+header for data structures,~migrate lib.h
+some file handlers for writing and reading (may help with very large
renders by doing them piecemeal when I can)
2023-08-25 19:07:24 +01:00
Aryadev Chavali
62647556fa (main)+threading for steps
Doing this experiment with threads shows a strong improvement in
render speed by separating "steps" from the direct render.
2023-08-25 18:59:03 +01:00
Aryadev Chavali
985a883fda (main)~fixed bug with zooming out too far
Stopped presenting the simulation after a while.
2023-08-25 18:54:44 +01:00
Aryadev Chavali
9524e7ade9 (main)+zoom in and out by keyboard,+translation by mouse 2023-08-25 18:52:11 +01:00
Aryadev Chavali
32934c0c1a (main)+camera
This will be useful for zooming in.
2023-08-25 18:52:00 +01:00
Aryadev Chavali
08bca7b68e (main)+colouring for differing sandpile proportions
Based on Wikipedia page colouring.
2023-08-25 18:44:28 +01:00
Aryadev Chavali
e6fc32ef08 (main)+state data structure and iteration logic
Per iteration, increment the centre of the grid, and perform any
collapsing necessary (if >= 4 then sand pile "collapses" onto its
cardinal directions).
2023-08-25 18:42:49 +01:00
Aryadev Chavali
0d25b2b78e INITIAL
Simple hello world in raylib, with a Makefile to do the compilation
for me!
2023-08-25 18:24:31 +01:00