コード例 #1
0
ファイル: main.py プロジェクト: matcool/term-tris
def main(screen):
    framerate = 1 / 60
    dt = 0
    mode = modes.MainMenu(screen, Input, True)
    while True:
        start = time.perf_counter()
        Input.update()
        background(screen)
        ev = screen.get_event()
        key = ev.key_code if isinstance(ev, KeyboardEvent) else None
        if key in (ord('Q'), ord('q')):
            if hasattr(mode, 'quit'):
                mode.quit()
            return
        elif key in (ord('E'), ord('e')):
            if hasattr(mode, 'quit'):
                mode.quit()
            mode = modes.MainMenu(screen, Input)

        mode.run(key, dt)

        screen.refresh()
        end = time.perf_counter()
        if end - start < framerate:
            time.sleep(framerate - (end - start))
        dt = time.perf_counter() - start
コード例 #2
0
 def handleEvent(self, event):
     if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
         self.state += 1
         if self.state >= len(self.inputBoxes):
             self.state = 0
             self.evalResult()
             self.setShowing(False)
             Input.get().setInDialog(False)
             for b in self.inputBoxes:
                 b.setText('')
             GUI.get().topMenu().setShowing(False)
             return 'cursor'
     elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
         if self.state > 0:
             #self.inputBoxes[self.state].setText('')
             self.state -= 1
         else:
             self.setShowing(False)
             Input.get().setInDialog(False)
             for b in self.inputBoxes:
                 b.setText('')
             return 'cursor'
     elif event.type == pygame.KEYDOWN:
         if event.key == pygame.K_BACKSPACE:
             self.inputBoxes[self.state].delChar()
         if ((event.key >= pygame.K_0 and event.key <= pygame.K_9)
                 or (event.key >= pygame.K_a and event.key <= pygame.K_z)
                 or event.key == pygame.K_PERIOD
                 or event.key == pygame.K_MINUS):
             self.inputBoxes[self.state].append(chr(event.key))
コード例 #3
0
    def update(self, dt, entities):
        delta_time = float(dt) / 1000
        # if the player pressed z move faster
        if inp.Input().keyFired(pygame.K_z):
            self.x_speed = 275
        else:
            self.x_speed = 230

        # input on the x-axis
        self.vel.x = inp.Input().horizontal() * self.x_speed * delta_time

        # flips mario depending on the direction mario is moving

        if self.currentDirection != self.direction:
            if self.currentDirection == "L":
                self.image = self.images.idle[0]
            elif self.currentDirection == "R":
                self.image = self.images.idleR[0]
            self.direction = self.currentDirection

        # make ground check to check if player hasn't fallen off platform
        # input on the y-axis
        if self.jumpPressed != inp.Input().vertical():
            self.jumpPressed = not self.jumpPressed
            if self.onGround and self.jumpPressed:
                if self.direction == "L":
                    self.image = self.images.jumpL[0]
                elif self.direction == "R":
                    self.image = self.images.jumpR[0]
                self.vel.y += (-inp.Input().vertical() *
                               self.y_speed) * delta_time
                self.onGround = False
        else:
            self.vel.y += self.gravity * delta_time

        # code for animations
        self.current_time += delta_time
        if self.current_time >= self.animation_time:
            if self.vel.x < 0  and self.currentDirection == "L" \
             and self.onGround:
                self.current_time = 0
                self.index = (self.index + 1) % len(self.images.runL)
                self.image = self.images.runL[int(self.index)]
            elif self.vel.x > 0 and self.currentDirection == "R"\
             and self.onGround:
                self.current_time = 0
                self.index = (self.index + 1) % len(self.images.runR)
                self.image = self.images.runR[int(self.index)]
            else:
                if self.onGround:
                    if self.currentDirection == "L":
                        self.image = self.images.idle[0]
                    elif self.currentDirection == "R":
                        self.image = self.images.idleR[0]

        # seperating the movement into x and y movement
        if self.vel.x != 0:
            self.move_single_axis(int(self.vel.x), 0, entities, delta_time)
        if self.vel.y != 0:
            self.move_single_axis(0, int(self.vel.y), entities, delta_time)
コード例 #4
0
def exitPlay():  # If all lives are loss bot
    # returns to main menu
    Input.PressKey(Input.KEY_ESC)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_ESC)
    time.sleep(0.5)

    Input.PressKey(Input.KEY_DOWN)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_DOWN)
    time.sleep(0.5)

    Input.PressKey(Input.KEY_Z)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_Z)
    time.sleep(0.5)

    Input.PressKey(Input.KEY_UP)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_UP)
    time.sleep(0.5)

    Input.PressKey(Input.KEY_Z)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_Z)
    time.sleep(0.5)
コード例 #5
0
ファイル: BankingApp.py プロジェクト: kumbhar-p/backup
def deposit():
	acc_num=Input.getinteger("Enter your account number:")
	if acc_num in BankDetails:
		amt=Input.getinteger("Enter amount to be deposited:")
		BankDetails[acc_num].deposit(amt)
	else:
		print acc_num,"does not exists"
コード例 #6
0
def inputs(skip=False, data_type = 'INV'):
    """
    Loads the inputs into a protocol buffer run serially
    :param skip: Whether to skip generating the protocol buffer
    :param data_type: ADH vs Pure DCIS run or Pure DCIS vs DCIS with invasion
    :return:
    """

    # Skip part 1 and 2 if the protobuff already exists
    if not skip:

        # Part 1: Load the raw images and save to protobuf
        if data_type == 'INV':
            Input.pre_process_DCISvsInv(FLAGS.box_dims)
            Input.pre_process_INV_new(FLAGS.box_dims)

        else:
            Input.pre_process_adh_vs_pure(FLAGS.box_dims)
            Input.pre_process_ADH_new(FLAGS.box_dims)

    else:
        print('-------------------------Previously saved records found! Loading...')

    # Part 2: Load the protobuff  -----------------------------
    print('----------------------------------------Loading Protobuff...')
    train = Input.load_protobuf()
    valid = Input.load_validation_set()

    return train, valid
コード例 #7
0
def startFromMenu():  # bot goes through menu to start the game
    Input.PressKey(Input.KEY_Z)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_Z)
    time.sleep(0.5)
    Input.PressKey(Input.KEY_Z)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_Z)
    time.sleep(1.5)
    Input.PressKey(Input.KEY_Z)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_Z)
    time.sleep(0.5)
    Input.PressKey(Input.KEY_Z)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_Z)
    time.sleep(0.5)
    Input.PressKey(Input.KEY_Z)
    print("press")
    time.sleep(0.2)
    Input.ReleaseKey(Input.KEY_Z)
    time.sleep(1)
コード例 #8
0
 def handleEvent(self, event):
     if event.type == pygame.KEYDOWN and event.key == pygame.K_RETURN:
         self.state += 1                
         if self.state >= len(self.inputBoxes):
             self.state = 0
             self.evalResult()
             self.setShowing(False)
             Input.get().setInDialog(False)
             for b in self.inputBoxes:
                 b.setText('')
             GUI.get().topMenu().setShowing(False)
             return 'cursor'
     elif event.type == pygame.KEYDOWN and event.key == pygame.K_ESCAPE:
         if self.state > 0:
             #self.inputBoxes[self.state].setText('')
             self.state -= 1
         else:
             self.setShowing(False)
             Input.get().setInDialog(False)
             for b in self.inputBoxes:
                 b.setText('')
             return 'cursor'
     elif event.type == pygame.KEYDOWN:
         if event.key == pygame.K_BACKSPACE:
             self.inputBoxes[self.state].delChar()
         if ((event.key >= pygame.K_0 and event.key <= pygame.K_9) or
             (event.key >= pygame.K_a and event.key <= pygame.K_z) or
             event.key == pygame.K_PERIOD or event.key == pygame.K_MINUS):
             self.inputBoxes[self.state].append(chr(event.key))
コード例 #9
0
def chuansongzhen():
    x, y = pyautogui.pLocateCenterOnScreen(
        r'C:\Users\Administrator\PycharmProjects\DNF_Automation\Downtown\Forward.png',
        region=(0, 0, 800, 600))
    pyautogui.moveTo(x + 200, y + 8)
    time.sleep(RandomV.rdp3())
    Input.click()
コード例 #10
0
ファイル: UI.py プロジェクト: joekane/DeepFriedSuperNova
    def draw(self):
        Render.clear_layer(5)
        self.opened = True
        print self.width, self.height



        x = 5
        y = 5

        button_text = 'Close'
        button = Button(button_text,
                        self.width / 2,
                        self.height - 3,
                        function=close_window,
                        target=Render.layers['overlay_console'])

        dragging = False
        click_x = None

        mouse = Input.mouse

        while True:

            Input.update()
            Render.clear_layer(Render.layers['overlay_console'])

            Render.draw_rect(Render.layers['overlay_console'], x, y,
                             self.width,
                             self.height,
                             frame=True,
                             f_color=terminal.color_from_argb(255, 100, 100, 255),
                             bk_color=terminal.color_from_argb(192, 32, 32, 128),
                             title="POP_UP TEST!")

            Render.print_rect(Render.layers['overlay_console'], x + 2, y + 2, self.width - 4, self.height - 4, self.text)

            if mouse.lbutton and x <= mouse.cx <= x + self.width and (mouse.cy == y or dragging):
                if click_x is None:
                    click_x = mouse.cx - x
                x = mouse.cx - click_x    # (width / 2)
                y = mouse.cy
                dragging = True
            else:
                dragging = False
                click_x = None

            if button.draw(x, y) == 'close':
                self.opened = False
                Render.clear_layer(Render.layers['overlay_console'])
                return

            # libtcod.console_flush()

            # graphics.draw_image(x, y, enlarge=True)
            # graphics.draw_image(x + 1, y + 1, enlarge=True)
            # graphics.clear()
            # graphics.draw_font(0,0)

            GameState.render_ui()
コード例 #11
0
ファイル: grep.py プロジェクト: Demilade/5143-OS-Fasanya
def grep(**kwargs):
    if Input.isParamsListEmpty(kwargs['params'], 2):
        return

    flags = Input.isFlagsListEmpty(kwargs['flags'])

    lines = []
    keywd = kwargs['params'][0].strip('\'')

    for fileName in kwargs['params'][1:]:
        file = Input.getFullFileName(fileName)

        if file[0]:
            with open(file[1], 'r') as _file:
                for line in _file:
                    if line.strip() and keywd in line.strip().lower():
                        lines.append(line.strip())

            if len(lines) != 0:
                if flags:
                    for line in lines:
                        print(line)
                else:
                    if kwargs['flags'][0] == '-l':
                        print('\'' + keywd + '\'' + ' was found in \'' +
                              file[1] + '\'\n')
                    else:
                        print('\'' + kwargs['flags'][0] + '\'' +
                              ' is not a recognized flag\n')
            else:
                print('\'' + keywd + '\'' + ' was not found in \'' + file[1] +
                      '\'\n')
        else:
            print(file[1])
            break
コード例 #12
0
def array_kind():
    n = Input.get_number_matrix()
    w = Input.get_number_weight()
    row = n
    column = n
    matrix = matrix_square(n, w)
    return matrix, row, column, w
コード例 #13
0
ファイル: copyFile.py プロジェクト: Demilade/5143-OS-Fasanya
def copyFile(**kwargs):
    if Input.isParamsListEmpty(kwargs['params']):
        return

    fileList = kwargs['params']

    file = Input.getFullFileName(fileList[0])
    if not file[0]:
        print(file[1])
        return

    if len(fileList) > 2:
        print('Too many files provided\n')
        return

    kwargs['params'] = [fileList[0]]

    cwd = Input.getCwd(fileList[1])

    if os.path.exists(cwd):
        newFile = open(fileList[1], 'w')
        newFile.write(cat.cat(False, **kwargs))
        newFile.close()
    else:
        print(fileList[1] + ' : path doesn' 't exist\n')
        return

    print(str(fileList[1]) + ' has been created\n')
コード例 #14
0
def tail(**kwargs):
    if Input.isParamsListEmpty(kwargs['params']):
        return

    file = Input.getFullFileName(kwargs['params'][0])
    
    if len(kwargs['params']) > 1 and str(kwargs['params'][1]).isdigit():
        noLines = int(kwargs['params'][1])
        noLines = noLines if noLines >= 0 else 5
    else:
        noLines = 5

    if file[0]:
        lines = []
        lineCounter = 0
        with open(file[1], 'r') as _file:
            for line in _file:
                if line.strip():
                    lines.append(line.strip())
                    lineCounter += 1
        lines = lines[lineCounter - noLines:]  

        for lastLines in lines:
            print (lastLines)
    else:
        print(file[1])
コード例 #15
0
 def update_kinematics(self):
     # Front/back
     if (Input.Hold(Input.Up)):
         self.acc[0] = 100
         self.acc[1] = 100
     elif (Input.Hold(Input.Down)):
         self.acc[0] = -100
         self.acc[1] = -100
     else:
         self.acc[0] = -self.vel[0] / 20
         self.acc[1] = -self.vel[1] / 20
     # Left.right
     if (Input.Hold(Input.Left)):
         self.acc[2] = -5
     elif (Input.Hold(Input.Right)):
         self.acc[2] = 5
     else:
         self.acc[2] = 0
     # Velocity
     self.vel[0] += self.acc[0] * 0.1
     self.vel[1] += self.acc[1] * 0.1
     self.vel[2] += self.acc[2] * 0.1
     # Resistance
     for i in range(0, 2, 1):
         self.vel[i] *= 0.90
         if (abs(self.vel[i]) < 0.3):
             self.vel[i] = 0
     # Position
     self.pos[0] += self.vel[0] * 0.1 * math.cos(self.pos[2])
     self.pos[1] += self.vel[1] * 0.1 * math.sin(self.pos[2])
     self.pos[2] += self.vel[2] * 0.1
     self.pos[2] *= 0.90
     if (abs(self.pos[2]) < 0.3):
         self.pos[2] = 0
コード例 #16
0
def run():
    global SKIP_GENERATION
    global SKIP_ROUND

    if Input.key_typed(pygame.K_s):
        SKIP_GENERATION = not SKIP_GENERATION

    if Input.key_typed(pygame.K_r):
        SKIP_ROUND = True

    if not SKIP_GENERATION and not SKIP_ROUND:
        if CURRENT_ROUND > Params.TOTAL_ROUNDS:
            evolve()

        tick()
        render()
    elif SKIP_GENERATION:
        while CURRENT_ROUND < Params.TOTAL_ROUNDS:
            tick()
            Input.process_events()
            if Input.key_typed(pygame.K_s):
                SKIP_GENERATION = False
                break

        if CURRENT_ROUND == Params.TOTAL_ROUNDS:
            evolve()
    elif SKIP_ROUND:
        next_round = CURRENT_ROUND + 1
        while CURRENT_ROUND is not next_round:
            tick()
        SKIP_ROUND = False
コード例 #17
0
ファイル: TestTest.py プロジェクト: nevillegrech/stdl
 def testSortDependencies2(self):
     cut=self.test
     i1,i2,i3,i4,i5=Input(),Input(),Input(),Input(),Input()
     i1.name,i2.name,i3.name,i4.name,i5.name='i1','i2','i3','i4','i5'
     cut.inputs={'i1':i1,'i2':i2,'i3':i3,'i4':i4,'i5':i5}
     order=cut.sortDependencies()
     assert len(order)==5,len(order)
     self.checkIfDependant(order,cut.inputs)
コード例 #18
0
ファイル: option_menu.py プロジェクト: PakhomCh/YL_PyGm
def input_menu():
    global h_color
    global color
    global screen
    screen.fill((0, 0, 0))
    pygame.font.init()

    font = pygame.font.Font("GB_boot.ttf", 20)

    text = ['KEYBOARD', 'MOUSE', 'BACK TO OPTIONS']
    options = []

    for txt in text:
        options.append(font.render(txt, False, color))

    dist_btw = options[0].get_height() + 5

    def centre_menu(surface, opt):
        menu_x = (screen.get_width() / 2 - opt.get_width() / 2)
        menu_y = (screen.get_height() / 2 - opt.get_height() / 2 - 30)
        return (menu_x, menu_y)

    selected = 0

    while True:
        for event in pygame.event.get():
            if event.type == QUIT:
                pygame.quit()
                sys.exit()
            if event.type == KEYDOWN:
                if event.key == K_UP:
                    selected -= 1
                if event.key == K_DOWN:
                    selected += 1

                if selected < 0:
                    selected = 0
                if selected > len(options) - 1:
                    selected = len(options) - 1

                if event.key == K_RETURN:
                    if selected == 0:
                        Input.set_inputdev(1)
                    elif selected == 1:
                        Input.set_inputdev(2)
                    elif selected == 2:
                        return

        screen.fill((0, 0, 0))
        for i in range(0, len(options)):
            x, y = centre_menu(screen, options[i])
            if i == selected:
                options[i] = font.render(text[i], False, h_color)
            else:
                options[i] = font.render(text[i], False, color)
            screen.blit(options[i], (x, (y + i * dist_btw)))

        pygame.display.update()
コード例 #19
0
def mouseResponseGameInit(event):
    if Ip.regionMonitor(event, button_site["single"], start_button_size):
        Et.game_state = GAMEINIT1
    if Ip.regionMonitor(event, button_site["setting"], start_button_size):
        Et.game_state = GAMESETTING
    if Ip.regionMonitor(event, button_site["help"], start_button_size):
        Et.game_state = GAMEHELP
    if Ip.regionMonitor(event, button_site["online"], start_button_size):
        Et.game_state = GAMEONLINEINIT1
コード例 #20
0
ファイル: Game.py プロジェクト: Leitast/CN-course-practice
 def __init__(self):
     self.input = Input()
     self.input.game = self
     self.output = Output()
     self.player = Player()
     self.server = Server()
     self.server.game = self
     self.locations = dict()
     self.event = multiprocessing.queues.SimpleQueue()
コード例 #21
0
ファイル: FNML.py プロジェクト: XMUDM/FNML
def readFeatures(filepath1, filepath2):
    drugFeature = []
    proteinFeature = []

    drugFeature = Input.readVectorFromFile(filepath1)

    proteinFeature = Input.readVectorFromFile(filepath2)

    return np.array(drugFeature), np.array(proteinFeature)
コード例 #22
0
ファイル: main.py プロジェクト: ken1882/ABSlib
def update_input():
    Input.update()
    # pause program
    if Input.is_trigger(Input.keymap.kF8, True):
        _G.Flags['paused'] ^= True
        print(f"Paused: {_G.Flags['paused']}")

    # terminate program
    elif Input.is_trigger(Input.keymap.kF9, True):
        _G.Flags['running'] = False
コード例 #23
0
ファイル: TestTest.py プロジェクト: nevillegrech/stdl
 def testSortDependencies4(self):
     cut=self.test
     i1,i2,i3,i4,i5=Input(),Input(),Input(),Input(),Input()
     i1.name,i2.name,i3.name,i4.name,i5.name='i1','i2','i3','i4','i5'
     i1.dependsOn=['i2','i4']
     i5.dependsOn=['i1']
     i4.dependsOn=['i2','i3']
     i2.dependsOn=['i3']
     i3.dependsOn=['i7']
     cut.inputs={'i1':i1,'i2':i2,'i3':i3,'i4':i4,'i5':i5}
     self.assertRaises(SemanticException,cut.sortDependencies)
コード例 #24
0
ファイル: main.py プロジェクト: ken1882/ABSlib
def main_loop():
    util.uwait(_G.UpdateDuration, False)

    update_basic()
    _G.CurScriptTick += 1

    if _G.CurScriptTick >= _G.ScriptUpdateTime:
        _G.CurScriptTick = 0
        if not _G.Flags['paused']:
            update_script()
            Input.clear_cache()
コード例 #25
0
def main():
    # Loop until the user clicks the close button.
    done = False
    loopCount = 0
    while not done:
        loopCount += 1
        Input.update()
        if(Input.Trigger(Input.Close)):
            done = True
        map.update()
        Graphics.update()
コード例 #26
0
ファイル: BankingApp.py プロジェクト: kumbhar-p/backup
def open_acc():
	global number
	acc_num=number
	name=Input.getstring("Enter your name:")
	acc_type=Input.getchar("Enter account type:s[savings],c[current]:")
	bal=0
	obj=Account(acc_num,name,acc_type,bal)
	obj.showAccountDetails()
	BankDetails[acc_num]=obj
	print "Your account is created with account number",acc_num
	number+=1
コード例 #27
0
ファイル: W_diary.py プロジェクト: VetalCoder/Laba2_Zamyatin
def add_data():
    date = Input.get_date()
    temp = Input.get_temp()
    preasure = Input.get_preasure()
    humidity = Input.get_humidity()
    wspeed = Input.get_wspeed()
    wdirect = input('Enter wind direction (eg. SW or S): ')
    prec = input('Enter precipitations (eg. Rain or Snow): ')
    tmp = {date: [temp, preasure, humidity, wspeed, wdirect, prec]}
    weather.update(tmp)                                         # rewrite data that already exsist
    Open_file.save_data(weather, Configs.get_type())                                # save changes in file
    input('Press Enter to continue...')
コード例 #28
0
def mount():
    x, y = pyautogui.pLocateCenterOnScreen(
        r'C:\Users\Administrator\PycharmProjects\DNF_Automation\Downtown\Forward.png',
        region=(0, 0, 800, 600))
    if (y < 120) or (y > 450):
        Input.KeyPress(0x31)
        time.sleep(RandomV.rdp3())
        pyautogui.moveTo(592, 175)
        Input.click()
        time.sleep(7)
        Input.KeyPress(0x31)  # go to the center of Mount
    return
コード例 #29
0
ファイル: BankingApp.py プロジェクト: kumbhar-p/backup
def withdraw():
	acc_num=Input.getinteger("Enter your account number:")
	if acc_num in BankDetails:
		amt=Input.getinteger("Enter amount to be withdrawn:")
		if amt<0:
			print "Amount cannot be less than zero"
		elif amt<BankDetails[acc_num].getbal():
			BankDetails[acc_num].withdraw(amt)
		else:
			print "Insufficient funds"
	else:
		print acc_num,"does not exists"
コード例 #30
0
def inputs(training=True, skip=False):
    """
    Loads the inputs
    """

    if not skip: Input.pre_proc_localizations(FLAGS.box_dims, thresh=0.4)

    else:
        print(
            '-------------------------Previously saved records found! Loading...'
        )

    return Input.load_protobuf_class(training)
コード例 #31
0
def main():

	#Input
	config=Input.load_config("appconfig.yaml")
	employee_list=Input.generate_employee_data(config,Input.get_current_payperiod())
	
	#Process
	for employee in employee_list:
		employee.process_employee_vcp()

	#Output
	print(Output.serialize(employee_list))
	Output.save_to_db(config["db_setting"],employee_list)
コード例 #32
0
ファイル: View.py プロジェクト: BenPerson/UlDunAd
 def pushScene(self, scene):
     try:
         Input.resetKeyPresses()
         ImgObj.clickableObjs = []
         if scene == "TestScene":
             scene = TestScene(self.engine)
         elif scene == "ParticleTest":
             scene = ParticleTest(self.engine)
         else:
             scene = WorldScenes.create(self.engine, scene)
         self.addScene = scene
     except ImportError:
         print scene + " has not yet been implemented or does not exist"
コード例 #33
0
def inputs(skip=False):
    """
    This function loads our raw inputs, processes them to a protobuffer that is then saved and
    loads the protobuffer into a batch of tensors
    """

    # To Do: Skip part 1 and 2 if the protobuff already exists
    if not skip: Input.save_examples(FLAGS.box_dims)

    print('----------------------------------------Loading Protobuff...')
    train = Input.load_protobuf()
    valid = Input.load_validation_set()

    return train, valid
コード例 #34
0
def completeQuest():
    Input.KeyPress(0x01)
    pyautogui.moveTo(301, 527)
    Input.click()
    try:
        x, y = pyautogui.locateCenterOnScreen(
            r'C:\Users\Administrator\PycharmProjects\DNF_Automation\Downtown'
            r'\QuestCompleted1.png',
            region=(0, 0, 800, 600))
        pyautogui.moveTo(x, y)
        Input.click()
    except:
        Login.restart()
    return
    def get_next_input(self, history):
        # refine the range to values that have a distance of at most kappa_i to the standard trace we picked
        close_values = self.input_distance.get_input_symbols_close_to_trace(
            self.standard_trace, history)

        if close_values.is_empty():
            # if there are no close values, get the set of all inputs
            input_domain = self.input_distance.get_values_domain()

            # return any of them
            return Input(input_domain.get_random_value())
        else:
            # pick any of the close values
            return Input(close_values.get_random_value())
コード例 #36
0
ファイル: Supervised.py プロジェクト: ving1/DinoML
def run():
    time.sleep(1)
    with tf.Session() as sess:
        saver.restore(sess, "models/supervised/model.ckpt")
        print 'Starting...'
        Input.Reset(keyboard)
        while 1:
            im = np.reshape(getScrn(), [1, 10, 40, 1])
            a = sess.run(output, feed_dict={x_in : im})
            if a == [[0]]:
                Input.Wait(keyboard)
            else:
                Input.Up(keyboard)
            print a
コード例 #37
0
ファイル: engine.py プロジェクト: BenPerson/UlDunAd
    def run(self):
        global finished

        # main event loop
        Input.update()
        self.finished = Input.finished

        self.viewport.run()
        Input.reset()
        self.clock.tick(FPS)
        self.currentFPS = int(self.clock.get_fps())
        
        #fps counter is in the title bar
        pygame.display.set_caption(caption % (self.currentFPS))
コード例 #38
0
ファイル: W_diary.py プロジェクト: VetalCoder/Lab1_Zamyatin
def add_data():
#add data to our weather diary#
    date = Input.get_Date()
    temp = Input.get_temp()
    preasure = Input.get_preasure()
    humidity = Input.get_humidity()
    wspeed = Input.get_wspeed()
    wdirect = input('Enter wind direction (eg. SW or S): ')
    prec = input('Enter precipitations (eg. Rain or Snow): ')
    tmp = {date:[temp, preasure, humidity, wspeed, wdirect, prec]}
	#rewrite data that already exsist
    weather.update(tmp) 
	#save changes in file
    Open_file.save_data(weather)                               
    tmp = input('Adding/Editing Successful. Press Enter to continue...')
コード例 #39
0
ファイル: rm.py プロジェクト: Demilade/5143-OS-Fasanya
def rm(**kwargs):
    if Input.isParamsListEmpty(kwargs['params']):
        return

    file = Input.getFullFileName(kwargs['params'][0])

    if file[0]:
        filePath = os.getcwd() + '\\' + file[1]
    else:
        print(file[1])
        return

    print('deleting file...........')
    os.remove(filePath)
    print(file[1] + ' successfully deleted!')
コード例 #40
0
ファイル: Gamess.py プロジェクト: jjwilke/PySkyNet
 def getInputZMatrix(self):
     try:
         data_section = re.compile("INPUT CARD.*?DATA(.*?)END", re.DOTALL).search(self.fileText).groups()[0] 
         xyz = self.getInitialXYZ()
         atom_list = []
         for atom in xyz: atom_list.append(atom[0])
         #build the regular expression
         regExp = []
         for atom in atom_list:
             regExp.append( r" INPUT CARD>(%s.*?)\n" % atom )
         regExp = "".join(regExp)
         zmat_tuple = re.compile(regExp).search(data_section).groups()
         #convert the zmat_lines into a list
         zmat_lines = []
         for entry in zmat_tuple: zmat_lines.append(entry)
         #now get anything that would be z matrix variable
         zmat_lines.append("Variables")
         regExp = "[A-Z\d]+\s*[=]\s*[-]?\d+[.]?\d*"
         vars = re.compile(regExp).findall(data_section)
         for var in vars:
             zmat_lines.append(var)
         zmat_text = "\n".join(zmat_lines)
         import Input
         atomList, zmatObject = Input.readZMatrix(zmat_text)
         return zmatObject
     except Exception, error:
         raise InfoNotFoundError("Z-Matrix")
コード例 #41
0
def manual_input():
    print('-------------------------------------------------------')
    matrix = Input.insert_matrix()
    print("Matrix: ")
    Output.print_matrix(matrix)
    result = Determinant.calculate_determinant(matrix)
    print('Determinant: ' + str(Output.round_number(result)))
コード例 #42
0
ファイル: Menu.py プロジェクト: VetalCoder/Laba2_Zamyatin
def print_menu():
    # run menu
    while True:
        clear()
        print('''      Weather diary

            1. Add/Edit Element
            2. Remove Element
            3. Show data
            4. Show data by month
            5. Exit
                      ''')
        ans = Input.get_choice()                # input menu key
        if ans == 1:
            W_diary.add_data()
        elif ans == 2:
            W_diary.rm_data()
        elif ans == 3:
            Output.show_data()
        elif ans == 4:
            Output.show_data_by_month()
        elif ans == 5:
            os._exit(1)
        else:
            print('Try again')
コード例 #43
0
ファイル: Controller.py プロジェクト: segonzal/pyVoxel
	def __init__(self):
		self.model = None
		self.view = None
		self.running = True

		self.t = pygame.time.get_ticks()
		self.input = Input()
		self.wireframe = False
コード例 #44
0
ファイル: W_diary.py プロジェクト: VetalCoder/Laba2_Zamyatin
def rm_data():
    date = Input.get_date()
    if date in weather:
        del weather[date]
        Open_file.save_data(weather, Configs.get_type())            # save changes in file
        input('Press Enter to continue...')
    else:
        input('Day in diary not found. Press Enter to continue...')
コード例 #45
0
 def handleEvent(self, event):
     if event.type == Input.CURSOR_ACCEPT:
         tagNum = self.getSelection()
         tagName = self.options[tagNum]
         self.setSelectedOption(0)
         self.setShowing(False)
         GUI.get().topMenu().setSelectedOption(0)
         GUI.get().topMenu().setShowing(False)
         GUI.get().editTagDialog().setShowing(True, tagName)
         Input.get().setInDialog(True)
         return 'editTag'
     elif event.type == Input.CURSOR_CANCEL:
         self.setShowing(False)
         return 'topMenu'
     elif event.type == Input.CURSOR_UP:
         self.moveUp()
     elif event.type == Input.CURSOR_DOWN:
         self.moveDown()
コード例 #46
0
ファイル: W_diary.py プロジェクト: VetalCoder/Lab1_Zamyatin
def rm_data():
# remove data from our diary
    date = Input.get_Date()
    if date in weather:
        del weather[date]
		#save changes in file
        Open_file.save_data(weather)            
        tmp = input('Removing Successful. Press Enter to continue...')
    else:
        tmp = input('Day in diary not found. Press Enter to continue...')
コード例 #47
0
def parameter_input(string_matrix):
    matrix = Input.get_matrix(string_matrix)
    result = Determinant.calculate_determinant(matrix)
    if str(result).lower().__contains__('e'):
        return Output.exponential_output(result)
    else:
        if result != 0:
            return Output.round_number(result)
        else:
            return 0
コード例 #48
0
ファイル: View.py プロジェクト: BenPerson/UlDunAd
    def detect(self, scene):
        for key, char in Input.getKeyPresses():
            scene.keyPressed(key, char)

        for press in Input.clicks:
            clickedImages = [image.getCollision(press) for image in ImgObj.clickableObjs]
            try:
                x = clickedImages.index(True)
                scene.buttonClicked(ImgObj.clickableObjs[x])
            except ValueError:
                continue
コード例 #49
0
ファイル: Output.py プロジェクト: VetalCoder/Laba2_Zamyatin
def show_data_by_month():
    # show weather during chosen month
    Menu.clear()
    year = Input.get_year()
    month = Input.get_month()  # reading month number
    count = 0
    print('Date\t\tTemp\tPreasure\tHumidity\tWind Speed\tWind Direction\tPrecipitation')
    for i in W_diary.weather:                       # show all data about thise month that exsist in diary
        if (i.year == year) & (i.month == month):
            print(i.isoformat() + '\t' +
                  str(W_diary.weather[i][0]) + '\t' +
                  str(W_diary.weather[i][1]) + '\t\t' +
                  str(W_diary.weather[i][2]) + '\t\t' +
                  str(W_diary.weather[i][3]) + '\t\t' +
                  str(W_diary.weather[i][4]) + '\t\t' +
                  str(W_diary.weather[i][5]))
            count += 1
    if not count:
        print('Diary is empty')
    input('Press Enter to continue...')
コード例 #50
0
 def handleEvent(self, event):
     if event.type == Input.CURSOR_ACCEPT:
         choice = self.getSelection()
         if choice == TopMenu.TILE_INFO:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().tileInfoDisplayer().setShowing(True)
             Input.get().setInDialog(True)
             return 'tileInfo'
         elif choice == TopMenu.SET_TAG:
             GUI.get().tagMenu().setShowing(True)
             return 'setTag'
         elif choice == TopMenu.EDIT_TAG:
             GUI.get().chooseTagMenu().setShowing(True)
             return 'chooseTag'
         elif choice == TopMenu.NEW_TAG:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().addTagDialog().setShowing(True)
             Input.get().setInDialog(True)
             return 'addTag'
         elif choice == TopMenu.SAVE:
             self.setShowing(False)
             self.setSelectedOption(0)
             GUI.get().saveDialog().setShowing(True)
             Input.get().setInDialog(True)
             return 'save'
     elif event.type == Input.CURSOR_CANCEL:
         self.setShowing(False)
         return 'cursor'
     elif event.type == Input.CURSOR_UP:
         self.moveUp()
     elif event.type == Input.CURSOR_DOWN:
         self.moveDown()
コード例 #51
0
ファイル: Controller.py プロジェクト: elfnor/mazes
def main():
    
    logic = bge.logic
    cont = logic.getCurrentController()
    own = cont.owner 
    if own['Control Scheme'] == 1:
        Input.controlScheme = 'ArrowKeys/WASD'
    if own['Control Scheme'] == 2:
        Input.controlScheme = 'WASD/Mouse'
    if own['Control Scheme'] == 3 and Input.controlScheme != 'Gamepad':
        status = Input.compatibleGamepadFound()
        if status == 'FOUND_AND_COMPATIBLE':
            Input.controlScheme = 'Gamepad'
        elif status == 'NOT_FOUND':
            print('Could not find gamepad. Reverting to previous control scheme')
        elif status == 'INCOMPATIBLE':
            print('Gamepad is incompatible. Reverting to previous control scheme')
コード例 #52
0
def run():
#    jobs, qcs, ycs, yts = Input.small_problem()
    jobs, qcs, ycs, yts = Input.big_problem()
    #===========================================================================
    # find job which satisfy cut's condition
    #===========================================================================
    cut = []
    for qc in qcs:
        is_first_loading_job_of_qc = True
        for i, j_id in enumerate(qc.job_seq):
            if j_id == qc.primary_j:
                #===============================================================
                # or if i == 0
                # it means first job of qc.job_seq
                #===============================================================
                cut.append(j_id)
            if jobs[j_id].type == 'loading':
                #===============================================================
                # all loading job will be in cut
                # and discharging job before finding first loading job will be in cut
                #===============================================================
                if is_first_loading_job_of_qc:
                    for x in range(i + 1):
                        if qc.job_seq[x] == qc.primary_j: continue
                        #=======================================================
                        # discharging job will be in cut
                        #=======================================================
                        cut.append(qc.job_seq[x])
                    is_first_loading_job_of_qc = False
                    continue
                #===============================================================
                # after is_first_loading_job_of_qc = False
                # all loading job will be into cut
                #===============================================================
                cut.append(j_id)
                
    stack_for_cut = []
    scheduled_jobs = [False for _ in jobs]
    agreeable_yt_of_job = [[True for x in range(len(yts))] for _ in jobs]
    # node is for data saving
    init_node = Node(cut, scheduled_jobs, agreeable_yt_of_job, qcs, ycs, yts)
    stack_for_cut.append(init_node)
    print [(job.id, job.type)for job in jobs]
コード例 #53
0
ファイル: main.py プロジェクト: alitteneker/CS268
def main(inputFile):

    # Parse the input file, loading images, depth data, etc.
    K, images = Input.readInput(inputFile)
    print "Loaded " + str(len(images)) + " images from file " + inputFile

    # Reconstruction: Combine each image's point cloud into a common point cloud
    pointCloud, transforms = reconstruction(K, images)
    print "Reconstruction finished!"

    # Manipulation: Add to or modify the contents of the point cloud
    manipulation(pointCloud)
    print "Manipulation finished!"

    # Hallucination: Generate new data from the composite point cloud
    hallucination( K, pointCloud, map( lambda t: np.linalg.inv( t.mat ), transforms ) )
    print "Hallucination finished!"

    print "Final step: Saving point cloud to disk . . ."
    pointCloud.outputToPLY("points.ply")
コード例 #54
0
ファイル: Engine.py プロジェクト: szhowardhuang/Wario-Land-3
	def __init__(self, screen_size, fps):
		self._tmx_root = None  # Will be used to store the currently loaded tmx-file:
		self._fps = fps # Save fps
		self._CLOCK = pygame.time.Clock() # Create pygame.Clock for fps-control
		self._draw_tile_ids = False # DEBUG: Draw all ids:

		# Create instance of Graphics-Engine:
		self.graphics = Graphics(self,screen_size)
		# Create instance of World:
		self.world = World(self)
		# Create instance of input-engine
		self.input = Input(self)
		# Create actors-controller
		self.actors = GameActorController(self)
		# Create sound-controller (not jet programmed...)
		self.sound = Sound(self)

		# Finally, first map (temporary):
		self._load_tmx("Forest_N1_1.tmx")

		# Var changed by self.load_new_level. If not false, in the next update cycle, the level gets loaded.
		self._load_new_level = False
コード例 #55
0
def eval_inputs():
  data_dir = FLAGS.data_dir
  images, labels = Input.eval_inputs(data_dir = data_dir, batch_size = 1)
  return images, labels
コード例 #56
0
def inputs():
  if not FLAGS.data_dir:
    raise ValueError('Source Data Missing')
  data_dir = FLAGS.data_dir
  images, labels = Input.inputs(data_dir = data_dir, batch_size = FLAGS.batch_size)
  return images, labels
コード例 #57
0
ファイル: UI.py プロジェクト: joekane/DeepFriedSuperNova
def beastiary(width=10, height=10, title=None, text=None):

    # calculate total height for the header (after auto-wrap) and one line per option
    if width is None:
        width = Constants.MAP_CONSOLE_WIDTH - 10

    if height is None:
        height = libtcod.console_get_height_rect(0, 0, 0, width, Constants.SCREEN_HEIGHT, text) + 7

    pop = libtcod.console_new(width, height)
    # print the header, with auto-wrap
    libtcod.console_set_default_foreground(pop, Constants.UI_PopFore)
    libtcod.console_set_default_background(pop, Constants.UI_PopBack)

    libtcod.console_print_frame(pop, 0, 0, width, height, clear=True,
                                flag=libtcod.BKGND_SET,
                                fmt=title)
    # blit the contents of "window" to the root console

    x = 0
    y = 0

    button_text = 'Click to Continue'
    button = Button(button_text,
                    width / 2,
                    height - 3,
                    function=close_window)

    img = libtcod.image_load('Images//cipher_warden_80x80_test_01.png')
    libtcod.image_set_key_color(img, Color(0, 0, 0))
    # show the background image, at twice the regular console resolution
    libtcod.image_blit_2x(img, pop, 9, 2)

    libtcod.console_set_default_foreground(pop, Constants.UI_PopFore)
    libtcod.console_set_default_background(pop, Constants.UI_PopBack)
    Render.print_rect(pop, 3, 3, width - 6, height, text)

    background = libtcod.console_new(Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT)
    libtcod.console_blit(0, 0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT, background, 0, 0, 1.0, 1.0)

    dragging = False

    click_x = None

    while True:
        Input.update()
        mouse = Input.mouse

        Render.blit(background, 0)
        # libtcod.console_blit(background, 0, 0, Constants.SCREEN_WIDTH, Constants.SCREEN_HEIGHT, 0, 0, 0, 1.0, 1.0)
        libtcod.console_blit(pop, 0, 0, width, height, 0, x, y, 1.0, .85)

        if mouse.lbutton and x <= mouse.cx <= x + width and (mouse.cy == y or dragging):
            if click_x is None:
                click_x = mouse.cx - x
            x = mouse.cx - click_x    # (width / 2)
            y = mouse.cy
            dragging = True
        else:
            dragging = False
            click_x = None

        if button.draw(x, y) == 'close':
            return
        libtcod.console_flush()
コード例 #58
0
import Input
Input.start()
コード例 #59
0
ファイル: engine.py プロジェクト: BenPerson/UlDunAd
#command line parser, if running python 2.7 use argparse, else fall-back to optparse
try:
    import argparse
except ImportError:
    import optparse as argparse

FPS = 60
caption = 'UlDunAd - Ultimate Dungeon Adventure [FPS: %i]'

if not os.path.exists(os.path.join("..", "uldunad.ini")):
    Configuration(os.path.join("..", "uldunad.ini")).save()
    runini = Configuration(os.path.join("..", "uldunad.ini"))
    runini.video.__setattr__("resolution", str(800) + "x" + str(600) + "x" + "W")
    runini.audio.__setattr__("volume", str(10))
    runini.save()
    Input.create(runini)
    Input.load(runini)
else:
    runini = Configuration(os.path.join("..", "uldunad.ini"))
    Input.load(runini)

w, h, fullscreen = runini.video.__getattr__("resolution").split("x")
w, h = float(w), float(h)
resolution = (int(w), int(h))
volume = int(runini.audio.__getattr__("volume"))

if fullscreen == "F":
    fullscreen = True
else:
    fullscreen = False