Grids
12 nodes
On this page 12
Count Cells
FunctionHow many cells hold a value.
CountCells(grid: Value Grid, value: Integer) -> Integer
int CountCells(ValueGrid grid, int value)
Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| value | Integer | — | The value. |
Returns
| Count | Integer |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Find Cells
FunctionThe cells holding a value, row by row from the top.
FindCells -> (Count: Integer, xs: Integer Array, ys: Integer Array)
grid: Value Grid
value: Integerint FindCells(
ValueGrid grid,
int value,
out int[] xs,
out int[] ys)Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| value | Integer | — | The value. |
Returns
| Count | Integer |
| xs | Integer Array |
| ys | Integer Array |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Find Grid Path
FunctionThe 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.
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: Integerbool 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
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| fromX | Integer | — | Start column. |
| fromY | Integer | — | Start row. |
| toX | Integer | — | End column. |
| toY | Integer | — | End row. |
| open | Integer | 0 | The value of a cell the path may cross. |
| margin | Integer | 0 | How many cells beyond each edge the path may use. |
| stepCost | Integer | 1 | What each step costs. |
| turnCost | Integer | 0 | What each turn costs. |
| maxTurns | Integer | -1 | The most turns allowed; -1 for no limit. |
Returns
| Found | Truth |
| xs | Integer Array |
| ys | Integer Array |
| turns | Integer |
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
FunctionA grid holding the given values, row by row from the top.
FromValues -> Value Grid
width: Integer
height: Integer
values: Integer ArrayValueGrid FromValues(int width, int height, int[] values)
Parameters
| name | type | default | description |
|---|---|---|---|
| width | Integer | — | Cells across. |
| height | Integer | — | Cells down. |
| values | Integer Array | — | Width × height of them. |
Returns
| Grid | Value Grid |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Get Cell
FunctionWhat a cell holds; the grid's outside value for a cell beyond it.
GetCell(grid: Value Grid, x: Integer, y: Integer) -> Integer
int GetCell(ValueGrid grid, int x, int y)
Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| x | Integer | — | Column. |
| y | Integer | — | Row. |
Returns
| Value | Integer |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Make Grid
FunctionA grid with every cell holding one value.
Make -> Value Grid
width: Integer
height: Integer
fill: IntegerValueGrid Make(int width = 8, int height = 8, int fill = 0)
Parameters
| name | type | default | description |
|---|---|---|---|
| width | Integer | 8 | Cells across. |
| height | Integer | 8 | Cells down. |
| fill | Integer | 0 | What every cell holds. |
Returns
| Grid | Value Grid |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Pair Neighbouring Cells
FunctionAs 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.
PairNeighbours -> (Pairs: Integer, firstXs: Integer Array, firstYs: Integer Array, secondXs: Integer Array, secondYs: Integer Array)
grid: Value Grid
value: Integer
seed: Integerint PairNeighbours(
ValueGrid grid,
int value,
out int[] firstXs,
out int[] firstYs,
out int[] secondXs,
out int[] secondYs,
int seed = 0)Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| value | Integer | — | Which cells to pair. |
| seed | Integer | 0 | Different seeds give different tilings; 0 gives the same one every time. |
Returns
| Pairs | Integer |
| firstXs | Integer Array |
| firstYs | Integer Array |
| secondXs | Integer Array |
| secondYs | Integer Array |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Grid Region
FunctionThe cells holding the same value as a starting cell and joined to it four ways: what a paint bucket fills.
Region -> (Count: Integer, xs: Integer Array, ys: Integer Array)
grid: Value Grid
x: Integer
y: Integerint Region(
ValueGrid grid,
int x,
int y,
out int[] xs,
out int[] ys)Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| x | Integer | — | Start column. |
| y | Integer | — | Start row. |
Returns
| Count | Integer |
| xs | Integer Array |
| ys | Integer Array |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Set Cell
FunctionThe grid with one cell holding a new value.
SetCell -> Value Grid
grid: Value Grid
x: Integer
y: Integer
value: IntegerValueGrid SetCell(ValueGrid grid, int x, int y, int value)
Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| x | Integer | — | Column. |
| y | Integer | — | Row. |
| value | Integer | — | What it holds now. |
Returns
| Grid | Value Grid |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Set Cells
FunctionThe 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.
SetCells -> Value Grid
grid: Value Grid
xs: Integer Array
ys: Integer Array
values: Integer ArrayValueGrid SetCells(
ValueGrid grid,
int[] xs,
int[] ys,
int[] values)Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| xs | Integer Array | — | Columns. |
| ys | Integer Array | — | Rows, as many as columns. |
| values | Integer Array | — | One value for all, or one for each cell. |
Returns
| Grid | Value Grid |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Shuffle Grid Cells
FunctionThe grid with what its cells hold shuffled among them, leaving every cell that holds the kept value where it is.
ShuffleCells -> Value Grid
grid: Value Grid
keep: Integer
seed: IntegerValueGrid ShuffleCells(
ValueGrid grid,
int keep = 0,
int seed = 1)Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
| keep | Integer | 0 | The value that stays put; 0 keeps the empty cells empty. |
| seed | Integer | 1 | The same seed shuffles the same way. |
Returns
| Grid | Value Grid |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine
Grid Values
FunctionEvery cell's value, row by row from the top.
Values(grid: Value Grid) -> Integer Array
int[] Values(ValueGrid grid)
Parameters
| name | type | default | description |
|---|---|---|---|
| grid | Value Grid | — | The grid. |
Returns
| Values | Integer Array |
- Ships with
- Divooka ExploreDivooka Compute
- Graph kinds
- Flows Function Events Routine Constructs StateMachineState
- Declared by
- Grids
- Package
- Crime Engine