# Integer grid

For two-dimensional state such as a board or a map.

> For the full list see "[UI development](help:vml/ui)". Each call below comes with a
> one-line usage note and an example; signatures come from `Lib/c/vml_ui.h` (the authoritative source).

### `ui_grid_clear(void)`
Clears the grid. Use it for two-dimensional state such as a board or a map - it is **more reliable than the language's own arrays** (with some front ends a value written into an array does not read back; see the per-language pitfalls under "27 languages").
```c
ui_grid_clear();
```
### `ui_grid_get(int idx)`
Reads one cell; returns 0 if it was never written.
```c
int v = ui_grid_get(y * 10 + x);
```
### `ui_grid_set(int idx, int val)`
Writes one cell; `i` is a **one-dimensional index** (`row * width + col`).
```c
ui_grid_set(y * 10 + x, 1);   /* place a stone on a 10-column board at (x,y) */
```
