> For the complete documentation index, see [llms.txt](https://todepond.gitbook.io/spacetode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://todepond.gitbook.io/spacetode/rules.md).

# Rules

You can give an element rules by drawing rule diagrams:

```
element Sand {
    @ => _
    _    @
}
```

An element's rules show how it acts in the world.\
It checks its surroundings to see if it matches the left-hand-side of the rule (the inputs).\
If it matches, it changes it to look like the right-hand-side of the rule (the outputs).\
Rules are checked in order. The first rule to match is the one that gets used.

Check out the [diagrams](/spacetode/diagrams.md) page for more information on diagrams.

## Rule Keyword

You can optionally use the `rule` keyword, which may improve readability in longer elements:

```
element Sand {
    rule {
        @ => _
        _    @
    }
}
```
