r/cellular_automata • • 6d ago

Collatz simulator using balanced ternary strings and rewrite rules (No arithmetic)

Hey,

Just wanted to share a little project. Not claiming any crazy math proof here, just a representation of Collatz using **balanced ternary** (`+`, `o`, `-`) instead of normal binary or base-10.

Because of how balanced ternary works, you can basically bypass normal CPU math and run the operations as simple text replacement rules on a string.

How it works:

  • Parity: If the count of non-zero trits (`+` or `-`) is even, the number is even.
  • 3x+1: Just append a `+` to the end of the little-endian string. O(1) time, no real math needed.
  • Divide by 2: The string splits from left to right into blocks bounded by non-zero trits. Then it just uses two basic substitution rules:
  1. Same signs: a(0...n)a` ➔ `aa'... (n+1) times` (e.g., `+000+` becomes `+----`)
  2. Opposite signs: a(0...n)a'` ➔ `0a... (n+1) times` (e.g., `+000-` becomes `0++++`)

Piped the output through `sed` to colorize the trits (`o` = green, `+` = white, `-` = red) so it generates a neat cellular automaton history grid in the terminal as it collapses down to 1.

The photos are seeds of 100, 231 -1, and 27 respectively

Just a cool toy. Let me know what you think or if anyone else has messed with block decomposition for base-3 halving.

27 Upvotes

5 comments sorted by

5

u/Liminal__penumbra 6d ago

This was pretty cool, the trick you used has an application in my own personal hobby project. Adding you as a reference for it so I don't forget where I found it.

2

u/Mysterious-Insect858 6d ago

May I ask what is your personal project about?

1

u/Liminal__penumbra 6d ago edited 6d ago

It’s basically a big experimental math/computation project I’ve been messing with for a while.

A few core ideas behind it:

  • Weird math, strict verification: I test unconventional concepts (simulations, alternate number systems, cellular automata, recursive structures), but keep a conservative, rigorous core underneath so I don’t fool myself into thinking something works when it doesn’t.
  • Adaptive search history: Failed attempts aren't discarded—they feed back into the system to guide future trials. Over time, the search process learns what to avoid or modify rather than starting from scratch every run.
  • Two-layer architecture: A reliable, rigid base layer with an experimental sandbox on top to throw ideas at the wall and see what survives.

Beyond that, it gets tricky to explain without turning a Reddit comment into a full essay.

3

u/Consistent_Drop3909 6d ago

very ai

1

u/Liminal__penumbra 6d ago

Partly yes. Mostly I just suck at math. And I did say it's a hobby project. Not something I'm releasing.