def move(self, board, n, newDisplay): """ The main function for this class. Returns the point the AI wants to move in. """ self.updateAll(board, n, newDisplay, -1000) # check for four in a row on both sides move = self.assuredMove() if self.decided: if move == False: print "Chris has been trying to recreate this bug for a while," print "Please get all this info to him if possible." print "Moves: ", self.b.moveList print "Players: ", self.n, self.o print "Move, assured, decided, scared: ", move, self.assured, self.decided, self.scared print "Board:" newD = Display(self.b, [None], [None]) newD.displayShittyBoard() print "Possible moves: ", self.moves return move move = self.weakLookAhead() return move
def __init__(self): self.display = Display() self.map_player = Map() self.needle = Item("needle", 4, self.map_player) self.map_player.put_item_on_map(self.needle) self.ether = Item("ether", 5, self.map_player) self.map_player.put_item_on_map(self.ether) self.tube = Item("tube", 6, self.map_player) self.map_player.put_item_on_map(self.tube) self.mac_gyver = Player(self.map_player) self.display.load_wall() self.display.load_ground() self.display.load_player_display() self.display.load_jailer() self.display.load_items() self.display.load_font() self.display.refresh(self.map_player, self.mac_gyver) self.display.show_inventory(self.mac_gyver) self.items_in_game = [self.needle, self.ether, self.tube] self.keyboard_list_movements = [ pygame.K_UP, pygame.K_DOWN, pygame.K_LEFT, pygame.K_RIGHT ] self.keyboard_functions = [ self.mac_gyver.move_up, self.mac_gyver.move_down, self.mac_gyver.move_left, self.mac_gyver.move_right ]
def display(self): try: return self._display except AttributeError: self._display = Display() self._display.start() return self._display
def query_driver(self, key, len, key_list, start_date, end_date): logging.info('module:{}, calling:{}, with:{},{},{},{},{}'.format( 'ModifyData', 'query', key, len, key_list, start_date, end_date)) query_function = None if key == KEY_PROVINCE: query_function = COVID_Database.getInstance().query_by_province elif key == KEY_COUNTRY: query_function = COVID_Database.getInstance().query_by_country elif key == KEY_COMBINE_KEY: query_function = COVID_Database.getInstance().query_by_combined_key else: logging.ERROR('ERROR:{},module:{}, calling:{}'.format( 'invalid key', 'ModifyData', 'query')) print('invalid key') return master_list = [] for i in range(len): query_result = query_function(start_date, end_date, key_list[i].replace('_', ' ')) master_list.append(query_result) logging.info('DEBUG:master_list{},module:{}, calling:{}'.format( master_list, 'ModifyData', 'query')) Display(master_list) Display.getInstance().display_on_screen()
def init_ui(self): self.bAll = QVBoxLayout(self) self.setLayout(self.bAll) # top menu self.topMenu = TopMenu(self) self.bAll.addWidget(self.topMenu, 0) # Left Toolbar b1 = QHBoxLayout() self.toolsGUI = ToolsGUI(self) b1.addWidget(self.toolsGUI, 0) # Display self.display = Display(self) b1.addWidget(self.display, 10) self.bAll.addLayout(b1) # GUI events self.topMenu.convertDICOM.connect(self.toolsGUI.preprocess_dicom) self.topMenu.loadData.connect(self.toolsGUI.load_data) self.topMenu.eddyCorr.connect(self.toolsGUI.preprocess_eddy) self.topMenu.sigBET.connect(self.toolsGUI.preprocess_bet) self.toolsGUI.postProcessDisplayUpdateSignal.connect( self.display.postProcessUpdate) self.raise_()
def main(): dis = Display() scene = Scene(dis) light = Circle(dis, (255, 0, 0), dis.get_center(), 15, 0) move_schedule = move_light_spiral(light, dis.get_center(), 200, 720, 128) line_sched = move_light_straight(light, move_schedule.get_final_location(), dis.get_center(), 128) move_schedule.add_task(line_sched) color_schedule = fade_colors(light, (255, 0, 0), (0, 255, 0), 128) flash_sched = blink(light, color_schedule.get_final_color(), (255, 255, 255), 2, 2, 128) color_schedule.add_task(flash_sched) scene.add_instance(Object_Instance(light, move_schedule, color_schedule)) BPMtrigger(128, scene, 256) dis.main_menu()
def Main(): if (len(sys.argv) < 2): sys.exit("No input file path provided.") Path = sys.argv[1] ExportPath = None if (len(sys.argv) > 2): ExportPath = sys.argv[2] os.makedirs(ExportPath, exist_ok=True) if (not os.path.exists(ExportPath)): ExportPath = None JSONPath = os.path.splitext(Path)[0] + ".txt" if (not os.path.exists(Path)): sys.exit("File does not exist.") if (not os.path.exists(JSONPath)): sys.exit("JSON file does not exist.") JSON = ReadJSON(JSONPath, Path) JSON = IdentifyRunway.IdentifyRunway(JSON, ExportPath) Display.Display(JSON, ExportPath) Correct.Correct(JSON, ExportPath) JSON = Calculate.find_position(JSON) #Export JSON: if (ExportPath is not None): File = open(ExportPath + "/11 JSON.txt", "w") json.dump(JSON, File, indent=4) File.close() print(json.dumps(JSON, indent=4))
def __init__(self): """ Creates display and initial menu """ # nothing much to do here yet until display is better self.b = Board() self.d = Display(self.b) self.n = 0 self.forced = False
def __init__(self, pretrained_model=None, learning_rate=0.0001, std=1, screen_size=None, display=True): """ Init the agent with the necessary values """ self.name = 'policy gradient agent gaussian linear' if screen_size is None: self.screen_size = [400, 400] else: self.screen_size = screen_size self.env = catcher.ContinuousCatcher(width=self.screen_size[0], height=self.screen_size[1]) if pretrained_model: # linear model self.theta = pretrained_model else: # linear model w_bar_center, w_bar_vel, w_fruit_center0, w_fruit_center1 = 0, 0, 0, 0 self.theta = [ w_bar_center, w_bar_vel, w_fruit_center0, w_fruit_center1 ] # learning rate for the update self.learning_rate = learning_rate # standard deviation of the Gaussian. self.std = std self.display = display if display: self.Display = Display.Display()
def __init__(self, isDisplay=True): self.__isDisplay = isDisplay if isDisplay: self.display = Display() self.genetic = Genetic() self.tetrisList = [] self.population = [] self.generation = 0
def main(): print("Jay Ganesh......") print("Enter Number") No = int(input()) Display(No)
def main(): No = 0 print("Jay Ganesh.....") print("Enter Number To Iterate") No = int(input()) Display(No)
def init(data): data.level = Scene(Node(Mesh.triangularPyramid(Vec3(0, 0, 500))), Camera(Vec3(0, 0, 0), 250, data.width, data.height)) data.level.root.addChildren(Node(Mesh.cube(Vec3(200, 200, 500)))) data.screen = Display(data.level) data.paused = True data.looking = False data.prevX = 0 data.prevY = 0
def backtesting(): SuperGet = Dataget.Dataget() ##刷新数据库 #SuperGet.updatedaily('20100101','20190627') ##刷新复权因子 #SuperGet.updatedaily_adj_factor('20100101','20190627') ##刷新经济指标 #dataset_adj_train=SuperGet.updatedaily_long_factors('20100101','20190627') ##选择日期 dataset_adj_train = SuperGet.getDataSet_adj_factor('20120101', '20170101') dataset_adj_test = SuperGet.getDataSet_adj_factor('20170101', '20190727') dataset_train = SuperGet.getDataSet('20120101', '20170101') dataset_test = SuperGet.getDataSet('20170101', '20190727') #测试添加长期指标 #dataset_adj_train=Dataget.Dataget.getDataSet_adj_factor('20170101','20180520') #dataset_adj_test=Dataget.Dataget.getDataSet_adj_factor('20190101','20190501') #dataset_train=Dataget.Dataget.getDataSet('20170101','20180520') #dataset_test=Dataget.Dataget.getDataSet('20190101','20190501') dataset_long_train = SuperGet.getDataSet_long_factor( '20120101', '20170101') dataset_long_test = SuperGet.getDataSet_long_factor('20170101', '20190727') #dataset_adj_test=Dataget.Dataget.getDataSet_adj_factor('20100101','20170101') #dataset_adj_train=Dataget.Dataget.getDataSet_adj_factor('20170101','20190520') #dataset_test=Dataget.Dataget.getDataSet('20100101','20170101') #dataset_train=Dataget.Dataget.getDataSet('20170101','20190520') #选择特征工程 cur_fe = FE.FE3() FE_train = cur_fe.create(dataset_train, dataset_adj_train, dataset_long_train) FE_test = cur_fe.create(dataset_test, dataset_adj_test, dataset_long_test) #选择模型 cur_model = models.LGBmodel() #训练模型 cur_model_done = cur_model.train(FE_train) #进行回测 finalpath = cur_model.predict(FE_test, cur_model_done) #展示类 dis = Display.Display() #dis.scatter(finalpath) dis.plotall(finalpath)
def backTestingWithPredictDatas(self): #展示类 dis = Display.Display() #dis.scatter(finalpath) dis.real_plot_create() dis.real_plot_show_plus() asfsdf = 1
def __init__(self): self.message_queue = queue.Queue() self.debug_flag = threading.Event() try: with open("eggos", "r") as cookies: session_cookies = json.loads(cookies.readline()) except FileNotFoundError: session_cookies = None try: self.facebook = Facebook.Facebook(os.getenv('FB_USER'), os.getenv('FB_PASSWD'), self.message_queue, self.debug_flag, session_cookies=session_cookies) self.facebook_thread = threading.Thread( target=self.facebook.listen) self.facebook_thread.start() with open("eggos", "w") as cookies: cookies.write(json.dumps(self.facebook.getSession())) except: pass try: self.instagram = Instagram.Instagram(os.getenv('IG_USER'), os.getenv('IG_PASSWD'), self.message_queue, self.debug_flag) self.instagram_thread = threading.Thread( target=self.instagram.listen) self.instagram_thread.start() except: pass self.display = Display.Display() self.display_thread = threading.Thread(target=self.display.run_forever) self.display_thread.start() self.users = {} self.received_message_count = 0 self.commands = { "MAXMESSAGES": self.max_messages, "MAXLENGTH": self.max_length, "STATS": self.stats, "ANIMATION": self.animation, "SHOW": self.display_message, "HELP": self.help, "DEBUG": self.debug, "PW": self.password }
def __init__(self): self.exp_parameters = ExpParameters() self.RESOURCES = sdl2.ext.Resources('.', 'resources') self.display = Display.Display(self.RESOURCES, self.exp_parameters) self.recorder = Recorder.Recorder(self.exp_parameters) self.pID = 999 self.session = 99 self._setupSessions() self._getPIDNSession()
def main(): print("Jay Ganesh......") print("Enter Number To Start Number Line") No = int(input()) print("Enter Number To End Number Line") No2 = int(input()) Display(No, No2)
def __init__(self, parent=None): super(self.__class__, self).__init__(parent) self.setupUi(self) self.centerOnScreen() self.BTN_SelFolder.clicked.connect(self.browse_folder) self.BTN_Process.clicked.connect(self.process_folder) self.actionAuthors.triggered.connect(self.show_authors) self.form2 = ProgressClass(self) self.form3 = Display(self) self.magic = magic.open(magic.MAGIC_MIME) self.magic.load()
def __init__(self): self.square = Square(SQUARE_X, SQUARE_Y, SQUARE_HEIGHT, SQUARE_WIDTH, [0, 0], SQUARE_SPEED) self.missiles = [] self.display = Display(SCREEN_WIDTH, SCREEN_HEIGHT) self.done_game = True self.done_all = False self.time_between_missiles = TIME_BETWEEN_MISSILES self.time_last_missile = 0 self.score = 0 self.client = Client()
def __init__(self): self.display = Display.Display() self.player = Player(10,10, np.array([3], dtype=int).reshape(1,1), layer=69) #self.object1 = Entity.Entity(0, 10, np.array([1], dtype=int).reshape(1,1), 100) #self.object2 = Entity.Entity(100, 20, np.array([2], dtype=int).reshape(1,1), 0) self.display.add_objects([self.player]) logging.basicConfig(filename="logging.log", filemode="w", level=logging.DEBUG) self.fps = 60
def _analyse(ui, fileUrls, algorithm): global output if len(fileUrls) != 0: algorithmClass = _loadAlgorithmClass(algorithmsFolder, algorithm)() if len(str(ui.qwtPlot.title().text())) == 0: ui.curveX, ui.curveY = preparePlot(ui, algorithm) for fileUrl in fileUrls: print fileUrl video, i, j = cv2.VideoCapture(fileUrl), 0, 0 ret, frame = video.read() algorithmClass._initiateRegisters(frame) display1 = Display(ui.label_17) display2 = Display(ui.label_18) display3 = Display(ui.label_7) avaragePeriod, outlierDistance = ui.spinBox.value( ), ui.spinBox_2.value() opencvPreview = ui.checkBox_2.isChecked() ui.resultDict = {} while ret: display1.display(frame) algorithmClass.analyze(frame, avaragePeriod) display2.display(algorithmClass.processedFrame) frame2 = algorithmClass.processedFrame if not opencvPreview: frame2 = np.zeros((100, 100, 3), dtype=np.uint8) cv2.imshow("raw preview ", frame2) if 0xFF & cv2.waitKey(5) == 27: break ret, frame = video.read() if i % ui.spinBox.value() == 0 and i > 0: ui.resultDict = algorithmClass.getResultDict( i, outlierDistance) output.append(ui.resultDict) #print "output len ", sys.getsizeof(output) if j == 0: printAlgorithmResultsKeys(ui, j) j += 1 i += 1 video.release()
def init_widget(__): __.tab = qt.QTabWidget() __.tab.setMaximumHeight(80) __.tab.setMovable(True) __.initCollisionLayer() __.tab.addTab(Layer(Layer.EVENT, length=DEFAULT_MAP_LENGTH * DEFAULT_TILE_WIDTH), "Events") __.tab.addTab(Layer(Layer.ENEMY, length=DEFAULT_MAP_LENGTH * DEFAULT_TILE_WIDTH), "Enemies") __.showTab = qt.QPushButton("Hide") __.showTab.setMaximumWidth(40) __.display = Display(__)
def __init__(): # Intitalizes program global clock clock = pygame.time.Clock() clock.tick(60) # Controls frame rate global eventHandler eventHandler = Events() # Listens for mouse and keyboard clicks global display display = Display(eventHandler) # Initializes the Display while True: Game()
def __init__(self, set_points, control_signs=(1, 1, 1, 1), log_name='log.xls', do_plot=True): self.log_name = log_name self.do_plot = do_plot self.set_points = set_points self.control_signs = control_signs self.logger = SimpleLogger.Logger() self.save_interval = 25 self.display = False self.thermal_tile_0 = SingleThermalTile(set_point=set_points[0], channel=0, control_sign=control_signs[0]) self.thermal_tile_1 = SingleThermalTile(set_point=set_points[1], channel=1, control_sign=control_signs[1]) self.thermal_tile_2 = SingleThermalTile(set_point=set_points[2], channel=2, control_sign=control_signs[2]) self.thermal_tile_3 = SingleThermalTile(set_point=set_points[3], channel=3, control_sign=control_signs[3]) if self.do_plot: self.display = Display.Display(set_points)
def __init__(self, lll, viewspace, mymap): self.lll = lll self.display = Display() self.viewspace = viewspace self.mymap = mymap self.terrainset = TerrainSet() self.units = [] # Test self.settsurf = Surface() self.settsurf.loadFromFile("gfx/protosettler.png") self.settsurf.cols = 16 self.settsurf.rows = 16 """self.sett = Unit (self.viewspace, self.settsurf)
def TodayPredict5Day_0606(this): REAL_Get = Dataget.Dataget() datepath, adjpath, longpath, moneyflowpath = REAL_Get.get_history_dateset_four( ) #datepath,adjpath,moneyflowpath=REAL_Get.get_history_dateset() REAL_Get.real_get_change(datepath) REAL_Get.real_get_adj_change(adjpath) REAL_Get.real_get_long_change(longpath) REAL_Get.real_get_moneyflow_change(moneyflowpath) #选择特征工程 #切换为e #cur_fe=FE.FEg30eom0110onlinef() cur_fe = FE.FEonlinew_a31() cur_fe.real_FE() # nowTime = datetime.datetime.now() month_sec = nowTime.strftime('%Y%m%d') print(month_sec) #选择模型 cur_model = Models.LGBmodel_20() cur_model.real_lgb_predict('lgb16.pkl', 'out1.csv') cur_model.real_lgb_predict('lgb26.pkl', 'out2.csv') cur_model.real_lgb_predict('lgb36.pkl', 'out3.csv') cur_model.real_lgb_predict('lgb46.pkl', 'out4.csv') #展示类 dis = Display.Display() dis.show_today() todaypath = './result' + month_sec FileIO.FileIO.mkdir(todaypath) FileIO.FileIO.copyfile('out1.csv', todaypath + '/out1.csv') FileIO.FileIO.copyfile('out2.csv', todaypath + '/out2.csv') FileIO.FileIO.copyfile('out3.csv', todaypath + '/out3.csv') FileIO.FileIO.copyfile('out4.csv', todaypath + '/out4.csv') asdad = 1
def __init__(self): super().__init__() self.app = QApplication(sys.argv) self.window = gui.GUI() self.displayTh = display.Display() self.dataTh = data.TestData() WaveGen.UZPOut.generateLUT() self.disptimer = QTimer() self.disptimer.setInterval(c.PERIOD_OF_DISP) self.disptimer.timeout.connect(self.displayTh.start) self.window.startScanning.connect(self.startScans) self.window.endScanning.connect(self.endScans) self.displayTh.loadedImage.connect(self.relayImage) self.sendImage.connect(self.window.showGivenImage) self.window.show() sys.exit(self.app.exec_())
def run(self): print("Ta rodando heuiahuaehuahae\n") self.init_scenario() self.init_labirint() self.init_robot() self.init_camera() self.init_illumination() self.debug_txt = Display.Display() self.robot.brain.observe(self.robot, self.labirint, self) self.io_ = io_robot.IO_Robot() the_brain = self.io_.load_brain() not_load = True if the_brain: self.robot.brain = the_brain not_load = False self.camera.toggle_camera() self.camera.switch_camera(self.robot, self) #try: while True: self.robot.brain.observe(self.robot, self.labirint, self, not_load) not_load = False for i in range(0, 2000): print(i) self.robot.brain.train(self.robot, self.labirint, self) #self.robot.brain.predict(self.robot, self.labirint, self) self.camera.switch_camera(self.robot, self) self.deselect_objects() bpy.ops.wm.redraw_timer(type='DRAW_WIN_SWAP', iterations=1) #self.save_images(i) self.put_fruits_back() self.io_.save_brain(self.robot) self.reset()
def __init__(self, numtrials=1000, numtest=25, gamma=0.3, epnum=500, lrnum=100): self.numtrials = numtrials self.gamma = gamma #key is (state,action) tuple, value is qvalues. initially zero self.qtable = {} #key is (state,action) tuple, value is frequencies of occurence. initially zero self.Nsa = {} #Collision tracking self.success = {} self.epnum = epnum self.lrnum = lrnum self.numtest = numtest self.answer = 0 #Display for graphics self.display = Display.Display()