Genetic
Genetic, as you could have guessed by its name, is an esolang that only uses the letters in DNA (which is A, C, G, and T). The basic part is designed by User:iddi01.
It's designed to simulate genetic evolution though very simple rules.
Basic rules
Genetic programs modify themselves, with each letter executed simutaneously. It can also be treated as "each turn, an empty new program is created, and with each letter executed, apply modifications to it, and append it to the end of the new program". Each letter decides its behavior according to the previous letter, the letter and the next letter, which will be referred to in this article as gL, gM, and gR:
Modifications
If a gR is C, then the gM Copies itself to the right, then the copy, wherever it's in the list C, A, G, T, becomes the next item, with wraparound (that is, a T would become C).
If a gL is C, then the gM becomes C;
If a gM is C, and the gR isn't G or empty, then the gM deletes itself. (intended so that only G can Generate new letters in the usual case)
The only ways to increase the length of the code are having a C on the right edge, through a G, or via adjustments (see below).
Technically, anything except C is a no-op.
Adjustments
- This section is still a work in progress. It may be changed in the future.
With only the basic rules, it produces pseudo-random code that looks "too random" to be an actual usable code, and in which C's and A's dominates. This can be fixed using adjustments. Since the current adjustments listed here are likely not the best set, this will remain a work-in-progress until a set of adjustments are proved to be better than all others (which is unlikely). Please contribute your own adjustment sets on the talk page!
The usual adjustment is basically when [gL, gM, gR]
is equal to [x, y, z]
, the gM becomes <string>
. A simple notation to describe the adjustment would be x,y,z,<string>
.
The current best adjustment set is: (Feel free to edit this if you have a better one)
A,G,T,TC A,A,A,GC
Using this adjustment set, The frequencies of the four letters tend to be reasonably equal, and the code tend to evolve into a random-but-ordered sequence, similarly to compiled programs and .pyc files. It is conjectured that if we run this set for a very long time, say a year, we might be able to create actual lifeforms!
(later research found that it evolves into 4 distinct pseudo-random sequences which cycle into the next every execution cycle.)
Implementation
It's very easy to write an interpreter. Here's moderate one in Python, configured to the adjustment set above:
import copy seq = input("Sequence: ").upper() li = ['C', 'A', 'G', 'T'] while True: newseq = "" for index in range(len(seq)): append = True copy = False if index > 0: if seq[index-1] == 'C': newseq += "" if seq[index] != 'G' else 'C' append = False if index < len(seq) - 1: if seq[index+1] == 'C': copy = True if index > 0: #adjustments goes here if seq[index-1] == 'A' and seq[index] == 'G' and seq[index+1] == 'T': newseq += 'TC' append = False elif seq[index-1] == seq[index] == seq[index+1] == 'A': newseq += 'GC' append = False if append: newseq += seq[index] if copy: newseq += li[(li.index(seq[index]) + 1) % 4] seq = newseq print(seq) if len(seq) > 172: print()
See also
Note: These are too picky with style and doesn't bring evolution.