Brainfuck Interpreter
-
class
bf_interpreter.
Interpret
(file_name, mem_size=65536, get_input=<function Interpret.<lambda>>)[source]
Interpret a brainfuck code,
Loads file_name in a memory of size mem_size, loads the inputs with get_input
-
get_output
(size=0)[source]
If size is 0 gets the current output, else waits for the output size to be size
-
step
()[source]
Execute an instruction
Database
-
database.
open_db
()[source]
Opens the database
-
database.
update_state
(db, new_state, job_id)[source]
Update the state in db for the job job_id
if it is less than new_state
Ensicoin Library
Wrapper around ensicoincoin-cli
-
ensicoin.
generate_keys
()[source]
Generates a pair of (private_key, public_key)
-
ensicoin.
send_to
(value, outpoint_hash, outpoint_index, privkey_from, spent_output_value, pubkey_to, flags, uid)[source]
Sends a transaction
-
ensicoin.
wait_for_flag
(flag)[source]
Blocks until a transaction is issued containing flag
-
ensicoin.
wait_for_pubkey
(pubKey)[source]
Blocks until a transaction is issued by pubKey
Golfer: a Gopher Server
-
gopher.golfer.
get_entries
()[source]
returns [(DirEntry)] as defined by the gopher protocol
-
gopher.golfer.
get_selectors
()[source]
returns a list of selectors for the known files
-
gopher.golfer.
main
()[source]
Starts the gopher server
Micro Tiling Client
Library usage
Module to generate mosaics using micro-tiling
-
client_library.client.
generate_mosaic
(host, on_invoice)[source]
Wraps manage_state to return a result, uses on_invoice when
needing to pay
-
client_library.client.
get_address
(host, job_id)[source]
Gets the ensicoin address needing fees for job
-
client_library.client.
launch_job
(host)[source]
Create a job for host and returns the job_id
-
client_library.client.
manage_state
(host, result)[source]
Iterator on the completion of a job generation at host,
Writes the mosaic in the list result
Command line usage
A command line usage is defined for convienience, however it needs progressbar2.
It is used by invoking client.py with arguments the REST api address for micro-tiling and an ensicoin address used to pay
a_pi
This is the module responsible for generating random segments using the digits of pi.
Segment generation
Generation of a bounded segment
-
a_pi.segment_generator.
random_segment
(x_max, y_max)[source]
Creates a segment with each endpoint x, y such that:
\[x \in [0;x\_max],y \in [0;y\_max]\]
Flask Application
Flask a_pi executing an action on each digit of pi sent
-
a_pi.app.
action
(db, job_id, job_current)[source]
Advances the state of the job job_id using the state job_current as
inital state and executes an action, here segment generation
-
a_pi.app.
close_db
(e=None)[source]
Closes the DB
-
a_pi.app.
create_app
(test_config=None)[source]
Generates the Flask application
-
a_pi.app.
get_db
()[source]
Get the db associated with the application
-
a_pi.app.
terminate
(db, job_id, mill_stub)[source]
Finishes the job job_id and forwards it to the mill_stub
Millllllll
This service is rotating segments on a gRPC call
Module for Rotating points
-
Millllllll.rotate.
decode
(s)[source]
Takes six bytes s and returns a point
-
Millllllll.rotate.
encode
(vect)[source]
Takes a point vect and converts it to six bytes
-
Millllllll.rotate.
go_through_brainfuck
(file_name, point, use_python=False)[source]
passes points throught the brainfuck file file_name
-
Millllllll.rotate.
mirror_and_turn
(points, use_python=False)[source]
points need to be tuples or lists of floats
-
Millllllll.rotate.
mirror_and_turn_segments
(segments, use_python=False)[source]
segments need to be tuples or lists of points
(will be returned as tuples),
points need to be tuples or lists of floats
Millllllll Reference
gRPC server to rotate segments
-
class
Millllllll.millllllll.
MillServicer
[source]
Serves a Millllllll gRPC server
-
Turn
(request, context)[source]
Turns segments contained in the RPC message request
-
Millllllll.millllllll.
segment_to_tuple
(segment)[source]
Transforms a segment from a dict to a tuple
-
Millllllll.millllllll.
serve
()[source]
Start the Millllllll server
-
Millllllll.millllllll.
write
(job, job_id)[source]
Write a job to a gopher served directory
while notifing a golfer server of the job_id
Unitator
This services clips segments fetched from a gopher server into the unit square, then writes them to firefox
Unitator Service
-
Unitator.unitator.
listen
()[source]
Start a Unitator server listening for notifications of
a golfer server
-
Unitator.unitator.
recv_data
(conn)[source]
Receive all data from a socket conn
-
Unitator.unitator.
send
(data, host, port)[source]
Sends data using a gopher connnection on host:port
-
Unitator.unitator.
unit
(segments, job_id)[source]
Clip segments of the job job_id into a unit square and forwards them
-
Unitator.unitator.
write
(job_id, text)[source]
Writes a text by an html form
Clipping Reference
Module clipping lines in the unit square
-
Unitator.clipping.
clip_right
(lines)[source]
Clip lines with a vertical line to the right at x = 1
-
Unitator.clipping.
clip_unit_square
(lines)[source]
Clip lines to fit in the unit square
-
class
Unitator.clipping.
p
(x, y)[source]
Class defining a two dimensional point in space
-
class
Unitator.clipping.
segment
(a, b)[source]
Class representing a segment by the two endpoints
-
Unitator.clipping.
turn_right
(lines)[source]
Rotates lines by 90 degrees
Translator
This translates and replicates segments from a inotify event and sends them by mail
Translator Reference
-
Translator.translator.
decode
(s)[source]
Takes six bytes s and returns a point (tuple of coordinates)
-
Translator.translator.
decode_nine
(s)[source]
Decode nine points from s
-
Translator.translator.
encode
(vect)[source]
Takes a vect and converts it to six bytes
-
Translator.translator.
go_through_brainfuck
(file_name, point, use_python=False)[source]
Passes point through the brainfuck file file_name
Returns a list of translated points
-
Translator.translator.
translate_segments
(segments, use_python=False)[source]
Translate and copies each segment from the list segments in all
eight directions
Translator Service
-
Translator.app.
create_app
(test_config=None)[source]
Launches the flask web application
-
Translator.app.
encrypt
(string, gpg)[source]
Encrypt the string in pgp encoded using the context gpg
-
Translator.app.
send
(host, segments, job_id, gpg)[source]
Sends the encoded segments to the next service by smtp
throught host encrypted using the gpg context
-
Translator.app.
translation
(segments, job_id, gpg)[source]
Creates replicas of the segments in the eight directions
Cruxingator
This service cuts all segments such that no two segments cross, and publishes the result in an ensicoin transaction
SMTP Server
-
class
Cruxingator.smtp_serv.
Handler
[source]
Handles SMTP requests
-
handle_DATA
(server, session, envelope)[source]
Handles the content of a mail
-
handle_RCPT
(server, session, envelope, address, rcpt_options)[source]
Refuse all mails not in @micro-tiling.tk
-
Cruxingator.smtp_serv.
decrypt
(string)[source]
Decrypts the string using gpg
Segment Spliting
-
class
Cruxingator.split.
Point
(pos)[source]
Points in two dimensions
-
get_pos
(precision=0.0003)[source]
Get a rounded position at precision level
-
merge
(other)[source]
Tells two points are equivalent
-
class
Cruxingator.split.
Segment
(a, b)[source]
Segment between two endpoints
-
intersect
(other)[source]
Calculate the intersection point beetween self and other
-
class
Cruxingator.split.
Vect
(x, y)[source]
Two dimensional Vector
-
norm2
()[source]
Squared norm of the vector
-
Cruxingator.split.
cut
(segments)[source]
Cuts the segments such that no two segments cross
-
Cruxingator.split.
find_intersections
(segments)[source]
Find all intersections between segments
-
Cruxingator.split.
generate_id_tuple
(points)[source]
Generates a tuple for each point (id, x, y, [id of linked])
-
Cruxingator.split.
pairs
(l)[source]
Iterate on pairs of segments
Solidator
This service works in two parts: a master program managing subprograms
Master
- signification of messages to solidator :
- r : the point is ready.
d : there is one less point of degree 1 alive.
e : a point process has ended.
-
class
Solidator.solidator.
Point
(pos)[source]
A two dimensional point whose pos is a Vect
-
get_pos
(precision=1e-10)[source]
Returns a position rounded up to precision
-
merge
(other)[source]
Merges with another Point
-
class
Solidator.solidator.
Segment
(a, b)[source]
A segment of two vectors
-
class
Solidator.solidator.
Vect
(x, y)[source]
A two dimensional vector
-
Solidator.solidator.
create_points
(point_list)[source]
Takes in a list of [(point_id, pos_x, pos_y, [list of neighbours’ ids]),…]
and output a list of Point
-
Solidator.solidator.
open_process
(point)[source]
Opens a process representing a point
tells it how many neighbours it should expect and its Point id
-
Solidator.solidator.
remove_deg_1
(points, job_id, multiprocess=True)[source]
Write an svg with only closed polygons displayed
Subprograms
processes are sent the IDs of their neighbours at start
once they have them, they start telling others if they have a degree of 1
and they listen for neighbours signaling they have a degree of 1
- signification of messages to point_processes :
- e : message comming from main meaning it is now time to write
- the result.
- d <neighbour_id> : the neighbouring point with neighbour_id
- had only one neighbour left ‘alive’ and is therefore
now ‘dead’.
a : death acknowledge means the neighbour now knows the point is ‘dead’
- A <neighbour_id> <neighbour_x_pos> <neighbour_y_pos> : the
- corresponding neighbour is still ‘alive’ (sent after the neighbour
received a message ‘e’).
- D : a neighbour is ‘dead’ and no line should be displayed between the
- two points.
-
Solidator.point_process.
debug
(string, own_id)[source]
write a string in stderr and add the point’s own_id for clarity
-
Solidator.point_process.
main
()[source]
Waits for processes to die around you to check if you can survive
-
Solidator.point_process.
read_neighbours
(amount)[source]
Reads amount neighbours from stdin
-
Solidator.point_process.
read_position
()[source]
Reads a line from stdin and interprets it as a position
-
Solidator.point_process.
signal_death
(neighbour_messagers, own_id)[source]
Tells all neighbours of own_id death by neighbour_messagers’ fifo files
-
Solidator.point_process.
svg_coord
(x)[source]
Returns the coordinate in svg space for x
-
Solidator.point_process.
svg_output
(message, own_id, position, res)[source]
Outputs to res the svg line from position to the neighbour
indicated in message if own_id is smaller than
the neighbour’s id (this is to avoid writing twice the same line)
-
Solidator.point_process.
who_am_i_at_the_end
(is_dead, neighbour_messagers, own_id, position)[source]
Tells all neighbours by neighbour_messagers
the vertex own_id and position if not is_dead,
else send them D