Skip to content

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

Bits:   2 3 4 1 5 6 7 8 Val: 0 0 0 0  0 1 1 0 W:10 H:10 X: Y: 8 1

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

Source

A rectangular board has two size parameters:

  1. width: width of board as number of cells
  2. height: height of board as number of cells

Position

Source

Position of each cell is represented by cartesian coordinates (X and Y values).

Directions

Source

Each cell in a rectangular board utilizes 4 directions as following:

  1. Top (mask: 0b0001 or 1)
  2. Right (mask: 0b0010 or 2)
  3. Bottom (mask: 0b0100 or 4)
  4. Left (mask: 0b1000 or 8)