Skip to content

MargolusNeighborhood

Tim Hutton edited this page Jun 28, 2015 · 1 revision

What is the Margolus neighborhood?

Use:

Here is an example:

# Diffusion Limited Aggregation, in a Margolus neighborhood CA

n_states:3
neighborhood:Margolus
symmetries:rotate4reflect

# In the Margolus nhood, the transition a,b,c,d : e,f,g,h means:
#  a  b     -->    e  f
#  c  d            g  h

# 0: vacuum
# 1: gas particle
# 2: stuck particle

# HPP gas rules:
1,0,0,0 : 0,0,0,1 # a diagonally-travelling particle keeps going
1,1,0,0 : 0,0,1,1 # two particles pass through each other
0,1,1,0 : 1,0,0,1 # two particles collide head-on
1,1,1,0 : 0,1,1,1 # three particles pass through each other

# plus aggregation rules: (these seem to suffice)
1,0,2,0 : 2,0,2,0
1,0,2,2 : 2,0,2,2

And another:

# A simple CA simulation of sand - inspired by MCell's version.

n_states:4
neighborhood:Margolus
symmetries:reflect_horizontal

# In the Margolus nhood, the transition a,b,c,d : e,f,g,h means:
#  a  b     -->    e  f
#  c  d            g  h

# 0 : air
# 1 : sand
# 2 : wood
# 3 : magical source of sand

var a={0,1,2}
var b={0,1,2}

1,1,0,0 : 0,0,1,1 # a pair of sand particles falls
1,a,0,b : 0,a,1,b # otherwise, sand falls next to a static column
1,0,a,0 : 0,0,a,1 # otherwise, it can topple
3,0,0,0 : 3,0,1,0 # sand can appear from the magical source

Features:

Discussion:

  • reflect_horizontal (and vertical) are new symmetries that we were missing.
  • It's longer than MCell's specification string but much more powerful, allowing multiple states and variables, and different symmetries. And no-change transitions can be skipped, so it's actually more readable.
  • We could use Calcyman's GenericNeighborhoods for the header but is there any need to? This approach is more human-readable, which is the main point of the rule table format - we want people to start authoring their own rules, as they have been!

Tim Tyler discusses the Square-4 neighborhood which is related to the Margolus neighborhood. It is actually more appropriate than the Margolus neighborhood for the Sand CA above, since it covers one particular case where 2 stacked sand particles should topple but don't. See the pattern info in Patterns/Margolus/Sand-Test.rle for an example that shows the effect of these different neighborhoods. --TJH

Clone this wiki locally