15.01.2013, 05:13
you maze problem got my attention, too.
at first reading the init_maze snippet, i found a little enhancement already - your code:
1 of 2 comparements for checking if the line or row is even, are redundant, and can be transformed into a slightly faster version. i know, initialising a little labyrinth of just 30*30 cells doesnt take time anyways, but optimisations ARE are using better algorithms...
...not tested btw.
at first reading the init_maze snippet, i found a little enhancement already - your code:
Код:
init_maze(maze[MAX][MAX]) { for(new a = 0; a < MAX; a++) { for(new b = 0; b < MAX; b++) { if(a % 2 == 0 || b % 2 == 0) { maze[a][b] = 1; } else { maze[a][b] = PATH; } } } return 1; }
Код:
init_maze(maze[MAX][MAX]) { for(new a = 0; a < MAX; a+=2) { for(new b = 0; b < MAX; b+=2) { maze[a][b]=(a+b==0)?PATH:WALL; } } return 1; }