|
Author |
Topic: Sand Piles (Read 1605 times) |
|
Jerronimo
|
Sand Piles
« on: Sep 7th, 2003, 6:22pm » |
|
I was just experimenting with a few homebrew sand pile settling algorithms, and threw it together in this sketch: http://www.cis.rit.edu/~sdlpci/Software/p5/sandtoy I tried two different sand settling algorithms, one which seems to behave like water, and one like sand. (blue/orange buttons) If you raise the max number of granules up, it will slow down significantly, so i kept it at a reasonably low amount. I think I'm going to try it again, but using a Cellular Automata instead of simulating each individual granule. (also with larger grains of sand.)
|
|
|
|
Koenie
|
Re: Sand Piles
« Reply #1 on: Sep 7th, 2003, 8:48pm » |
|
This is pretty cool! I like the way it falls on the little platform and forms both piles on and under the platform. And yes, simulating each individual granule isn't really smart Koenie
|
http://koeniedesign.com
|
|
|
Jerronimo
|
Re: Sand Piles
« Reply #2 on: Sep 8th, 2003, 12:32am » |
|
> And yes, simulating each individual granule isn't really smart That's what I love about Processing. It's really quick for a programmer to come to that realization. I didn't have to spend a few days to get up the infrastructure to run my simulation on. I pretty much knew in less than an hour that this strategy wouldn't work. Version 2 is in progress right now.
|
|
|
|
Jerronimo
|
Re: Sand Piles
« Reply #4 on: Oct 23rd, 2003, 11:07pm » |
|
Damn. that's pretty simple. What are the basic rules you used for the CA?
|
|
|
|
benelek
|
Re: Sand Piles
« Reply #5 on: Oct 24th, 2003, 12:39am » |
|
the code is so nice n simple... this really reminds me of the good ol' days when a band of marching lemmings could just keep on marching...
|
|
|
|
Koenie
|
Re: Sand Piles
« Reply #6 on: Oct 24th, 2003, 5:11pm » |
|
benelek: thanks jerronimo: every cell only looks at the 3 cells beneath it. if the one right beneath is free, it moves there. otherwise it will just look and pick one of the others, or just stay where it is, when everything's full. Koenie
|
http://koeniedesign.com
|
|
|
Jerronimo
|
Re: Sand Piles
« Reply #7 on: Oct 27th, 2003, 6:28am » |
|
sweet. I just modified your example to be snow instead. click to drain the screen. Code: int[][] world; void setup() { size(200, 200); world = new int[width][height]; } void loop() { for( int i=0 ; i<20 ; i++ ) world[constrain((int)random(width), 1, width-2)][constrain((int)random(20), 0, height-2)] = 1; if( mousePressed) for( int i=0 ; i<width ; i++ ) world[i][height-1] = 0; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { pixels[j*width+i] = (world[i][j] == 1) ? #FFFFFF : #000000; } } for (int i = 1; i < width-1; i++) { for (int j = height-2; j >= 0; j--) { if (world[i][j] == 1) { if (world[i][j+1] == 0) {world[i][j+1] = 1; world[i][j] = 0;} else if (world[i-1][j+1] == 0) {world[i-1][j+1] = 1; world[i][j] = 0;} else if (world[i+1][j+1] == 0) {world[i+1][j+1] = 1; world[i][j] = 0;} } } } } |
|
|
|
|
|
Koenie
|
Re: Sand Piles
« Reply #8 on: Oct 27th, 2003, 6:42pm » |
|
Very nice jerronimo. I think you can get a lot of different effects with my little piece of code... Koenie (btw, jerronimo, did you post my piece in exhibition?)
|
http://koeniedesign.com
|
|
|
REAS
|
Re: Sand Piles
« Reply #9 on: Oct 27th, 2003, 7:46pm » |
|
I did, Koenie. It's a great piece.
|
|
|
|
benelek
|
Re: Sand Piles
« Reply #11 on: Oct 27th, 2003, 11:16pm » |
|
wow, this really shows how the simplest code can be adapted/extended to make great effects. this "ageing" modification is starting to bring up memories of earth layering in geography.
|
|
|
|
|