Support and General Use > Plugins/Viewers

Game of Life

<< < (2/6) > >>

piquadrat:
linuxstb: yeah, I already stumbled upon LCD_WIDTH and LCD_HEIGHT which come in handy


EDIT: Problem solved. "step" wasn't the luckiest choice for a function name since it seems to colide with another member... :) ignore anything below this line:

----------------------------------------------------------------

on a related note, I have a little problem "porting" my console-code. Following function works without a hitch on my computer, but causes a crash in the simulator:


--- Code: ---#define XDIM LCD_WIDTH / 2
#define YDIM LCD_HEIGHT / 2

static 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];
}
}
}
--- End code ---

Is there any code in there that Rockbox doesn't like? I'm quite sure it isn't an "array index out of bounds" problem. I changed the bounds well into the array size and it still crashes. The error message from the simulator is here.

EDIT: after further investigation, I found out that replacing the function call with the function itself "solves" the problem - but looks ugly, of course. Here's my main function. Something wrong with the "step();" function call?


--- Code: ---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;
}
--- End code ---

piquadrat:
OK, here's a prelimenary version of the plugin. It just fills 40% of the screen randomly with cells and starts. So no glider guns yet ;) Use the power button to exit.

BTW, is there a way to set the color of lcd_fillrect? I'd like to use colors to show the age of a particular cell.

[attachment deleted by admin, too old]

Noxneo:
I was thinking recently about coding this.

Well, I'll let piquadrat do the thing ;)

I'm gonna check your plugin, I'll give feedback later.

mightybrick:

--- Quote from: piquadrat on December 19, 2006, 11:59:12 AM --- Use the power button to exit.

--- End quote ---
What about players without a dedicated power button, such as the iPods?

piquadrat:
mightybrick: ok, I copied the button definitions from the sokoban plugin. But don't ask me what "BUTTON_SELECT | BUTTON_MENU" means :D "Up" and "Down" ("Menu" and "Play" for the iPod) now adjust simulation speed.

In the meantime, I wrote a reader for world-files like this (a glider):

--- Code: ---010
001
111
--- End code ---

Unfortunately, the glider dies instead of, well, gliding. Randomly appearing gliders behave like they should, so I'm pretty clueless...

[attachment deleted by admin, too old]

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version