예제 #1
0
  def automatedMovesForSnake(self):

    training_data=[]
    self.theApp=main.App()
    for _ in range(self.initialGames):
      self.theApp.reset()
      obs=self.generate_observation()
      prev_distance=self.getAppleDistance()
      prev_score=self.theApp.player.score
      for _ in range(self.goalSteps):
        #print(obs)
        #print("snake direction" + str(self.theApp.player.direction))
        #print("snake pos: %d, %d apple position: %d, %d"%(self.theApp.player.x[0],self.theApp.player.y[0],self.theApp.apple.x,self.theApp.apple.y))
        
        new_action,direction=self.action()
        #print("new_Action"+str(new_action))
        self.makeMoveAndCheckCollision(direction)
        new_distance=self.getAppleDistance()
        #print("(prev_distance,new_distance) (%f,%f)"%(prev_distance,new_distance))
        new_score=self.theApp.player.score
        
        if not self.theApp._running:
          #print(self.theApp.player.x[0],self.theApp.player.y[0])
          training_data.append([self.add_action_to_observation(obs, float(new_action)), -1]) #0 previously
          break
        else:
          if new_distance < prev_distance and prev_score>=new_score:
            training_data.append([self.add_action_to_observation(obs, float(new_action)), 1])
          else:
            training_data.append([self.add_action_to_observation(obs, float(new_action)), 0]) #1 previosuly
          prev_distance=new_distance
          obs=self.generate_observation()
          prev_score=new_score
        #time.sleep (100.0 / 1000.0);
    return training_data
예제 #2
0
def test_write_invited():
    app = main.App()
    app.read_customers('customers.txt')
    app.invite_near_customers(100)
    app.write_invited('output.txt')

    with open('output.txt', 'r+') as f:
        assert len(f.readlines()) == 16
예제 #3
0
def test_invite_near_customers():
    app = main.App()
    app.read_customers('customers.txt')

    app.invite_near_customers(100)
    assert len(app.invited) == 16

    app.invite_near_customers(50)
    assert len(app.invited) == 8
 def HomePage(self):
     self.home = main.App()
예제 #5
0
def test_main_connected():
    app = main.App()
    app.register_classes()
    app.auth.connect()
    print('Main Script Connected')
예제 #6
0
from sys import argv, exit

from PyQt5.QtWidgets import QApplication

import configurer
import main

if __name__ == '__main__':
    if argv[1] == 'main':
        argv.pop(1)
        app = QApplication(argv)
        window = main.App()
        exit(app.exec_())
    elif argv[1] == 'configurer':
        argv.pop(1)
        app = QApplication(argv)
        window = configurer.App()
        exit(app.exec_())
예제 #7
0
파일: quail.py 프로젝트: 1egoman/quail
 def run(self):
     # load src/main.py
     while 1:
         import main
         main.App()
예제 #8
0
파일: quail.py 프로젝트: 1egoman/quail
            print "pid:", os.getpid()
            daemon.start()

        # stop daemon
        elif 'stop' == sys.argv[1]:
            daemon.stop()

        # restart daemon
        elif 'restart' == sys.argv[1]:
            daemon.restart()

        # start for debugging, with full stdin / stdout / stderr
        elif 'go' == sys.argv[1]:
            # start quail manually
            import main
            main.App()

        # install a plugin
        # quail install 1egoman/qlist
        elif 'install' == sys.argv[1] and len(sys.argv) == 3:
            os.chdir("plugins")
            if sys.argv[2] == "template":
                name = raw_input("Name of template plugin: ")

                if os.system("git clone http://github.com/1egoman/qplugin %s" %
                             name) == 0:
                    print "Created template called '%s'." % name
                    origin = raw_input(
                        "Github plugin origin (blank for none) : ")
                    if origin and os.system(
                            "git remote set-url origin %s") == 0:
예제 #9
0
import main
import os
import json
from apiclient.http import MediaFileUpload

UPLOADS_PATH = 'src/uploads/'

if __name__ == "__main__":
    app = main.App()
    #    app.setModels([JuryAppointment, StudentResponse])
    app.register_classes()
    parent_folder_id = '1d-lLioPih504aD6Hao9mk4Dg7ahch5EJ'
    request_string = 'https://www.googleapis.com/drive/v3/files?q="' + parent_folder_id + '"+in+parents'
    r = app.auth.authsession.get(request_string)
    response_dict = json.loads(r.text)
    directories = response_dict['files']
    uploads = os.listdir(UPLOADS_PATH)
    for i in uploads:
        for j in directories:
            if j['name'] in i:
                print("Uploading " + i + " to " + j['name'])
    print('Does this look correct? (y for yes, n for no)')
    choice = input()
    if choice.lower() == 'y':
        upload_files = []
        print('Uploading...')
        for i in uploads:
            for j in directories:
                if j['name'] in i:
                    metadata = {'name': i, 'parents': [j['id']]}
                    print(metadata)
예제 #10
0
 def setUpClass(cls):
     cls.root = tkinter.Tk()
     cls.app = main.App(cls.root)
예제 #11
0
    def gameDisp(self):

        theApp = main.App()
        theApp.on_execute()
예제 #12
0
def test_read_customers():
    app = main.App()
    app.read_customers('customers.txt')

    assert len(app.customers) == 32
예제 #13
0
def test_application():
    app = main.App()

    assert app.office.latitude == math.radians(53.339428)
    assert app.office.longitude == math.radians(-6.257664)