Python Compiler from Turedo to Oritatami
root / python
- oritatami_class.py
- readme.md
- turedo.py
- turedo2oritatami.py
- turedo2oritatami_beadtypes.py
- turedo2oritatami_modules.py
- turedo2oritatami_speedbump.py
- turedo_examples.py
Turedo to oritatami compiler: Source files
The source files
The demo file compute_examples.py
is the python demo file to be executed using the command
python3 compute_examples.py
to produce the .os
files for some examples of Turedo found in the turedo_examples.py
file.
The source files are:
oritatami_class.py
: class definition of anOritatamiSystem
objectturedo.py
: class definition of aTuredo
objectturedo_examples.py
: define some Turedo examples used by the demonstration programcompute_examples.py
turedo2oritatami.py
: compiler from aTuredo
object to anOritatamiSystem
objectturedo2oritatami_beadtypes.py
: definition of the bead types used in the oritatami system simulating any turedoturedo2oritatami_modules.py
: class definitions of the different oritatami modules used by the Turedo-to-Oritatami system compilerturedo2oritatami_speedbump.py
: class definition of the speedbump oritatami module used by the Turedo-to-Oritatami system compiler
Running examples
Run the program compute_examples.py
to produce the .os
files from some Turedo examples with various densities:
python3 compute_examples.py
This will produce various .os
files, one for each Turedo and density declared in the file.
The .os
files must then be executed by the iOS program:
Simple Oritatami Simulator 1.2+ [ direct free download link on the iOS app store ]
in any iPad or iOS simulator for running.
How to build a Turedo
In order to build your own Turedo, you need to define using the Turedo
class in turedo.py
by passing the arguments:
q
: the number of state bitsbit_weigths
: an array of 6 arrays of q integers which are the weights for each of the q bits on the 6 sides NW, SW, S, SE, NE and N.transition_function
: a function that takes two arguments(i,s)
which returns the state (as an integer) to be written on sidei
when the total sum of the bits read iss
transition_function
: aTuredoTransitionFunction
object defined by 4 parameters:q
: the number of bits per statesum_of_bit_weights
: the total sum of the bit weightsstate_function
: a function that takes two arguments(i,s)
which returns the state (as an integer) to be written on sidei
when the total sum of the bits read iss
exit_function
: a function that takes one arguments
which returns the side number (as an integer: 0:NW, 1:SW, 2:S, 3:SE, 4:NE) to exit from when the total sum of the bits read iss
seed_path
: a possibily empty array containing a list of pairs of integers(i,d)
wherei
is a state to be writen in the current cell andd
is the direction to the next seed cell (encoded as an integer: 0:NW, 1:SW, 2:S, 3:SE, 4:NE, assuming that N is the entry point).number_of_steps
: the number of steps of turedos to be simulated
Refer to turedo_examples.py
for examples.
How to compile a Turedo
Once you a have built a Turedo turedo
, just call the function OritatamiSystem_for(turedo, density)
to obtain an OritatamiSystem
object simulating the turedo. The density
parameter is an integer which extends the macrocell side to accomodate a hexagon which increases the macrocell density (the hexagon is not filled for performance).
Refer to the compute_examples.py
file for an example.
Examples of Turedo
The file turedo_examples.py
defines some Turedo (beware that some of them generate huge oritatami systems that require a lot of time to process in the oritatami simulator):
Right_hand(count, extra_bits)
: creates a Turedo that applies the right hand algorithm to explore the plane.count
is the number of steps to be simulated. For this algorithm 1 bit is enough,extra_bits
is an integer that creates an internal state in 0..2^(extra_bits
-1) that is incremented at each step modulo 2^(extra_bits
-1). Here is an example of execution withextra_bits
=2:

Turedo Righ_hand(extra_bits=2)

Oritatami simulation of Turedo Righ_hand(extra_bits=2)
Bouncing_right_hand(count, extra_bits)
: creates a Turedo that applies the bouncing right hand algorithm to explore the plane where.count
is the number of steps to be simulated. For this algorithm 1 bit is enough,extra_bits
is an integer that creates an internal state in 0..2^(extra_bits
-1) that is incremented at each step modulo 2^(extra_bits
-1). Here is an example of execution withextra_bits
=2:

Bouncing_righ_hand(extra_bits=2)

Oritatami simulation of Turedo Bouncing_righ_hand(extra_bits=2)
Sierpinski_2_bits(count)
: creates a Turedo that runs the Sierpinski triangle cellular automata. Because the bit weights are exponentially increasing, beware that the resulting oritatami is huge and that the.os
file will be very slow to load and run.count
is the number of steps to be simulated:

The Turedo Sierpinski_2_bits()

Oritatami simulation of Turedo Sierpinski_2_bits()
Sierpinski_bit_sum_8(count)
: creates a Turedo that runs the Sierpinski triangle cellular automata with a clever encoding of the state into bits and bit weight so that the sum of bit weight never exceed 8.count
is the number of steps to be simulated:

Turedo Sierpinski_bit_sum_8()

Oritatami simulation of Turedo Sierpinski_bit_sum_8()
Increasing the macrocell density
We increase the macrocell density by extending its edges to fit an filled hexagon at its core (the hexagon is not filled in the .os
file for performance):

Oritatami simulation of Turedo Bouncing_righ_hand(extra_bits=2)() with density extension 10

Oritatami simulation of Turedo Bouncing_righ_hand(extra_bits=2)() with density extension 50

Oritatami simulation of Turedo Bouncing_righ_hand(extra_bits=2)() with density extension 100

Oritatami simulation of Turedo Bouncing_righ_hand(extra_bits=2)() with density extension 200