The Genetic Computer
The Genetic Computer is a very simple esolang which splits a string of DNA bases into codons, which it uses as both the tape and the program. Each step, it reads the cell it is currently in, performs an action based on the value of that cell, and then moves by one cell in whichever direction the head is currently moving. To initialise, the compiler will check that the input is a valid tape (i.e. only contains the letters ACTG), splits it into a list of codons, finds the first occurence of the start codon in that list, positions the head there, and begins moving to the right. If it encounters a codon which is currently not assigned to a function, it will just skip that codon and keep moving.
Python Interpreter: https://github.com/theonetruenerd/the_genetic_computer/tree/master
Codons
Function | Codon | Function | Codon | Function | Codon | Function | Codon |
---|---|---|---|---|---|---|---|
Start Reading | AAA | Combine Next And Stored Codons | TAA | Print Tape | CAA | Output Tape To File | GAA |
Move Left | AAT | Currently Undefined | TAT | Swap Stored And Tape | CAT | Save Memory As Tape | GAT |
Move Right | AAC | Move Equal To Last Stored Codon | TAC | Loop Start | CAC | Compare Codon Value | GAC |
Stay In Place | AAG | Load Tape | TAG | Loop End | CAG | Remove Last Stored Codon | GAG |
Store Next Codon | ATA | Clear Memory | TTA | Reverse Codon | CTA | Begin Equation | GTA |
Complement Next Codon | ATT | Do Nothing | TTC | Print Memory | CTT | End Equation | GTT |
Overwrite Next Codon | ATC | Stop Reading | TTT | Print Memory As ASCII | CTC | Save Tape To Memory | GTC |
Print Stored Codon As ASCII | ATG | Generate Random Codon | TTG | Tape Meiosis | CTG | Jump To End | GTG |
Double Tape Speed | ACA | Move To Stored Codon | TCA | Reverse Order Of Memory | CCA | Bitwise NOT | GCA |
Halve Tape Speed | ACT | Store User Ascii Input | TCT | Read File Into Tape | CCT | Bitwise AND | GCT |
Insert Codon | ACC | Store User Codon Input | TCC | Print Stored Codon | CCC | Currently Undefined | GCC |
Delete Next Codon | ACG | Return | TCG | Jump To Beginning | CCG | If | GCG |
Shuffle Bases Of Next Codon | AGA | Append Stored Codon | TGA | Print Next Codon | CGA | Bitwise OR | GGA |
Change Read Direction To Right | AGT | Shuffle Tape | TGT | Read ASCII File Into Tape | CGT | Bitwise XOR | GGT |
Change Read Direction To Left | AGC | Start New Tape | TGC | Output Tape To ASCII File | CGC | Append Stored Codon To Top Of Tape Stack | GGC |
Toggle Read Direction | AGG | Read From Adjacent Tape | TGG | Print Next Codon As ASCII | CGG | Return To Start Of Tape | GGG |
Codons as Ascii
def codon_to_ascii(codon): base_to_index = {'A': 0, 'C': 1, 'T': 2, 'G': 3} index = base_to_index[codon[0]] * 16 + base_to_index[codon[1]] * 4 + base_to_index[codon[2]] index += 32 return chr(index)
Ascii Character | Codon | Ascii Character | Codon | Ascii Character | Codon | Ascii Character | Codon |
---|---|---|---|---|---|---|---|
space | AAA | 0 | CAA | @ | TAA | P | GAA |
! | AAC | 1 | CAC | A | TAC | Q | GAC |
" | AAT | 2 | CAT | B | TAT | R | GAT |
# | AAG | 3 | CAG | C | TAG | S | GAG |
$ | ACA | 4 | CCA | D | TCA | T | GCA |
% | ACC | 5 | CCC | E | TCC | U | GCC |
& | ACT | 6 | CCT | F | TCT | V | GCT |
' | ACG | 7 | CCG | G | TCG | W | GCG |
( | ATA | 8 | CTA | H | TTA | X | GTA |
) | ATC | 9 | CTC | I | TTC | Y | GTC |
* | ATT | : | CTT | J | TTT | Z | GTT |
+ | ATG | ; | CTG | K | TTG | [ | GTG |
, | AGA | < | CGA | L | TGA | \ | GGA |
- | AGC | = | CGC | M | TGC | ] | GGC |
. | AGT | > | CGT | N | TGT | ^ | GGT |
/ | AGG | ? | CGG | O | TGG | _ | GGG |
Example Code
Hello, World:
AAAATATTAATATCCATATGAATATGAATATGGATAAGAATAAAAATAGCGATATGGATAGATATATGAATATCACTCTTATTTT
Truth Machine:
AAATCTTCACAATTTCACATGAAT
Cat Program:
AAATCTCTCTTATTT