diff --git a/site/index.html b/site/index.html index 55535a6..7294218 100644 --- a/site/index.html +++ b/site/index.html @@ -29,7 +29,7 @@ this means it is
- unity on linux sucks
- dead trees
- horological crimes
-- snad (cell thing)
+- snad
- keyboar
- distracting
- blender
diff --git a/site/snad/bee_movement_pattern.png b/site/media/snad/bee_movement_pattern.png similarity index 100% rename from site/snad/bee_movement_pattern.png rename to site/media/snad/bee_movement_pattern.png diff --git a/site/snad/bee_rules_rotated.png b/site/media/snad/bee_rules_rotated.png similarity index 100% rename from site/snad/bee_rules_rotated.png rename to site/media/snad/bee_rules_rotated.png diff --git a/site/snad/bees.mp4 b/site/media/snad/bees.mp4 similarity index 100% rename from site/snad/bees.mp4 rename to site/media/snad/bees.mp4 diff --git a/site/snad/bees_biased.mp4 b/site/media/snad/bees_biased.mp4 similarity index 100% rename from site/snad/bees_biased.mp4 rename to site/media/snad/bees_biased.mp4 diff --git a/site/snad/copy_example.png b/site/media/snad/copy_example.png similarity index 100% rename from site/snad/copy_example.png rename to site/media/snad/copy_example.png diff --git a/site/snad/fire.mp4 b/site/media/snad/fire.mp4 similarity index 100% rename from site/snad/fire.mp4 rename to site/media/snad/fire.mp4 diff --git a/site/snad/group_example.png b/site/media/snad/group_example.png similarity index 100% rename from site/snad/group_example.png rename to site/media/snad/group_example.png diff --git a/site/snad/rule_size_bias.mp4 b/site/media/snad/rule_size_bias.mp4 similarity index 100% rename from site/snad/rule_size_bias.mp4 rename to site/media/snad/rule_size_bias.mp4 diff --git a/site/snad/sand_fall_faster.mp4 b/site/media/snad/sand_fall_faster.mp4 similarity index 100% rename from site/snad/sand_fall_faster.mp4 rename to site/media/snad/sand_fall_faster.mp4 diff --git a/site/snad/snake_in_maze.mp4 b/site/media/snad/snake_in_maze.mp4 similarity index 100% rename from site/snad/snake_in_maze.mp4 rename to site/media/snad/snake_in_maze.mp4 diff --git a/site/snad/worm_left.mp4 b/site/media/snad/worm_left.mp4 similarity index 100% rename from site/snad/worm_left.mp4 rename to site/media/snad/worm_left.mp4 diff --git a/site/snad/worm_right.mp4 b/site/media/snad/worm_right.mp4 similarity index 100% rename from site/snad/worm_right.mp4 rename to site/media/snad/worm_right.mp4 diff --git a/site/cellthing.html b/site/snad.html similarity index 88% rename from site/cellthing.html rename to site/snad.html index 4f2d5d9..f3e8823 100644 --- a/site/cellthing.html +++ b/site/snad.html @@ -4,7 +4,7 @@ - something silly - cellthing + something silly - snad @@ -20,18 +20,16 @@ I made/am making some kind of asynchronous cellular automata or cell-based spati The world consists of a grid of cells, and you can create new cell types and assign them names and colours. You can create rules, which are like the chemistry of this world. You make a pattern on the left and a pattern on the right.
The engine randomly finds places where the one of your rules' input (left) picture matches a place in the world, and replaces it with the output (right) picture.

-

- -

+

groups

A rule can also have cells containing a group. On the input side, that cell will match anything in the group, and on the output side it will become a random cell from the group. A diagonal line through the group icon means that it can also match on positions outside the world, where there are no cells.
- +

copy cells

On the output side, a cell can be set to copy the contents of one cell from the input side, this is useful for applying the same rule to several cell types without randomly swapping between them on the output
- +

random is easy, right?

@@ -43,9 +41,11 @@ A rule can have blank cells. On the input side, this means it will matc

worm

Let's say I make a rule for a little worm that moves to the right, this works fine. Its head disappears out of the world because the cell in front of the head in the input pattern is blank, which matches anything, including out of bounds. To make it stop just before the edge, you could set that rule cell to air.
- + Now if I want it to do the same thing in but to the left, I can simply draw the rule and worm in the other direction, right?
-
+ +

+

Almost. It no longer moves past the edge.

@@ -65,9 +65,7 @@ Once at the start, the engine checks every possible position and every rule, and

Now, how should it even use that information? The first thing I tried was to randomly pick one of all the matches. This kind of works but leads to the simulation speed being dependent on the number of matches, so for example sand falls slower if there is a lot of sand that hasn't landed yet.

-

- -

+

I got a slightly more even result by multiplying the speed (number of rule executions per frame) by the total number of matches, but this is not a perfect solution as it does not take into account overlapping matches. A cell contained in several rule matches would be more likely to be affected, which in some cases can lead to weird bias (see just one more implementation)

@@ -79,9 +77,7 @@ So now the engine picks a random position, then checks the cache and picks a ran

I want to simulate a swarm of bees, so I create a rule for a bee moving by one cell, and enable rotate so it works in all directions. That was easy,

-

- -

+

Oh no, the swarm is moving toward the top left instead of spreading equally. But I can see that the bees move in all four directions, so the rule seems to be rotated correctly.

@@ -90,12 +86,12 @@ I was stuck on this problem for quite a while, and it only happened with the new

The movement rule has these variants:
- +

Each rule has its origin point in the top-left cell.
In the diagram below, the bee would move left when the left (purple) cell is picked by the engine, and up when the top (green) cell is picked.
- +

But to move right or down, it needs the bees own position to be picked by the engine, since the rules always extend right-down. That means when the engine picks the bee's position, there are two possible rules to execute. Therefore, moving right and down both have half the probability overall compared to moving up or left.
@@ -107,9 +103,7 @@ In this version, the cache is not only searched for matches at the chos

Since the root issue was caused by asymmetry, I thought this implementation should be correct. This one was actually my first instinct when I created the cache, but as a friend suggested, an absolute-position based checker seemed (and indeed was) more performant and simpler, so I did that one first.

-

- -

+

Now the bees are evenly distributed, just like real bees!(false)

@@ -117,9 +111,7 @@ Now the bees are evenly distributed, just like real bees!(false)

While I was trying to figure out the reason for the directional bias in the previous implementation, I realised that the overlap checker also has biases. The probability of any given cached match to be executed is dependent on its area, which is not very intuitive. Two objects of different mass fall at different speeds, and adding empty padding to a rule makes it run faster.

-

- -

+

Ideally the red, pink and blue cells should all fall at around the same rate, but the red sand always lands first and the pink last.

@@ -129,7 +121,7 @@ Alright, the Final (I hope) implementation stores an origin offset for

fin

If you somehow read through all that, congratulations I think? Now enjoy this fire:
- +

Download the thing and make something fun: git.crispypin.cc/CrispyPin/snad
diff --git a/write/index.md b/write/index.md index 7f6557b..a2ce6b1 100644 --- a/write/index.md +++ b/write/index.md @@ -13,7 +13,7 @@ this means it is - [unity on linux sucks](/awful_software/unity-on-linux) - [dead trees](/vent/dead-trees) - [horological crimes](/horological-crimes) -- [snad (cell thing)](/cellthing) +- [snad](/snad) - [keyboar](/keyboards-are-fun) - [distracting](/vent/distracting) - [blender](/blender) diff --git a/write/cellthing.md b/write/snad.md similarity index 92% rename from write/cellthing.md rename to write/snad.md index 29a4890..2520155 100644 --- a/write/cellthing.md +++ b/write/snad.md @@ -5,15 +5,15 @@ I made/am making some kind of asynchronous cellular automata or cell-based spati The world consists of a grid of cells, and you can create new cell types and assign them names and colours. You can create rules, which are like the chemistry of this world. You make a pattern on the left and a pattern on the right. The engine randomly finds places where the one of your rules' *input (left)* picture matches a place in the world, and replaces it with the *output (right)* picture. - +==video:"/media/snad/snake_in_maze.mp4" ## groups A rule can also have cells containing a *group*. On the input side, that cell will match anything in the group, and on the output side it will become a random cell from the group. A diagonal line through the group icon means that it can also match on positions outside the world, where there are no cells. - +==image:"/media/snad/group_example.png" ## copy cells On the output side, a cell can be set to *copy* the contents of one cell from the input side, this is useful for applying the same rule to several cell types without randomly swapping between them on the output - +==image:"/media/snad/copy_example.png" # random is easy, right? @@ -23,9 +23,10 @@ A rule can have *blank* cells. On the input side, this means it will match anyth ## worm Let's say I make a rule for a little worm that moves to the right, this works fine. Its head disappears out of the world because the cell in front of the head in the *input* pattern is blank, which matches anything, including out of bounds. To make it stop just before the edge, you could set that rule cell to air. - +==video:"/media/snad/worm_right.mp4" Now if I want it to do the same thing in but to the left, I can simply draw the rule and worm in the other direction, right? -
+==video:"/media/snad/worm_left.mp4" + Almost. It no longer moves past the edge. When a rule and position is chosen, the top-left of the rule is aligned with that position. In the example above, the rule would have to start from outside the world to make the worm continue one more step. @@ -40,7 +41,7 @@ Once at the start, the engine checks every possible position and every rule, and Now, how should it even use that information? The first thing I tried was to randomly pick one of all the matches. This kind of works but leads to the simulation speed being dependent on the number of matches, so for example sand falls slower if there is a lot of sand that hasn't landed yet. - +==video:"/media/snad/sand_fall_faster.mp4" I got a slightly more even result by multiplying the speed (number of rule executions per frame) by the total number of matches, but this is not a perfect solution as it does not take into account overlapping matches. A cell contained in several rule matches would be more likely to be affected, which in some cases can lead to weird bias (see [just one more implementation](#just-one-more-implementation)) @@ -50,18 +51,18 @@ So now the engine picks a random position, then checks the cache and picks a ran ## swarm I want to simulate a swarm of bees, so I create a rule for a bee moving by one cell, and enable `rotate` so it works in all directions. That was easy, - +==video:"/media/snad/bees_biased.mp4" Oh no, the swarm is moving toward the top left instead of spreading equally. But I can see that the bees move in all four directions, so the rule seems to be rotated correctly. I was stuck on this problem for quite a while, and it only happened with the new cached executor. The movement rule has these variants: - +==image:"/media/snad/bee_rules_rotated.png" Each rule has its origin point in the top-left cell. In the diagram below, the bee would move left when the left (purple) cell is picked by the engine, and up when the top (green) cell is picked. - +==image:"/media/snad/bee_movement_pattern.png" But to move right or down, it needs the bees own position to be picked by the engine, since the rules always extend right-down. That means when the engine picks the bee's position, there are *two* possible rules to execute. Therefore, moving right and down both have half the probability overall compared to moving up or left. @@ -71,14 +72,14 @@ In this version, the cache is not only searched for matches *at* the chosen posi Since the root issue was caused by asymmetry, I thought this implementation should be correct. This one was actually my first instinct when I created the cache, but as a [friend](https://gaussian.dev/) suggested, an absolute-position based checker seemed (and indeed was) more performant and simpler, so I did that one first. - +==video:"/media/snad/bees.mp4" Now the bees are evenly distributed, just like real bees!(false) ## just one more implementation While I was trying to figure out the reason for the directional bias in the previous implementation, I realised that the overlap checker also has biases. The probability of any given cached match to be executed is dependent on its area, which is not very intuitive. Two objects of different mass fall at different speeds, and adding empty padding to a rule makes it run faster. - +==video:"/media/snad/rule_size_bias.mp4" Ideally the red, pink and blue cells should all fall at around the same rate, but the red sand always lands first and the pink last. @@ -86,7 +87,7 @@ Alright, the Final (I *hope*) implementation stores an origin offset for rules. ## fin If you somehow read through all that, congratulations I think? Now enjoy this fire: - +==video:"/media/snad/fire.mp4" Download the thing and make something fun: [git.crispypin.cc/CrispyPin/snad](https://git.crispypin.cc/CrispyPin/snad)