Skip to content

Commit

Permalink
document automaton naming
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucaroff committed Aug 18, 2023
1 parent 3b606ed commit b1d9c1b
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
46 changes: 46 additions & 0 deletions src/automatonnaming/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Automaton naming

_Automaton description format_

## Examples

The following entries all describe rule 110:

- `1d, ns3, 2c, r110`
- `1d,ns3,2c,r110`
- `e110`

They are the compact version of the following entries:

- `1 dimension, neighborhood size 3, 2 colors, rule 110`
- `elementary 110`

Cellex handles only monodimensional rules, so rule descriptions beginning by `2d` or `3d` will be rejected.

By default, Cellex assumes the following:

- The dimension is one
- The neighboor size is three
- The number of colors is two
- The rule number has no default value and must always be specified

Therefore, the following entries are all recognised and also refer to rule 110:

- `1d,ns3,r110`
- `1d,2c,r110`
- `ns3,2c,r110`
- `1d,r110`
- `ns3,r110`
- `2c,r110`
- `r110`

Note that the order of the fields is must be preserved.

Upon pressing enter, the rule text input will normalize the entry and compact it, removing unecessary parameters and setting all letters to lowercase.

In case there are no letters in the input, the parser will proceed as follow:

- If the number is between 0 included and 256 excluded, it will be read as an elementary rule.
- If the number is greater or equal to 256, it will first try to parse it with a neighborhood size of three and with three colors, then with four colors, then with five colors and then with six colors.

The automaton description format supports the case of totalistic codes. The totalistic codes are the rules whose value depends only on the number of occurence of each of the colors in their neighborhood.
18 changes: 12 additions & 6 deletions src/control/KeyboardBinding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,18 @@ export let keyboardBinding = (prop: KeyboardBindingProp): KeyboardBinding => {
onKeypress("Digit5", act.setGenesis("(0)101(0)"), "5", "set the genesis to impulse 01010")
onKeypress("Digit7", act.setGenesis("(0)111(0)"), "7", "set the genesis to impulse 01110")

onKeypress(
"Digit9",
act.setRandomGenesis("([01])([01])"),
"9",
"set the genesis to random with 50% of 0 and 50% of 1",
)
onKeypress(
"Digit8",
act.setRandomGenesis("([0{9}1])([01{9}])"),
"8",
"set the genesis to random step from 10% of 1 to 90% of 1",
)
onKeypress(
"Digit2",
act.setRandomGenesis("(0[01])(0[01])"),
Expand All @@ -103,12 +115,6 @@ export let keyboardBinding = (prop: KeyboardBindingProp): KeyboardBinding => {
"set the genesis to 50% random but only on six indices",
)

description = "set the genesis to random step from 10% of 1 to 90% of 1"
onKeypress("Digit8", act.setRandomGenesis("([0{9}1])([01{9}])"), "8", description)

description = "set the genesis to random with 50% of 0 and 50% of 1"
onKeypress("Digit9", act.setRandomGenesis("([01])([01])"), "9", description)

onKeypress("Digit0", act.gotoTop, "0", "go back to the top")

onKeypress("Minus", act.halfZoom, "-", "half the zoom level")
Expand Down

0 comments on commit b1d9c1b

Please sign in to comment.