chemart / chameleon
View on GitHubColored chameleon chemistry — A puzzle in chemical clothing, and the smallest useful test case in the catalog. Three colours; when two chameleons of different colours meet, both take the third colour. The total count never changes, so the system just…
How it works
A puzzle in chemical clothing, and the smallest useful test case in the catalog. Three colours; when two chameleons of different colours meet, both take the third colour. The total count never changes, so the system just relaxes to equal thirds. Its real value is the conservation law: besides the obvious total, the differences between colour counts are conserved *modulo 3* - an integer invariant that any real-valued nullspace computation will miss entirely.
- S
- three colors r, g, b · explicit
- R
- i + j -> 2k for all i != j != k over {r,g,b}; same-color collisions are elastic · arity 2
- A
- well-stirred-multiset, ode · none needed - the rule is number-conserving (2 in, 2 out)
Parameters
| name | default | meaning |
|---|---|---|
| M int · population |
5400 | total number of chameleons (constant) [3, ∞] |
| x0 list · population |
[0.5, 0.0, 0.5] | initial colour fractions of (r, g, b), summing to 1; counts are M * x0 rounded by largest remainder |
Colored chameleon chemistry
One of the artificial chemistries of Banzhaf & Yamamoto, Artificial Chemistries (MIT Press, 2015), §2.5.1; first proposed by Winkler, 2009 puzzle (Communications of the ACM); formulated as an AC by Banzhaf & Yamamoto.
Its generator ships with the chemart library, so loading it runs no code from the hub and needs no trust_remote_code.
import chemart
net = chemart.generate_network("chemart/chameleon", seed=0) # same as "chameleon"
print(net.summary())
What to look for
- conserved total count
- relaxation to the 1/3,1/3,1/3 fixed point
- the mod-3 invariant that makes the original puzzle unsolvable
Implementation decisions
- Rate constants are 1 for all three reactions, as implied by the book's rate equations 2.40-2.42.
- Default x0 follows figure 2.5 (only red and blue present at the start).
Banzhaf & Yamamoto, Artificial Chemistries (2015), §2.5.1
Preview at default parameters
3 species · 3 reactions · status complete · seed 1
r + g -> 2 b [mass-action k=1.0] r + b -> 2 g [mass-action k=1.0] g + b -> 2 r [mass-action k=1.0]
Generated by the uploader with chemart push; the hub never runs uploaded code.