Exemplo n.º 1
0
def game_start():
    # initialisations
    pygame.init()
    status = functions.Status()
    st = Settings()

    screen = pygame.display.set_mode(st.screen_size)
    pygame.display.set_caption(st.screen_name)

    func = functions.Fucntions(st, screens.get_func_surface(screen, st))
    sqs = Squares(st, status, screens.get_sqs_surface(screen, st))

    AI = AI_player.AI()
    # main loop
    while True:
        pygame.display.flip()
        events.check_events(sqs, status, AI)
        if status.is_game_active():
            if sqs.update():
                screens.update_screen(screen, sqs, func, status, st)
        elif status.is_game_over():
            interface.game_over(screen, st)
        elif status.is_game_new():
            interface.start(screen, st)
        elif status.is_game_renew():
            AI_mode = status.new_AI
            status.refresh()
            status.game_status = status.ACTIVE
            sqs = Squares(st, status, screens.get_sqs_surface(screen, st))
            st = Settings()
            if AI_mode:
                status.AI = True
                sqs.st.adjust_for_AI()
        else:
            raise RuntimeError  # this should never happen
Exemplo n.º 2
0
def display(graph, steps=10, figure_texts=[], positions=None, callbacks={}):
    interface = create_visual_interface(graph,
                                        steps=steps,
                                        figure_texts=figure_texts,
                                        positions=positions,
                                        callbacks=callbacks)
    s = graph.get_node('s')
    interface.start()
Exemplo n.º 3
0
 def __init__(self, callback=None):
     config_options = {
         'wallet_path': "/sdcard/electrum/electrum.dat",
         'portable': True,
         'verbose': True,
         'auto_cycle': True
     }
     config = SimpleConfig(config_options)
     wallet = Wallet(config)
     interface = Interface(config)
     interface.register_callback(
         'connected', lambda: sys.stderr.write("Connected to " + interface.
                                               connection_msg + "\n"))
     if not interface.start(wait=True):
         print_msg("Not connected, aborting.")
         sys.exit(1)
     wallet.interface = interface
     verifier = WalletVerifier(interface, config)
     verifier.start()
     wallet.set_verifier(verifier)
     synchronizer = WalletSynchronizer(wallet, config)
     synchronizer.start()
     wallet.update()
     self.wallet = wallet
     self.interface = interface
     self._callback = callback
     self.password = None
Exemplo n.º 4
0
def main():
    a, b, c = interface.start()

    problem = Problem(a, b, c, len(data.heuristic), data.graph, data.heuristic)
    aux = problem.get_result()

    if aux is None:
        print('No way')
        return

    print('{')
    for i in aux:
        print(f'\t{i}')
    print('}')
Exemplo n.º 5
0
def init_testlib(apk_path, r_path = None, config_file = None, err_handler = None, skip_decode = False, skip_start = False, event_handler = None):
    if err_handler:
        connection.err_handler = err_handler
    if event_handler:
        connection.event_handler = event_handler
    if config_file is None:
        config.load_config()
    else:
        config.load_config(config_file = config_file)
    if not skip_decode:
        if r_path is None:
            widget.load_widgets_id(apk_path)
        else:
            widget.load_widgets_id_from_r(r_path)
    if not skip_start:
        return interface.start()
    else:
        return None
Exemplo n.º 6
0
 def __init__(self, callback = None):
     config_options = {'wallet_path':"/sdcard/electrum/electrum.dat", 'portable':True, 'verbose':True, 'auto_cycle':True}
     config = SimpleConfig(config_options)
     wallet = Wallet(config)
     interface = Interface(config)
     interface.register_callback('connected', lambda: sys.stderr.write("Connected to " + interface.connection_msg + "\n"))
     if not interface.start(wait=True):
         print_msg("Not connected, aborting.")
         sys.exit(1)
     wallet.interface = interface
     verifier = WalletVerifier(interface, config)
     verifier.start()
     wallet.set_verifier(verifier)
     synchronizer = WalletSynchronizer(wallet, config)
     synchronizer.start()
     wallet.update()
     self.wallet = wallet
     self.interface = interface
     self._callback = callback
     self.password = None
Exemplo n.º 7
0
def init_testlib(apk_path,
                 r_path=None,
                 config_file=None,
                 err_handler=None,
                 skip_decode=False,
                 skip_start=False,
                 event_handler=None):
    if err_handler:
        connection.err_handler = err_handler
    if event_handler:
        connection.event_handler = event_handler
    if config_file is None:
        config.load_config()
    else:
        config.load_config(config_file=config_file)
    if not skip_decode:
        if r_path is None:
            widget.load_widgets_id(apk_path)
        else:
            widget.load_widgets_id_from_r(r_path)
    if not skip_start:
        return interface.start()
    else:
        return None
        #Saves the starting location to a file.
        outfile = open(filename, 'wb')
        pickle.dump(startCoords, outfile)
        outfile.close()
    else:
        print(
            "  ERROR: Calibration failure, continuing assembly."
        )  #If there was an issue with the feedthrough distribution or pickup, exits calibration.
    return


time.sleep(3)

arduino.write(b'2\n')  #Strobes LEDs
print("\nPlease do not load assembly components until instructed.\n")
numberAssem = start()  #Prompts user for number of assemblies to be completed.
while numberAssem == 0:
    numberAssem = start()

time.sleep(1)

printer.startprint(home)  #Homes printer.
while printer.printing:
    time.sleep(1)
printer.send_now('G1 F1600 Z30')
time.sleep(3)
printer.send_now('G1 X140 Y20 Z30')  #Moves grippers out of the way.
time.sleep(8)
arduino.write(b'6\n')  #Opens preform grippers.
time.sleep(8)
Exemplo n.º 9
0
import interface as intf
import audio_fn as ad

if __name__ == "__main__":
        intf.start()
#       configure()
        ad.tts(str(intf.name)+", What do you intend to do?")
        intf.which_mode()
#       dict_crop()

	
	ad.remove_files()
Exemplo n.º 10
0
        self.product = prompted_info.get("product")
        self.amount = prompted_info.get("amount")
        self.material = prompted_info.get("material")
        self.printing_sheet_size = prompted_info.get("printing_sheet_size")
        # Status in prompted_info is always 1 or 2
        self._status = prompted_info.get("status")
        # Setting status to corresponding value with property (Ready../Waiting...)
        self.status = self._status
        self.comment = prompted_info.get("comment")
        self.addedDate = prompted_info.get("addedDate")
        self.job_id = prompted_info.get("job_id")
        self.priority = prompted_info.get("priority") 

    def _set_status(self, status_nro):
        if status_nro == "1":
            self._status = "Ready to Print"
        elif status_nro == "2":
            n = input("\nWaiting for what: ")
            self._status = "Waiting for: " + n

    def _get_status(self):
        return self._status

    status = property(_get_status, _set_status)

# Pistetään ohjelma pyörimään
RUNNING_LIST = JobList()
RUNNING_LIST.get_job_list_from_file()

start(RUNNING_LIST)
Exemplo n.º 11
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, datetime
import interface

# main
if __name__ == "__main__":

    interface.start()
Exemplo n.º 12
0
import interface as intf
import audio_fn as ad

if __name__ == "__main__":

    while (True):
        cmmd = ad.stt()
        if cmmd == None:
            continue
        elif ad.find(cmmd, "wake"):
            intf.start()
            ad.tts(str(intf.name) + ", What do you intend to do?")
            b = intf.which_mode()
            if b == 1:
                ad.tts(
                    "Ok, I am going to sleep. say wake up when you want my assistance again. Good bye."
                )
                continue
            elif b == 2:
                ad.tts("Ok, It was great to assist you.")
                break
            else:
                break
        else:
            ad.tts("Did you just said something?")
            continue
#       dict_crop()

    ad.remove_files()
Exemplo n.º 13
0
def main():
    pygame.init()
    pygame.mixer.init()
    screen=pygame.display.set_mode(config.ScreenSize)
    pygame.display.set_caption('GuguMelon\'s Mouse')
    # screen=InitGame()
    pygame.mixer.music.load(config.BgmPath)
    pygame.mixer.music.play(-1)
    audios={
        'CountDown':pygame.mixer.Sound(config.CountdownSoundPath),
        'Hammering':pygame.mixer.Sound(config.HammeringSoundPath)
    }
    font=pygame.font.Font(config.FontPath,40)
    BackImage=pygame.image.load(config.GameBackImagePath)
    start(screen,config.GameBeginImagePaths)
    HolePos=random.choice(config.HolePosition)
    ChangeHoleEvent=pygame.USEREVENT
    pygame.time.set_timer(ChangeHoleEvent,800)
    Mole=mole(config.MoleImagePaths,HolePos)
    hammer=Hammer(config.HammerImagePaths,(500,200))
    clock=pygame.time.Clock()
    score=0
    # print(score)
    flag=False
    # TimeRemain=40
    # print(TimeRemain)
    Timetime=round((61000+pygame.time.get_ticks()))
    # print('Timetime='+str(Timetime))
    while True:
        TimeRemain=round((Timetime-pygame.time.get_ticks())/1000.)
        print(TimeRemain)
        if TimeRemain==40 and not flag:
            HolePos=random.choice(config.HolePosition)
            Mole.reset()
            Mole.SetPosition(HolePos)
            pygame.time.set_timer(ChangeHoleEvent,650)
            flag=True
        elif TimeRemain==20 and flag:
            HolePos=random.choice(config.HolePosition)
            Mole.reset()
            Mole.SetPosition(HolePos)
            pygame.time.set_timer(ChangeHoleEvent,650)
            flag=False
        if TimeRemain==10:
            audios['CountDown'].play()
        if TimeRemain<0:
            break
        CountDownText=font.render('Time: '+str(TimeRemain),True,config.White)
        for event in pygame.event.get():
            if event.type==pygame.QUIT:
                pygame.quit()
                sys.exit()
            elif event.type==pygame.MOUSEMOTION:
                hammer.SetPosition(pygame.mouse.get_pos())
            elif event.type==pygame.MOUSEBUTTONDOWN:
                if event.button==1:
                    hammer.SetHammering()
            elif event.type==ChangeHoleEvent:
                HolePos=random.choice(config.HolePosition)
                Mole.reset()
                Mole.SetPosition(HolePos)
        if hammer.is_hammering and not Mole.is_hammer:
            IsHammer=pygame.sprite.collide_mask(hammer,Mole)
            if IsHammer:
                audios['Hammering'].play()
                Mole.SetBeHammered()
                score+=10
        ScoreText=font.render('Score: '+str(score),True,config.Brown)
        screen.blit(BackImage,(0,0))
        screen.blit(CountDownText,(875,8))
        screen.blit(ScoreText,(800,430))
        Mole.draw(screen)
        hammer.draw(screen)
        pygame.display.flip()
        clock.tick(60)
    try:
        BestScore=int(open(config.RecordPath).read())
    except:
        BestScore=0
    if score>BestScore:
        f=open(config.RecordPath,'w')
        f.write(str(score))
        f.close()
    ScoreInfo={'YourScore':score,'BestScore':BestScore}
    IsAgain=end(screen,config.GameEndImagePath,config.GameAgainImagePaths,ScoreInfo,config.FontPath,[config.White,config.Red],config.ScreenSize)
    return IsAgain
Exemplo n.º 14
0
        config.read('config.ini')
        platform = config['OS']['platform']
        cache_boolean = ("True" == config['Cache']['keep_cache'])
        cache_location = config['Cache']['cache_location']
        remote_url = config['Remote']['location']
        remote_branch = config['Remote']['location_branch']
        file_extension = config['Remote']['file_extension']
        search_local = ("True" == config['Search']['search_local'])
        remote_search_dir = config['Search']['packages_search_remote']

except:
    pass

#Main Program
if len(sys.argv) == 1:
    result = interface.start()
elif len(sys.argv) == 2:
    if sys.argv[1] == 'config':
        configuration.config_update()
elif len(sys.argv) == 3:
    if sys.argv[1] == 'search':
        print(remote_search_dir)
        remote_url = remote_url + 'packages-' + platform + '/' + remote_branch
        pattern = sys.argv[2]
        matches = search.search(pattern, remote_url, file_extension,
                                search_local, cache_location)
        for match in matches:
            print(match)
    elif sys.argv[1] == 'download':
        full_file = sys.argv[2] + file_extension
        file_url = remote_url + 'packages-' + platform + '/' + remote_branch + '/scripts/' + full_file
Exemplo n.º 15
0
def start():
    f.start()
Exemplo n.º 16
0
def check_interpreter():
    """Check interpreter version."""
    message = "Python interpreter version should be 3.5 or newer. Your version is %d.%d" % (
        sys.version_info.major, sys.version_info.minor)
    if sys.version_info.major < 3:
        sys.exit(message)
    elif sys.version_info.minor < 5:
        sys.exit(message)


def check_module(name):
    """Check if necessary Python module is installed."""
    return importlib.util.find_spec(name) is not None


def check_deps(names):
    not_installed = []
    for module in names:
        if not check_module(module):
            not_installed.append(module)
    if not_installed:
        sys.exit(
            f"Need to install following module(s): {', '.join(not_installed)}."
        )


if __name__ == "__main__":
    check_interpreter()
    check_deps(DEPENDENCIES)
    interface.start(FilesAggregator)
Exemplo n.º 17
0
import interface
interface.start()

#Imports the interface module and runs the start function to initiate command line interface.
import config
#import config module for database connection
import sqlite3
#sqlite for altering database connection

config.con = sqlite3.connect(
    ":memory:"
)  # alters config variable to connect to in-memory database for testing

import test_database
test_database.build_db()  # build in-memory database with test data

import interface
interface.start()  # import interface and begin command line interface