Self-replicating marbles

From Esolang
Jump to navigation Jump to search

Self-replicating marbles is an esolang by User:Joaozin003, which as the name says, uses self-replcating marbles.


A program is divided into a 2D grid of what we'll call sections. These sections then contain a 2D grid of instructions.

Sections can be blanked out, even if it doesn't make sense:

> > v

^   <

Additionally, sections don't need to be exactly rectangular and they don't connect diagonally, so


would be two separate sections.

A marble is your main way of storing data. It stores a bit and can go over instructions, executing them.

The interesting part is that if a marble reaches the end of a section, it will go to the next and replicate itself to all instructions of that section.

If a marble reaches the edge of a program, it gets removed.


When the program is started, a marble with a 0 is placed at the top-left instruction of the top-left section, with the top winning if a tiebreaker is needed:


In this case, the marble will land on the m.

Then, the marble will roll to the right.

The program ends when no marbles exist.


Instruction Description
>, v, < and ^ Make the marble on top roll in the direction the arrow points
? Delete the marble on top if it holds a 0
i Input a bit into the marble
o Output the marble's bit
  Separate sections
Anything else No-op. Avoid using it as it makes your code impure (all interpreters must have a flag --PURE that errors if a no-op is present)

There is one command not mentioned here, and that is when 2 or more marbles collide. If that happens, then they will merge into a single marble with the combined NAND of all of the marbles.

This requires the marbles to be above an arrow or get deleted by ? (not guaranteed!), otherwise this error occurs:

Runtime error: The marbles unexpectedly collided on a flat piece of track. (*waits until the heat death of the universe*)


What happens when you do this?

> >

Well, the > will make the marble go to the second >, so no, this is not a section jump and will not replicate the marble.


Cat program

> i o
< <

Pretty easy to understand.

Truth machine

i > o ? >
  <     <

Also pretty easy to understand.


> i o
  i >

NANDs both inputs and outputs the result.


A list of snippets can be found here.