Welcome to the Rockbox Technical Forums!
We just had cellular automatons and the Game of Life in a CS class, and as I'm trying to learn C and just installed Rockbox on my iAudio, this is the ideal little task for me But don't expect anything fancy soon. I hacked up a console version of the game this afternoon and will port it to the X5 today or tomorrow, with a randomly filled world to begin with (editing and the like will come much later ).BTW: how big do you think a cell should be? With the limited resolution of our players, 2x2 pixels is IMHO the most we can get without making the world to small...
#define XDIM LCD_WIDTH / 2#define YDIM LCD_HEIGHT / 2static bool last_gen[YDIM + 4][XDIM + 4];static bool this_gen[YDIM + 4][XDIM + 4];....void step(void){ int i, j; for(i = 1; i < (XDIM + 2); i++){ for (j = 1; j < (YDIM + 2); j++){ int n = count_neighbours(i, j); if ((last_gen[j][i] == false) && (n == 3)){ this_gen[j][i] = true; }else if((last_gen[j][i] == true) && ((n < 2) || (n > 3))){ this_gen[j][i] = false; } } } for(i = 0; i < (XDIM + 4); i++){ for (j = 0; j < (YDIM + 4); j++){ last_gen[j][i] = this_gen[j][i]; } }}
enum plugin_status plugin_start(struct plugin_api* api, void* parameter){ (void)parameter; rb = api; init_world(); display(); rb->sleep(5*HZ); int i; for (i = 0; i < 5; i++){ step(); display(); rb->sleep(HZ); } return PLUGIN_OK;}
Use the power button to exit.
010001111
A game of life program I wrote (a long long time ago) had a border problem when reading files. Check for that. Anythign on the border of the file I read wouldn't give birth off the border on the first iteration. So your glider wouldn't create the dot below the bottom line, killing it.Just a guess, may not be right.
0000000100000100111000000
#elif (CONFIG_KEYPAD == IAUDIO_X5_PAD)#define GOL_UP BUTTON_UP#define GOL_DOWN BUTTON_DOWN#define GOL_RIGHT BUTTON_RIGHT#define GOL_LEFT BUTTON_LEFT#define GOL_QUIT BUTTON_POWER#define GOL_PLAY BUTTON_PLAY#define GOL_SELECT BUTTON_SELECT
Page created in 0.12 seconds with 14 queries.