コード例 #1
0
ファイル: a.py プロジェクト: vaderkvarn/aoc19
 def __init__(self, in_q, out_q, addr):
     self.in_q = in_q
     self.out_q = out_q
     self.addr = addr
     self.msg = []
     self.in_q.append(self.addr)
     self.comp = Comp(p[:], self.get_input, self.cb)
コード例 #2
0
ファイル: a.py プロジェクト: vaderkvarn/aoc19
def run():
    prog = []
    row = []

    def get_input(comp):
        nonlocal prog
        if len(prog) == 0:
            prog = list("".join(input()))
            if "".join(prog) == "save":
                print("saving")
                prog = []
                save(comp.p)
                return "\n"
            if "".join(prog) == "load":
                print("loading")
                prog = []
                comp.p = load()
                return "\n"
            prog.append('\n')
        return prog.pop(0)

    def cb(comp, x):
        nonlocal row
        if isinstance(x, int):
            print(x)
            exit()
        if x == '\n':
            print("".join(row))
            row = []
        else:
            row.append(x)

    c = Comp(p, get_input, cb, ascii_mode=True)
    c.run()
コード例 #3
0
 def __init__(self, temp, cool_temp):
     name = 'ORCC'
     mixu = FlibeGrTU(cool_temp)
     Comp.__init__(self,
                   temp,
                   name, [GraphiteCoolMixT(cool_temp)],
                   fill=mixu)
コード例 #4
0
ファイル: ss_runtime.py プロジェクト: vaderkvarn/aoc19
def run():
    prog = open(sys.argv[2], "r").readlines()
    prog = [row for row in prog if row[0] != '#']
    prog = list("".join(prog))
    row = []
    m = []

    def get_input(comp):
        nonlocal prog
        return prog.pop(0)

    def cb(comp, x):
        nonlocal row
        nonlocal m
        if isinstance(x, int):
            print(x)
            exit()
        if x == '\n' and len(row) > 0:
            m.append(row)
            row = []
        else:
            row.append(x)

    c = Comp(p, get_input, cb, ascii_mode=True)
    c.run()
    for row in m:
        print("".join(row))
コード例 #5
0
    def __init__(self,
                 fpb_prop,
                 cool_temp,
                 dir_name='serp_input/',
                 name='FuelZone',
                 packing_fraction=0.6):
        self.gen_dir_name = dir_name

        random = False
        if "act" in name:
            random = name[-1]
        fpb_list = self.create_a_pb_unit_cell(fpb_prop, name, random)
        self.unit_cell = FuelUnitCell(fpb_list,
                                      cool_temp,
                                      packing_fraction=packing_fraction,
                                      dir_name=dir_name,
                                      random=random)
        self.unit_cell_lat = PBedLat(self.unit_cell,
                                     self.unit_cell.pitch,
                                     dir_name=dir_name,
                                     random=random)
        Comp.__init__(self,
                      fpb_list[0].temp,
                      name,
                      self.unit_cell_lat.mat_list,
                      gen=Gen(dir_name),
                      fill=self.unit_cell_lat)
コード例 #6
0
ファイル: both.py プロジェクト: vaderkvarn/aoc19
def run_a():
    def on_exit(comp):
        print(len(visited))

    visited[cur] = 0
    c = Comp(p, get_input, cb, on_exit)
    c.run()
コード例 #7
0
    def create(self, payload_file, template_file, special_char,
               payload_placeholder, rate, outputname, subs1, string1,
               compilers, option1_gcc, option2_gcc, option1_gplusplus,
               option2_gplusplus, value1_gcc, value2_gcc, value1_gplusplus,
               value2_gplusplus, hexed_filename):

        ops1_gcc = []
        ops2_gcc = []
        ops1_gplusplus = []
        ops2_gplusplus = []
        ops1_gcc.extend([option1_gcc, value1_gcc])
        ops1_gplusplus.extend([option1_gplusplus, value1_gplusplus])
        ops2_gcc.extend([option2_gcc, value2_gcc])
        ops2_gplusplus.extend([option2_gplusplus, value2_gplusplus])

        config_filename = hexed_filename + ".conf.json"

        path = os.path.join(app.config['UPLOAD_FOLDER'], hexed_filename,
                            "config", config_filename)

        self.conf.setTemplatePath(template_file)
        self.conf.setPayloadPath(payload_file)
        self.conf.setSpecialChar(special_char)
        self.conf.setPlaceholderPayload(payload_placeholder)

        rate = float(rate)
        self.conf.setFreq(rate)
        self.conf.setOut(outputname)
        for subs, string in zip(subs1, string1):
            self.conf.addToSub((subs, string))
        comps = []
        for compiler in compilers:
            comp = Comp()
            comp.setName(compiler)
            comp.setPath("edit")
            if compiler == "gcc":
                self.tmpOpt1.append(ops1_gcc)
                self.tmpOpt2.append(ops2_gcc)
            elif compiler == "g++":
                self.tmpOpt1 = []
                self.tmpOpt2 = []
                self.tmpOpt1.append(ops1_gplusplus)
                self.tmpOpt2.append(ops2_gplusplus)

            for t in self.tmpOpt1:
                comp.addOpt1(t)
            for t in self.tmpOpt2:
                comp.addOpt2(t)
            comps.append(comp)

        self.tmpOpt1 = []
        self.tmpOpt2 = []
        for comp in comps:
            self.listOfComp.append(comp)

        with open(path, "w") as f:
            tmp = str(self.conf)
            tmp = tmp.replace("\'", "\"")
            f.write(tmp)
        return config_filename
コード例 #8
0
ファイル: pb.py プロジェクト: xwa9860/FIG
 def __init__(self, triso, cg_temp, shell_temp, dir_name='serp_input/'):
     '''
     cg_temp: central graphite kernel temperature
     '''
     self.triso = triso
     self.tr_lat = TrisoLattice(self.triso)
     self.layer = [
         'CentralGraphite',
         'TrLat',
         'Shell']
     mat = [CentralGraphite(cg_temp), Shell(shell_temp)]
     mat.extend(self.tr_lat.mat_list)
     self.dr_config = {
         'CentralGraphite': 1.25114,  # cm
         'TrLat': 0.14886,  # cm
         'Shell': 0.1000  # cm
     }
     self.calculate_r()
     self.name = 'fuelPb'+self.tr_lat.name
     Comp.__init__(
         self,
         self.triso.temp,
         self.name,
         mat,
         FuelPbGen(dir_name))
コード例 #9
0
ファイル: a.py プロジェクト: vaderkvarn/aoc19
def run_auto(prog):
    prog = list("".join(prog))
    row = []
    p = load()

    def get_input(comp):
        nonlocal prog
        if len(prog) == 0:
            comp.pause()
            return "\n"
        if "".join(prog).startswith("load"):
            prog = prog[4:]
            comp.p = load("save_file")
            return "\n"
        return prog.pop(0)

    getting_inv = False

    def cb(comp, x):
        nonlocal row
        nonlocal getting_inv
        if x == '\n':
            s = "".join(row)
            if s.startswith("\"Oh"):
                print(int(s.split("typing ")[1].split(" ")[0]))
                exit()
            if getting_inv and s.startswith("-"):
                inv.append(s[2:])
            if s.startswith("Items in"): getting_inv = True
            row = []
        else:
            row.append(x)

    c = Comp(p, get_input, cb, ascii_mode=True)
    c.run()
コード例 #10
0
ファイル: pb.py プロジェクト: xwa9860/FIG
 def __init__(self, temp, dir_name='serp_input/'):
     self.r = 1.5   # cm
     self.temp = temp
     # self.filling = {'Graphite':Graphite(self.temp)}
     self.mat_list = [Graphite(temp)]
     self.name = 'Graphite'+str(self.temp)
     Comp.__init__(self, self.temp, self.name, self.mat_list, GPbGen(dir_name))
コード例 #11
0
ファイル: pb.py プロジェクト: GiudGiud/FIG
 def __init__(self, temp, dir_name='serp_input/'):
     self.r = 1.5  # cm
     self.temp = temp
     # self.filling = {'Graphite':Graphite(self.temp)}
     self.mat_list = [Graphite(temp)]
     self.name = 'Graphite' + str(self.temp)
     Comp.__init__(self, self.temp, self.name, self.mat_list,
                   GPbGen(dir_name))
コード例 #12
0
ファイル: triso.py プロジェクト: xwa9860/FIG
 def __init__(self, triso_particle, pf=0.4):
     '''pf: packing fraction
     '''
     self.triso_particle = triso_particle
     self.temp = triso_particle.temp
     self.name = 'trisoLat'+triso_particle.name
     self.pitch = ((4/3.0*math.pi*0.0405**3)/pf)**(1/3.0)
     self.mat_list = self.triso_particle.mat_list
     Comp.__init__(self, self.temp, self.name, self.mat_list,
                   TrisoLatticeGen())
コード例 #13
0
 def __init__(self, triso_particle, pf=0.4):
     '''pf: packing fraction
     '''
     self.triso_particle = triso_particle
     self.temp = triso_particle.temp
     self.name = 'trisoLat'+triso_particle.name
     self.pitch = ((4/3.0*math.pi*0.0405**3)/pf)**(1/3.0)
     self.mat_list = self.triso_particle.mat_list
     Comp.__init__(self, self.temp, self.name, self.mat_list,
                   TrisoLatticeGen())
コード例 #14
0
ファイル: pbed.py プロジェクト: xwa9860/FIG
 def __init__(self, pbed, pitch, dir_name='serp_input'):
     ''' arg:
         pbed: fuel pebble or graphite pebble unit cell
         pitch: pitch between two fcc unit cells
     '''
     name = 'pbedLat' + pbed.name
     self.pitch = pitch
     mat_list = pbed.mat_list
     self.pbed = pbed
     Comp.__init__(self, pbed.temp, name,
                   mat_list, gen=PBedLatGen(dir_name))
コード例 #15
0
ファイル: pbed.py プロジェクト: xwa9860/FIG
 def __init__(self,
              coolant, pb_list,
              dir_name='serp_input/',
              gen=PBedGen('serp_input/')):
     self.coolant = coolant
     self.pb_list = pb_list
     temp = coolant.temp
     mat_list = self.collect_mat()
     name = type(self).__name__
     Comp.__init__(self, temp, name,
                   mat_list, gen=gen)
コード例 #16
0
ファイル: pbed.py プロジェクト: GiudGiud/FIG
 def __init__(self,
              coolant, pb_list,
              dir_name='serp_input/',
              gen=PBedGen('serp_input/')):
     self.coolant = coolant
     self.pb_list = pb_list
     temp = coolant.temp
     mat_list = self.collect_mat()
     name = type(self).__name__
     Comp.__init__(self, temp, name,
                   mat_list, gen=gen)
コード例 #17
0
    def __init__(self,
                 coating_t_list,
                 fuel_list,
                 dr_config=None,
                 dir_name='serp_input'):
        '''
        coating_t_list: non_fuel coating layers temperatures in a list
        fuel_list: fuel material in a list
        dr_config: thickness of the layers
        '''
        if dr_config == None:
            assert len(coating_t_list) == 5, 'wrong temperature number %d' %(len(coating_t_list))
        elif dr_config =='homogenized':
            assert len(coating_t_list) == 1, 'wrong temperature number %d' %len(coating_t_list)
        else:
            print(ValueError, 'triso dr_config not implemented')

        # materials
        self.mat_list = []
        if not dr_config:
            for fuel in fuel_list:
                self.mat_list.append(fuel)
            self.mat_list.extend([Buffer(coating_t_list[0]),
                                  iPyC(coating_t_list[1]),
                                  SiC(coating_t_list[2]),
                                  oPyC(coating_t_list[3]),
                                  Matrix(coating_t_list[4])])
        elif dr_config == 'homogenized':
            for fuel in fuel_list:
                self.mat_list.append(fuel)
            self.mat_list.append(CMatrix(coating_t_list[0]))

        dr_list = []
        self.dr_config = {}
        # fuel layers radius
        for i, fuel in enumerate(fuel_list):
            tot_nb = len(fuel_list)
            tot_r = 0.02
            dr_list.append(((tot_r**3.0)/float(tot_nb)*(i+1))**(1/3.0) - ((tot_r**3.0)/float(tot_nb)*(i))**(1/3.0))
        if not dr_config:
            dr_list.extend([0.01, 0.0035, 0.0035, 0.0035])
        elif dr_config == 'homogenized':
            assert len(self.mat_list) == len(fuel_list) + 1, 'wrong length of mat_list'
        for i, dr in enumerate(dr_list):
            self.dr_config[self.mat_list[i].name] = dr

        assert len(coating_t_list) + len(fuel_list) == 1 + len(self.dr_config), '''
        coating_t_list and fuel_list for triso particle needs %d
        temperature values, got %d and %d''' % (len(self.dr_config),
                                                len(coating_t_list),
                                                len(fuel_list))
        name = 'triso'+fuel.name
        self.calculate_r()
        Comp.__init__(self, fuel.temp, name, self.mat_list, TrisoGen(dir_name))
コード例 #18
0
ファイル: pbed.py プロジェクト: GiudGiud/FIG
 def __init__(self, pbed, pitch, dir_name='serp_input',random=False):
     ''' arg:
         pbed: fuel pebble or graphite pebble unit cell
         pitch: pitch between two fcc unit cells
     '''
     name = 'pbedLat' + pbed.name
     self.pitch = pitch
     mat_list = pbed.mat_list
     self.pbed = pbed
     Comp.__init__(self, pbed.temp, name,
                   mat_list, gen=PBedLatGen(dir_name, random=random))
コード例 #19
0
ファイル: triso.py プロジェクト: xwa9860/FIG
    def __init__(self,
                 coating_t_list, 
                 fuel_list, 
                 dr_config=None, 
                 dir_name='serp_input'):
        '''
        coating_t_list: non_fuel coating layers temperatures in a list
        fuel_list: fuel material in a list
        dr_config: thickness of the layers
        '''
        if dr_config == None:
            assert len(coating_t_list) == 5, 'wrong temperature number %d' %(len(coating_t_list))
        elif dr_config =='homogenized':
            assert len(coating_t_list) == 1, 'wrong temperature number %d' %len(coating_t_list)
        else:
            raise ValueError, 'triso dr_config not implemented'

        # materials
        self.mat_list = []
        if not dr_config:
            for fuel in fuel_list:
                self.mat_list.append(fuel)
            self.mat_list.extend([Buffer(coating_t_list[0]),
                                  iPyC(coating_t_list[1]),
                                  SiC(coating_t_list[2]),
                                  oPyC(coating_t_list[3]),
                                  Matrix(coating_t_list[4])])
        elif dr_config == 'homogenized':
            for fuel in fuel_list:
                self.mat_list.append(fuel)
            self.mat_list.append(CMatrix(coating_t_list[0]))

        dr_list = []
        self.dr_config = {}
        # fuel layers radius
        for i, fuel in enumerate(fuel_list):
            tot_nb = len(fuel_list)
            tot_r = 0.02
            dr_list.append(((tot_r**3.0)/float(tot_nb)*(i+1))**(1/3.0) - ((tot_r**3.0)/float(tot_nb)*(i))**(1/3.0))
        if not dr_config:
            dr_list.extend([0.01, 0.0035, 0.0035, 0.0035])
        elif dr_config == 'homogenized':
            assert len(self.mat_list) == len(fuel_list) + 1, 'wrong length of mat_list'
        for i, dr in enumerate(dr_list):
            self.dr_config[self.mat_list[i].name] = dr

        assert len(coating_t_list) + len(fuel_list) == 1 + len(self.dr_config), '''
        coating_t_list and fuel_list for triso particle needs %d
        temperature values, got %d and %d''' % (len(self.dr_config),
                                                len(coating_t_list),
                                                len(fuel_list))
        name = 'triso'+fuel.name
        self.calculate_r()
        Comp.__init__(self, fuel.temp, name, self.mat_list, TrisoGen(dir_name))
コード例 #20
0
def run(p, main, funcs, vid):
    p[0] = 2
    [a, b, c] = funcs
    inputs = main + a + b + c + vid
    output = 0
    def cb(comp, x):
        nonlocal output
        output = x
    def get_input(comp):
        return inputs.pop(0)
    c = Comp(p, get_input, cb)
    c.run()
    print(output)
コード例 #21
0
def get_map(p):
    row = []
    m = []
    def cb(comp, x):
        nonlocal row
        nonlocal m
        if chr(x) == '\n' and len(row) > 0:
            m.append(row)
            row = []
        else: row.append(chr(x))
    c = Comp(p, None, cb)
    c.run()
    return m
コード例 #22
0
ファイル: blanket.py プロジェクト: xwa9860/FIG
 def __init__(self, pb_temp, cool_temp,
              packing_fraction=0.6,
              dir_name='serp_input/'):
     self.pb_temp = pb_temp
     self.cool_temp = cool_temp
     name = 'Blanket'
     self.unit_cell = GraphiteUnitCell(self.pb_temp, self.cool_temp,
                                       packing_fraction=packing_fraction,
                                       dir_name=dir_name)
     self.unit_cell_lat = PBedLat(self.unit_cell, self.unit_cell.pitch)
     Comp.__init__(self, pb_temp, name, self.unit_cell_lat.mat_list,
                   gen=Gen(dir_name),
                   fill=self.unit_cell_lat)
コード例 #23
0
def full_rescore(taskid: int,
                 background=False,
                 status=None,
                 autopublish=None,
                 compid=None,
                 user=None):
    from task import Task
    from comp import Comp
    from result import unpublish_result, publish_result
    task = Task.read(taskid)
    if background:
        print = partial(print_to_sse, id=None, channel=user)
        print('|open_modal')
        print('***************START*******************')
        refid, filename = task.create_results(mode='full',
                                              status=status,
                                              print=print)
        if autopublish:
            unpublish_result(taskid)
            publish_result(refid, ref_id=True)
            if compid:
                comp = Comp()
                comp.create_results(compid, name_suffix='Overview')
        print('****************END********************')
        print(f'{filename}|reload_select_latest')
        return None
    else:
        refid, filename = task.create_results(mode='full', status=status)
        if autopublish:
            unpublish_result(taskid)
            publish_result(refid, ref_id=True)
            if compid:
                comp = Comp()
                comp.create_results(compid, name_suffix='Overview')
        return refid
コード例 #24
0
    def create(cls, comp_id, ref_id=None):
        """ creates a FSDB Object from an AirScore competition
            input:
                - comp_id       int: comp_id event ID"""
        import time
        '''check comp is not an external event'''
        if is_ext(comp_id):
            # TODO probably with new logic we are able to create FSDB from ext comps?
            return None

        comp = Comp.from_json(comp_id, ref_id)
        '''check comp has already been scored'''
        if comp is None:
            print(f"Comp (ID {comp_id}) has not been scored yet.")
            return None

        timestamp = int(time.time() + comp.time_offset)
        dt = datetime.fromtimestamp(timestamp).strftime('%Y%m%d_%H%M%S')
        filename = '_'.join([comp.comp_code, dt]) + '.fsdb'
        '''get tasks and results'''
        tasks = []
        for tas in comp.tasks:
            task_id = tas['id']
            task = Task.create_from_json(task_id=task_id)
            tasks.append(task)

        fsdb = FSDB(comp=comp, filename=filename, tasks=tasks)
        return fsdb
コード例 #25
0
    def read(cls, fp, short_name=None, keep_task_path=False, from_CIVL=False):
        """ A XML reader to read FSDB files
            Unfortunately the fsdb format isn't published so much of this is simply an
            exercise in reverse engineering.

            Input:
                - fp:           STR: filepath
                - from_CIVL:    BOOL: look for pilot on CIVL database
        """
        """read the fsdb file"""
        try:
            tree = ET.parse(fp)
            root = tree.getroot()
        except ET.Error:
            print("FSDB Read Error.")
            return None

        pilots = []
        tasks = []
        """Comp Info"""
        print("Getting Comp Info...")
        fs_comp = root.find('FsCompetition')
        comp = Comp.from_fsdb(fs_comp, short_name)
        """Formula"""
        comp.formula = Formula.from_fsdb(fs_comp)
        comp.formula.comp_class = comp.comp_class
        """Pilots"""
        print("Getting Pilots Info...")
        if from_CIVL:
            print('*** get from CIVL database')
        p = root.find('FsCompetition').find('FsParticipants')
        for pil in p.iter('FsParticipant'):
            pilot = Participant.from_fsdb(pil, from_CIVL=from_CIVL)
            # pp(pilot.as_dict())
            pilots.append(pilot)

        comp.participants = pilots
        """Tasks"""
        print("Getting Tasks Info...")
        t = root.find('FsCompetition').find('FsTasks')
        for tas in t.iter('FsTask'):
            '''create task obj'''
            task = Task.from_fsdb(tas, comp.time_offset, keep_task_path)
            '''check if task was valid'''
            if task is not None:
                if not task.task_path:
                    task.create_path()
                # task.time_offset = int(comp.time_offset)
                """Task Results"""
                node = tas.find('FsParticipants')
                if node is not None:
                    task.pilots = []
                    print("Getting Results Info...")
                    for res in node.iter('FsParticipant'):
                        '''pilots results'''
                        pilot = FlightResult.from_fsdb(res, task)
                        task.pilots.append(pilot)
                tasks.append(task)

        return cls(comp, tasks, fp)
コード例 #26
0
def run():
    cs = [Comp(fname='inp.txt').add_inputs([i]) for i in range(50)]
    ms = defaultdict(list)
    n = []
    ns = set()
    while True:
        na = True
        for i in range(50):
            m = [-1]
            if ms[i]:
                na = False
                m = ms[i].pop(0)
            cs[i].add_inputs(m)
            o = cs[i].last_outputs
            if o:
                na = False
            for a, x, y in zip(o[::3], o[1::3], o[2::3]):
                if a == 255:
                    n = [x, y]
                    continue
                ms[a].append([x, y])
        if na:
            y = n[1]
            if y in ns:
                return y
            ns.add(y)
            ms[0].append(n)
コード例 #27
0
def solve(code):
    c = Comp(a);
    for i in code:
        for j in [ord(c) for c in i]:
            c.add_one_input(j)
        c.add_one_input(10)
    c.run()
    o = c.get_all_outputs()
    for output in o:
        if output <= 127:
            print(chr(output), end="")
        else:
            print("ans:", output)
コード例 #28
0
 def create_participants(comp_id: int):
     """ create FSDB file with participants, to use for Flymaster Livetracking setup on lt.flymaster.net site"""
     from compUtils import get_participants
     fsdb = FSDB()
     fsdb.comp = Comp.read(comp_id)
     fsdb.filename = f"{fsdb.comp.comp_name.replace(' - ', '_').replace(' ', '_')}_participants.fsdb"
     fsdb.comp.participants = get_participants(comp_id)
     return fsdb.to_file(participants_fsdb=True)
コード例 #29
0
def solve2():
    threshold = 100
    upleft_corners = {}
    y = 1200  # guessing that first suitable is after row 1200
    x_start = 0
    while True:
        hits = 0
        last_hit = 0
        x = x_start
        while True:
            c = Comp(a)
            c.add_one_input(x)
            c.add_one_input(y)
            c.run()
            o = c.get_one_output()
            if o == 1:
                if hits == 0:
                    x_start = x
                    possible_corner = y - threshold + 1
                    if (possible_corner in upleft_corners
                            and upleft_corners[possible_corner] == x):
                        return 10000 * x + possible_corner
                hits += 1
                last_hit = x
            if o == 0 and hits != 0:
                break
            x += 1
        if hits >= threshold:
            upleft_corners[y] = last_hit - threshold + 1
        y += 1
コード例 #30
0
ファイル: ctrl.py プロジェクト: ozne23/AVevasion-WebWrapping
    def updateComp(self, top, e, list, index):
        comp = Comp()
        if len(e[0].get()) != 0 and len(e[1].get()) != 0:
            from gui import Gui
            comp.setName(e[0].get())
            comp.setPath(e[1].get())
            
            for t in self.tmpOpt1:
                comp.addOpt1(t)
            for t in self.tmpOpt2:
                comp.addOpt2(t)

            self.tmpOpt1 = []
            self.tmpOpt2 = []

            self.listOfComp[index] = comp
            Gui.remFromList(list, index)        
            Gui.addElToList(list, str(comp), index)
            Gui.destroyTop(top)
コード例 #31
0
ファイル: blanket.py プロジェクト: GiudGiud/FIG
 def __init__(self,
              pb_temp,
              cool_temp,
              packing_fraction=0.6,
              dir_name='serp_input/'):
     self.pb_temp = pb_temp
     self.cool_temp = cool_temp
     name = 'Blanket'
     self.unit_cell = GraphiteUnitCell(self.pb_temp,
                                       self.cool_temp,
                                       packing_fraction=packing_fraction,
                                       dir_name=dir_name)
     self.unit_cell_lat = PBedLat(self.unit_cell, self.unit_cell.pitch)
     Comp.__init__(self,
                   pb_temp,
                   name,
                   self.unit_cell_lat.mat_list,
                   gen=Gen(dir_name),
                   fill=self.unit_cell_lat)
コード例 #32
0
ファイル: both.py プロジェクト: vaderkvarn/aoc19
def run_b():
    def on_exit(comp):
        max_x = 0
        max_y = 0
        for (x, y) in visited:
            if x >= max_x: max_x = x + 1
            if y >= max_y: max_y = y + 1
        print('P2', max_x, max_y, 1)
        for y in range(max_y):
            for x in range(max_x):
                if (x, y) in visited:
                    print(visited[(x, y)], end=' ')
                else:
                    print(0, end=' ')
            print()

    visited[cur] = 1
    c = Comp(p_orig, get_input, cb, on_exit)
    c.run()
コード例 #33
0
ファイル: fuel.py プロジェクト: xwa9860/FIG
 def __init__(self,
              fpb_prop,
              cool_temp,
              dir_name='serp_input/',
              name = 'FuelZone',
              packing_fraction=0.6):
     self.gen_dir_name = dir_name
     fpb_list = self.create_a_pb_unit_cell(fpb_prop, name)
     self.unit_cell = FuelUnitCell(fpb_list,
                                   cool_temp,
                                   packing_fraction=packing_fraction,
                                   dir_name=dir_name)
     self.unit_cell_lat = PBedLat(self.unit_cell,
                                  self.unit_cell.pitch,
                                  dir_name=dir_name)
     Comp.__init__(self, fpb_list[0].temp, name,
                   self.unit_cell_lat.mat_list,
                   gen=Gen(dir_name),
                   fill=self.unit_cell_lat)
コード例 #34
0
ファイル: ctrl.py プロジェクト: ozne23/AVevasion-WebWrapping
    def checkComp(self, top, e, list):
        from gui import Gui
        comp = Comp()
        if len(e[0].get()) != 0 and len(e[1].get()) != 0:
            comp.setName(e[0].get())
            comp.setPath(e[1].get())

            for t in self.tmpOpt1:
                comp.addOpt1(t)
            for t in self.tmpOpt2:
                comp.addOpt2(t)

            self.tmpOpt1 = []
            self.tmpOpt2 = []   

            self.listOfComp.append(comp)        
            Gui.addElToList(list, str(comp))
            Gui.destroyTop(top)
        else:
            Gui.alertErr("Error", "Fill obligatory fields", top)
コード例 #35
0
class Worker():
    def __init__(self, in_q, out_q, addr):
        self.in_q = in_q
        self.out_q = out_q
        self.addr = addr
        self.msg = []
        self.in_q.append(self.addr)
        self.comp = Comp(p[:], self.get_input, self.cb)
    
    def get_input(self, comp):
        if len(self.in_q) == 0:
            comp.pause()
            return -1
        
        return self.in_q.popleft()
    def cb(self, comp, x):
        self.msg.append(x)        
        if len(self.msg) == 3:
            self.out_q.append(tuple(self.msg))
            self.msg = []
    def run(self):
        self.comp.run()
コード例 #36
0
ファイル: d17.py プロジェクト: otahontas/adventofcode
def first():
    global grid
    global w
    global h
    c = Comp(a)
    c.run()

    sa = []
    while c.outputs:
        sa.append(chr(c.get_one_output()))

    s = "".join(sa)
    grid = s.splitlines()
    grid = grid[:-1]

    w = len(grid[0])
    h = len(grid)

    def is_intersection(y, x):
        if y < 1 or x < 1 or y > h - 2 or x > w - 2:
            return False
        if (grid[y][x] == "#" and grid[y - 1][x] == "#"
                and grid[y + 1][x] == "#" and grid[y][x - 1] == "#"
                and grid[y][x + 1] == "#"):
            return True
        return False

    ans = 0
    start = (0, 0)

    for y in range(h):
        for x in range(w):
            if grid[y][x] == "^":
                start = (y, x)
            if is_intersection(y, x):
                ans += y * x

    print(ans)
    return start
コード例 #37
0
ファイル: pb.py プロジェクト: GiudGiud/FIG
 def __init__(self,
              triso,
              cg_temp,
              shell_temp,
              dir_name='serp_input/',
              random=False):
     '''
     cg_temp: central graphite kernel temperature
     '''
     self.triso = triso
     self.tr_lat = TrisoLattice(self.triso)
     self.layer = ['CentralGraphite', 'TrLat', 'Shell']
     mat = [CentralGraphite(cg_temp), Shell(shell_temp)]
     mat.extend(self.tr_lat.mat_list)
     self.dr_config = {
         'CentralGraphite': 1.25114,  # cm
         'TrLat': 0.14886,  # cm
         'Shell': 0.1000  # cm
     }
     self.calculate_r()
     self.name = 'fuelPb' + self.tr_lat.name
     Comp.__init__(self, self.triso.temp, self.name, mat,
                   FuelPbGen(dir_name, random))
コード例 #38
0
def run():
    cs = [Comp(fname='inp.txt').add_inputs([i]) for i in range(50)]
    ms = defaultdict(list)
    while True:
        for i in range(50):
            m = [-1]
            if ms[i]:
                m = ms[i].pop(0)
            cs[i].add_inputs(m)
            o = cs[i].last_outputs
            for a, x, y in zip(o[::3], o[1::3], o[2::3]):
                if a == 255:
                    return y
                ms[a].append([x, y])
コード例 #39
0
ファイル: corebarrel.py プロジェクト: xwa9860/FIG
 def __init__(self, temp):
     name = 'Corebarrel'
     ssu = SSU(temp)
     Comp.__init__(self, temp, name, [SS316(temp)], fill=ssu)
コード例 #40
0
ファイル: downcomer.py プロジェクト: xwa9860/FIG
 def __init__(self, temp):
     name = 'Downcomer'
     flibeu = FlibeU(temp)
     Comp.__init__(self, temp, name, [Flibe(temp)], fill=flibeu)
コード例 #41
0
ファイル: crcc_seg_univ.py プロジェクト: xwa9860/FIG
 def __init__(self, name='crcc_seg'):
   Comp.__init__(self, 0, name, [], gen=CRCCSegGen())
コード例 #42
0
ファイル: vessel.py プロジェクト: xwa9860/FIG
 def __init__(self, temp):
     name = 'VESSEL'
     ss = SSU(temp)
     Comp.__init__(self, temp, name, [SS316(temp)], fill=ss)
コード例 #43
0
ファイル: shield.py プロジェクト: xwa9860/FIG
 def __init__(self, temp):
     name = 'SHIELD'
     ss = ShieldU(temp)
     Comp.__init__(self, temp, name, [ShieldMat(temp)], fill=ss)