Hi all! I’m trying to build some sort of random maze builder in javascript.
I’ve seen some examples on the web, but all of them are the kind of maze that fills all the area, while what I want to do is two random paths starting from 2 points that go on until they touch.
Something like that:
[URL=http://img580.imageshack.us/i/mymazegrid2.png/][IMG]http://img580.imageshack.us/img580/4606/mymazegrid2.png
Once the two paths have met, the information about flavour will be discharged and everything will look like this:
[URL=http://img811.imageshack.us/i/mymazegrid3.png/][IMG]http://img811.imageshack.us/img811/6213/mymazegrid3.png
The problem is: I’ve come out with two methods to represent each cell, but I don’t know which one is better.
The first one is to represent the cell like this:
[CODE]
function matrix_map_cell() {
this.connected_to = 0;
this.flavour = 0;
/* DIRECTIONS CAN BE:
* 1 2 3 4 5
* N E NE S NS
*
* 6 7 8 9 10
* SE NSE W NW EW
*
* 11 12 13 14 15
* NEW SW NSW SEW NESW
*/
}
While the second method is as follows:
[CODE]
function matrix_map_cell() {
this.NORTH = FALSE;
this.SOUTH = FALSE;
this.EAST = FALSE;
this.WEST = FALSE;
this.flavour = 0;
}
Which way is the best one to represents cell’s connection with adjacent cells? I think the first one uses less memory (using just 1 variable to store directions), but it needs more cpu for being handled (a recursive function is in order to check which directions this cell is connected to), while the second one has opposite behaviour.
Is that true?