Weave Board¶
Weave boards are extended from rectangular board with only one function overridden getNeighbours
which can look for next neighbour if immediate neighbour is a passage. The only limitation is that it can only look fore one next neighbour not multiples.
Usage¶
New Board¶
import {newBoard} from 'mazes101/boards/weave';
let board = newBoard({height: 20, width: 20});
newBoard
method takes only one argument:
size
: size of the board
Anatomy¶
In the figure above we have a rectangular board with:
- size parameters
{width: 10, height: 10}
, - a highlighted cell at position
{x: 8, y:1}
- the highlighted cell has value
0000 0111
which means its enabled (hence 0 at 1st bit) and has 3 walls removed top, right, bottom (hence 1 at 6, 7 and 8th bits).
Size Parameters¶
A rectangular board has two size parameters:
width
: width of board as number of cellsheight
: height of board as number of cells
Position¶
Position of each cell is represented by cartesian coordinates (X
and Y
values).
Directions¶
Each cell in a rectangular board utilizes 4 directions as following:
- Top (mask:
0b0001
or1
) - Right (mask:
0b0010
or2
) - Bottom (mask:
0b0100
or4
) - Left (mask:
0b1000
or8
)