Returns a generator that iterates over cells with a given logic. Once created, the same logic can be used on different grids - it is a pure function.
const v = create(`random`); // Randomly visit cellsfor (const cell of v(grid)) { // do something with cell} Copy
const v = create(`random`); // Randomly visit cellsfor (const cell of v(grid)) { // do something with cell}
Logic types: 'row': left-to-right, top-to-bottom 'column': top-to-bottom, left-to-right 'neighbours': neighbours surrounding cell (eight) 'breadth': breadth-first 'depth': depth-first 'random': any random cell in grid 'random-contiguous': any random cell neighbouring an already visited cell
Under the hood it uses createWithLogic, but lets you specify the logic with a simple string.
Returns a generator that iterates over cells with a given logic. Once created, the same logic can be used on different grids - it is a pure function.
Logic types: 'row': left-to-right, top-to-bottom 'column': top-to-bottom, left-to-right 'neighbours': neighbours surrounding cell (eight) 'breadth': breadth-first 'depth': depth-first 'random': any random cell in grid 'random-contiguous': any random cell neighbouring an already visited cell
Under the hood it uses createWithLogic, but lets you specify the logic with a simple string.