def activate(self): "..." super(MapPredictionTest, self).activate() self.__create_layers__() self.action.setChecked(True) Globs.log.info("Map Prediction Test Activated") items = [] items.append("Same Driving Direction") items.append("All Routable Lanes") items.append("All Neighbor Lanes") items.append("Undefined") widget = QWidget() tf = False self.mode, tf = QInputDialog.getItem( widget, "Select Route Creation Mode for Prediction Test ", "Options for creating Route: ", items, 0, False) self.length, tf = QInputDialog.getDouble( widget, "Enter length for Prediction Test ", "Length: ", 150.0, False) self.duration, tf = QInputDialog.getDouble( widget, "Enter duration for Prediction Test ", "Duration: ", 10.0, False)
def ask_user(self): # Ask the user for a factor by which to multiply all font sizes factor, ok = QInputDialog.getDouble( self.gui, 'Enter a magnification factor', 'Allow font sizes in the book will be multiplied by the specified factor', value=2, min=0.1, max=4 ) if ok: # Ensure any in progress editing the user is doing is present in the container self.boss.commit_all_editors_to_container() try: self.magnify_fonts(factor) except Exception: # Something bad happened report the error to the user import traceback error_dialog(self.gui, _('Failed to magnify fonts'), _( 'Failed to magnify fonts, click "Show details" for more info'), det_msg=traceback.format_exc(), show=True) # Revert to the saved restore point self.boss.revert_requested(self.boss.global_undo.previous_container) else: # Show the user what changes we have made, allowing her to # revert them if necessary self.boss.show_current_diff() # Update the editor UI to take into account all the changes we # have made self.boss.apply_container_update_to_gui()
def ask_user(self): # Ask the user for a factor by which to multiply all font sizes factor, ok = QInputDialog.getDouble( self.gui, 'Enter a magnification factor', 'Allow font sizes in the book will be multiplied by the specified factor', value=2, min=0.1, max=4) if ok: # Ensure any in progress editing the user is doing is present in the container self.boss.commit_all_editors_to_container() try: self.magnify_fonts(factor) except Exception: # Something bad happened report the error to the user import traceback error_dialog( self.gui, _('Failed to magnify fonts'), _('Failed to magnify fonts, click "Show details" for more info' ), det_msg=traceback.format_exc(), show=True) # Revert to the saved restore point self.boss.revert_requested( self.boss.global_undo.previous_container) else: # Show the user what changes we have made, allowing her to # revert them if necessary self.boss.show_current_diff() # Update the editor UI to take into account all the changes we # have made self.boss.apply_container_update_to_gui()
def oilify_image(self): val, ok = QInputDialog.getDouble( self, _('Oilify image'), _('The strength of the operation (higher numbers have larger effects)' ), value=4, min=0.1, max=20) if ok: self.canvas.oilify_image(radius=val)
def init_logic(self): logger.info(f"初始化逻辑数据") self.loop_index = 1 self.invalid_cell_count = 0 # 先手为蓝 self.step_cell = cell_blue # ai托管,默认不托管 self.ai_cells = {} self.ai_to_avg_stat = {} # type: Dict[int, AvgStat] self.ai_moving = False self.game_start_time = datetime.now() self.game_restarted = False self.ai_dfs_max_depth = 4 self.ai_min_decision_seconds = 0.5 self.ai_max_decision_time = timedelta(seconds=26) blue_set_ai = True red_set_ai = True self.ai_dfs_max_depth, _ = QInputDialog.getInt(self, "ai参数设置", f"ai最大搜索层数(越大越强,速度越慢,默认为{self.ai_dfs_max_depth})", self.ai_dfs_max_depth) self.ai_min_decision_seconds, _ = QInputDialog.getDouble(self, "ai参数设置", f"ai每步最小等待时间(秒)(太小可能会看不清手动方的落子位置-。-)", self.ai_min_decision_seconds) ai_max_decision_time, _ = QInputDialog.getDouble(self, "ai参数设置", f"ai每步最大等待时间(秒)(避免超出30秒)", self.ai_max_decision_time.total_seconds()) self.ai_max_decision_time = timedelta(seconds=ai_max_decision_time) blue_set_ai = QMessageBox.question(self, "AI配置", "蓝方是否启用AI?") == QMessageBox.Yes red_set_ai = QMessageBox.question(self, "AI配置", "红方是否启用AI?") == QMessageBox.Yes if blue_set_ai: self.set_ai(cell_blue, self.ai_min_max) if red_set_ai: self.set_ai(cell_red, self.ai_min_max) logger.info(f"ai最大迭代次数为{self.ai_dfs_max_depth},每次操作至少{self.ai_min_decision_seconds}秒,最大等待时间为{self.ai_max_decision_time}秒") self.last_step = (1, 1) self.init_board_without_invalid_cells()
def oilify_image(self): val, ok = QInputDialog.getDouble(self, _('Oilify image'), _( 'The strength of the operation (higher numbers have larger effects)'), value=4, min=0.1, max=20) if ok: self.canvas.oilify_image(radius=val)