Wolfram Rnd 1D cellular automata - 640x480 vga - with random rules
Dependencies: fastlib mbed vga640x480g
Revision 0:ba3520f6dbce, committed 2012-03-04
- Comitter:
- JLS
- Date:
- Sun Mar 04 13:07:21 2012 +0000
- Commit message:
Changed in this revision
diff -r 000000000000 -r ba3520f6dbce fastlib.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fastlib.lib Sun Mar 04 13:07:21 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/Ivop/code/fastlib/#bc492a93e116
diff -r 000000000000 -r ba3520f6dbce main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Mar 04 13:07:21 2012 +0000 @@ -0,0 +1,66 @@ +#include "mbed.h" +#include "vga640x480g.h" + +void DisplayState(int s[],int len, int row); + +int main() { + + init_vga(); + vga_cls(); + + + while(1) { + + int iteration = 479; + int lenght = 639; + int row = 0; + int state[lenght]; + int newstate[lenght]; + int i,j,k; + int rules[8] = {rand()%2,rand()%2,rand()%2,rand()%2,rand()%2,rand()%2,rand()%2,rand()%2}; + + wait (0.5); + + vga_cls(); + + for (i=0;i<lenght;i++) + + state[i]= int (rand()%2); + + for (i=0;i<iteration;i++) { + + for (j=0;j<lenght;j++) newstate[j] = 0; + + for (j=0;j<lenght;j++) { + + k = 4*state[(j-1+lenght)%lenght] + 2*state[j] + state[(j+1)%lenght]; + newstate[j] = rules[k]; + } + + for (j=0;j<lenght;j++) state[j] = newstate[j]; + + DisplayState(state,lenght,row); + row = row + 1; + if (row == 480) row = 0; + } + + } + + } + + +void DisplayState(int s[],int len, int row) +{ + int i; + + for (i=0;i<len;i++) { + + if (s[i] == 1){ + vga_plot(i,row,WHITE); + } + + else{ + vga_plot(i,row,BLACK); + } + } +} \ No newline at end of file
diff -r 000000000000 -r ba3520f6dbce mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Mar 04 13:07:21 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
diff -r 000000000000 -r ba3520f6dbce vga640x480g.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vga640x480g.lib Sun Mar 04 13:07:21 2012 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/gertk/code/vga640x480g/#821e34a87609