def pressed_but_not_select(self, x, y): """ Slot function to receive the pressed_but_nonselect signal if a Mylabel cinstance is clicked and also it's blank then get into this function This function implement these things: 1.Before clicking this cell, if you have already clicked(selected) a colored cell, then this function detect whether there is a valid path from the selected loc (self.selected_loc) to this loc(x,y). If success then move the colored cell to this loc and then set the previous selected_loc to blank(valid), else only set the previous selected_loc to valid(only view this action as canceling the seleted cell) 2. If there is no cell seleted before do nothing :param x: Mylabel x coordinate :param y: Mylabel y coordinate :return: """ print('received pressed_but_not_select signal') if self.selected_loc is not None: astar = AStar() converted_map = self.map.get_valid_map() * 10 converted_map = converted_map.astype(np.float) is_success = astar.main(converted_map, start_loc=self.selected_loc, end_loc=np.array([x, y])) if is_success: astar.path_backtrace() path = astar.best_path_array path = path[:, ::-1] self.just_start = False self.map.flash_starttoend(path) self.grade += self.map.judge_five([x, y]) # self.cancel_selected() self.selected_loc = None self.grade += self.map.rand_gen(self.gen_num) if self.map.get_valid_num() == 0: self.grade_label.setText('你的分数是: ' + str(self.grade) + ' 游戏结束') self.GameEndSignal.emit(self.grade) else: self.grade_label.setText('你的当前分数是: ' + str(self.grade)) else: self.cancel_selected()