Esempio n. 1
0
def deserialize_transitions(data: dict) -> Dict[Binding, Transition]:
    transitions_by_binding = {}
    for binding in Binding:
        transition = data.get(binding.value, None)
        if transition is None:
            continue
        transitions_by_binding[binding] = Transition(
            starting_fidl=State(transition[0]['fidl']),
            starting_src=from_src_filename(transition[0]['source']),
            changes=tuple(deserialize_change(c) for c in transition[1:]))
    return transitions_by_binding
Esempio n. 2
0
import os
from nosecone_library.specific_noses import BNC50J
from bodytubes.semroc import bt20, bt50, bt60
from bodytubes.modelrockets_us import _29mm
from nosecone.nosecone_bases import HollowBaseWithScrewHole

from misc.utils import render_to_file
from transitions import Transition
if __name__=="__main__":
    basedir = os.path.dirname(__file__)
    t=Transition(1.23975, bodytube1=_29mm, bodytube2=bt50, shoulder=.75, thickness = 1/16., bodytube3=bt20, open_end=True, fudge=0.02)
    render_to_file(t.transition, os.path.join(basedir,"bt50t.scad"))
    t=Transition(1.67725, bodytube1=bt60, bodytube2=_29mm, shoulder=.75, thickness = 1/16., bodytube3=bt50, open_end=True)
    render_to_file(t.transition, os.path.join(basedir,"29mmt.scad"))


    nc=BNC50J(thickness=1./16, scale_bodytube=_29mm)
    nc=HollowBaseWithScrewHole(nc, shoulder=0.75, screw_diameter=1 / 16., screw_length=0.25)
    render_to_file(nc.cone, os.path.join(basedir,"bt50n.scad"))
    nc=BNC50J(thickness=1./16, scale_bodytube=bt60)
    nc=HollowBaseWithScrewHole(nc, shoulder=0.75, screw_diameter=1 / 16., screw_length=0.25)
    render_to_file(nc.cone, os.path.join(basedir,"29mmn.scad"))


Esempio n. 3
0
from transitions import Transition
from transitions import Direction
from turing import TuringMachine

t0 = Transition("0", ("0", "0", "0"), "2", ("1", "4", "7"), [Direction.RIGHT, Direction.RIGHT, Direction.RIGHT])
t2 = Transition("2", ("0", "0", "0"), "3", ("2", "5", "8"), [Direction.RIGHT, Direction.RIGHT, Direction.RIGHT])
t3 = Transition("3", ("0", "0", "0"), "4", ("3", "6", "9"), [Direction.RIGHT, Direction.RIGHT, Direction.RIGHT])
t4 = Transition("4", ("2", "5", "8"), "4", ("3", "6", "9"), [Direction.RIGHT, Direction.RIGHT, Direction.RIGHT])

t0.toggle_start()
t4.toggle_accept()

states = ["0", "2", "3", "4"]
transitions = [t0, t2, t3, t4]
initial_state = "0"
accept_state = "4"
reject_state = None
initial_tape = [['0','0','0'], ['0','0','0'], ['0','0','0']]

tm = TuringMachine(states, transitions, initial_state, accept_state, reject_state, initial_tape)

print("Tansitions....")
tm.print_transitions()
print("Initial tapes...")
tm.print_tapes()
tm.execute()
print("Final tapes...")
tm.print_tapes()
Esempio n. 4
0
from transitions import Transition
from transitions import Direction
from turing import TuringMachine

t0 = Transition("0", "1", "2", "6", Direction.RIGHT)
t2 = Transition("2", "6", "2", "7", Direction.RIGHT)

t0.toggle_start()
t2.toggle_accept()

states = ["0", "2"]
transitions = [t0, t2]
initial_state = "0"
accept_state = "2"
reject_state = None
initial_tape = ['1', '1', '0']

tm = TuringMachine(states, transitions, initial_state, accept_state,
                   reject_state, initial_tape)

tm.print_transitions()
tm.print_tape()
tm.execute()
tm.print_transitions()
tm.print_tape()