Talk:Abelian sandpile model: Difference between revisions

Content added Content deleted
mNo edit summary
 
Line 121: Line 121:


Thanks for the information, I have added my code underneath the original.
Thanks for the information, I have added my code underneath the original.

== Incorrect .PPM File created by C code. ==

The current C code uses directly code directly copied from ppm Bitmap Writing page.
This consequently leads to a useless .ppm image created.

The following lines of code need to be replaced:

for(i=0;i<sandPileEdge;i++){
:for(j=0;j<sandPileEdge;j++){
::colour[0] = (sandPile[i][j] + i)%256;
::colour[1] = (sandPile[i][j] + j)%256;
::colour[2] = (sandPile[i][j] + i*j)%256;
:;fwrite(colour,1,3,fp);
:}
}

with these to get an image similar in style to the images on the wikipedia page, however any different combination of RGB values will serve.

for(i=0;i<sandPileEdge;i++){
:for(j=0;j<sandPileEdge;j++){
::if (sandPile[i][j] == 0){
:::colour[0] = 0;
:::colour[1] = 0;
:::colour[2] = 0;
::} else if (sandPile[i][j] == 1){
:::colour[0] = 0;
:::colour[1] = 255;
:::colour[2] = 0;
::} else if (sandPile[i][j] == 2){
:::colour[0] = 255;
:::colour[1] = 0;
:::colour[2] = 255;
::} else if (sandPile[i][j] == 3){
:::colour[0] = 255;
:::colour[1] = 215;
:::colour[2] = 0;
::};
::fwrite(colour,1,3,fp);
:};
};

[[User:BlackHorse|BlackHorse]] ([[User talk:BlackHorse|talk]])