Divooka Reference

Grids

12 nodes

On this page 12

Count Cells

Function

How many cells hold a value.

Signature
CountCells(grid: Value Grid, value: Integer) -> Integer
int CountCells(ValueGrid grid, int value)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
valueInteger—The value.

Returns

CountInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Find Cells

Function

The cells holding a value, row by row from the top.

Signature
FindCells -> (Count: Integer, xs: Integer Array, ys: Integer Array)
    grid: Value Grid
    value: Integer
int FindCells(
    ValueGrid grid,
    int value,
    out int[] xs,
    out int[] ys)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
valueInteger—The value.

Returns

CountInteger
xsInteger Array
ysInteger Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Find Grid Path

Function

The cheapest path between two cells, moving four ways through cells holding the open value; the two ends may hold anything. Steps and turns each cost what they are given, a turn limit can be set, and a margin lets the path run round the outside of the grid. The corners are the start, each turn and the end - enough to draw the path as straight lines - and may lie in the margin.

Signature
FindPath -> (Found: Truth, xs: Integer Array, ys: Integer Array, turns: Integer)
    grid: Value Grid
    fromX: Integer
    fromY: Integer
    toX: Integer
    toY: Integer
    open: Integer
    margin: Integer
    stepCost: Integer
    turnCost: Integer
    maxTurns: Integer
bool FindPath(
    ValueGrid grid,
    int fromX,
    int fromY,
    int toX,
    int toY,
    out int[] xs,
    out int[] ys,
    out int turns,
    int open = 0,
    int margin = 0,
    int stepCost = 1,
    int turnCost = 0,
    int maxTurns = -1)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
fromXInteger—Start column.
fromYInteger—Start row.
toXInteger—End column.
toYInteger—End row.
openInteger0The value of a cell the path may cross.
marginInteger0How many cells beyond each edge the path may use.
stepCostInteger1What each step costs.
turnCostInteger0What each turn costs.
maxTurnsInteger-1The most turns allowed; -1 for no limit.

Returns

FoundTruth
xsInteger Array
ysInteger Array
turnsInteger

Remarks

With the defaults it is the shortest walk. A tile-matching link - straight runs through empty cells with at most two turns, round the outside if need be - is open 0, margin 1, step cost 0, turn cost 1, max turns 2.

Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Grid From Values

Function

A grid holding the given values, row by row from the top.

Signature
FromValues -> Value Grid
    width: Integer
    height: Integer
    values: Integer Array
ValueGrid FromValues(int width, int height, int[] values)

Parameters

nametypedefaultdescription
widthInteger—Cells across.
heightInteger—Cells down.
valuesInteger Array—Width × height of them.

Returns

GridValue Grid
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Get Cell

Function

What a cell holds; the grid's outside value for a cell beyond it.

Signature
GetCell(grid: Value Grid, x: Integer, y: Integer) -> Integer
int GetCell(ValueGrid grid, int x, int y)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
xInteger—Column.
yInteger—Row.

Returns

ValueInteger
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Make Grid

Function

A grid with every cell holding one value.

Signature
Make -> Value Grid
    width: Integer
    height: Integer
    fill: Integer
ValueGrid Make(int width = 8, int height = 8, int fill = 0)

Parameters

nametypedefaultdescription
widthInteger8Cells across.
heightInteger8Cells down.
fillInteger0What every cell holds.

Returns

GridValue Grid
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Pair Neighbouring Cells

Function

As many pairs of side-by-side cells holding a value as can be made with no cell used twice: a tiling by dominoes. The nth pair is (first xs, first ys) and (second xs, second ys) at n.

Signature
PairNeighbours -> (Pairs: Integer, firstXs: Integer Array, firstYs: Integer Array, secondXs: Integer Array, secondYs: Integer Array)
    grid: Value Grid
    value: Integer
    seed: Integer
int PairNeighbours(
    ValueGrid grid,
    int value,
    out int[] firstXs,
    out int[] firstYs,
    out int[] secondXs,
    out int[] secondYs,
    int seed = 0)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
valueInteger—Which cells to pair.
seedInteger0Different seeds give different tilings; 0 gives the same one every time.

Returns

PairsInteger
firstXsInteger Array
firstYsInteger Array
secondXsInteger Array
secondYsInteger Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Grid Region

Function

The cells holding the same value as a starting cell and joined to it four ways: what a paint bucket fills.

Signature
Region -> (Count: Integer, xs: Integer Array, ys: Integer Array)
    grid: Value Grid
    x: Integer
    y: Integer
int Region(
    ValueGrid grid,
    int x,
    int y,
    out int[] xs,
    out int[] ys)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
xInteger—Start column.
yInteger—Start row.

Returns

CountInteger
xsInteger Array
ysInteger Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Set Cell

Function

The grid with one cell holding a new value.

Signature
SetCell -> Value Grid
    grid: Value Grid
    x: Integer
    y: Integer
    value: Integer
ValueGrid SetCell(ValueGrid grid, int x, int y, int value)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
xInteger—Column.
yInteger—Row.
valueInteger—What it holds now.

Returns

GridValue Grid
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Set Cells

Function

The grid with several cells set at once, the nth cell to the nth value - or every cell to the one value when only one is given.

Signature
SetCells -> Value Grid
    grid: Value Grid
    xs: Integer Array
    ys: Integer Array
    values: Integer Array
ValueGrid SetCells(
    ValueGrid grid,
    int[] xs,
    int[] ys,
    int[] values)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
xsInteger Array—Columns.
ysInteger Array—Rows, as many as columns.
valuesInteger Array—One value for all, or one for each cell.

Returns

GridValue Grid
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Shuffle Grid Cells

Function

The grid with what its cells hold shuffled among them, leaving every cell that holds the kept value where it is.

Signature
ShuffleCells -> Value Grid
    grid: Value Grid
    keep: Integer
    seed: Integer
ValueGrid ShuffleCells(
    ValueGrid grid,
    int keep = 0,
    int seed = 1)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.
keepInteger0The value that stays put; 0 keeps the empty cells empty.
seedInteger1The same seed shuffles the same way.

Returns

GridValue Grid
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine

Grid Values

Function

Every cell's value, row by row from the top.

Signature
Values(grid: Value Grid) -> Integer Array
int[] Values(ValueGrid grid)

Parameters

nametypedefaultdescription
gridValue Grid—The grid.

Returns

ValuesInteger Array
Ships with
Divooka ExploreDivooka Compute
Graph kinds
Flows Function Events Routine Constructs StateMachineState
Declared by
Grids
Package
Crime Engine