def genGetOnAction(self, car_bop, peo_bop): ''' 生成上车动作 :param car_bop: :param peo_bop: :return: True/能上车 False/不能上车 ''' try: list_g_stage = self.dic_metadata['l_stage'] flag_car_moving = wgruler.Moving(list_g_stage, cur_bop=car_bop) flag_peo_moving = wgruler.Moving(list_g_stage, cur_bop=peo_bop) flag_car_geton = car_bop.ObjTypeX == 1 and car_bop.ObjSonNum == 0 and car_bop.ObjStep >= car_bop.ObjStepMax // 2 and car_bop.ObjKeep == 0 flag_peo_geton = peo_bop.ObjTypeX == 2 and peo_bop.ObjStep == peo_bop.ObjStepMax and peo_bop.ObjKeep == 0 if flag_car_moving == 'M' and flag_peo_moving == 'M' and flag_car_geton and flag_peo_geton: return True return False except Exception as e: common.echosentence_color(" " + str(e)) self.__del__() raise except KeyboardInterrupt as k: common.echosentence_color(" " + str(k)) self.__del__() raise
def genMoveAction(self, cur_bop, obj_pos): ''' 判断是否机动,若机动,返回机动路线 :param cur_bop: 机动算子 :param obj_pos: 目标位置 :return: (True,list)/(需要机动,机动路线),(False,None)/(不机动,None) ''' try: list_g_stage = self.dic_metadata['l_stage'] flag_str_moving = wgruler.Moving(list_g_stage, cur_bop) assert flag_str_moving in ['N', 'M', 'O'] if flag_str_moving == 'M': series = wgobject.bop2Ser(cur_bop) flag_result, list_movepath = self.obj_interface.getMovePath( series, obj_pos) if (flag_result == 0): return True, list_movepath return False, None except Exception as e: common.echosentence_color(" " + str(e)) self.__del__() raise except KeyboardInterrupt as k: common.echosentence_color(" " + str(k)) self.__del__() raise
def genGetOffAction(self, cur_bop): ''' 判断能否下车 :param cur_bop: :return: True/可以下车 Flase/不能下车 ''' try: list_g_stage = self.dic_metadata['l_stage'] # 下车模型首先保证能够机动 flag_str_moving = wgruler.Moving(list_g_stage, cur_bop=cur_bop) if flag_str_moving == 'M' and cur_bop.ObjTypeX == 1 and cur_bop.ObjSonNum == 1 and \ cur_bop.ObjStep >= cur_bop.ObjStepMax // 2 and cur_bop.ObjKeep == 0: # 没有被压制 # and cur_bop.ObjSonNum == 1 and cur_bop.ObjStep >= 3 and cur_bop.ObjKeep == 0: # 没有被压制 ???3 return True return False except Exception as e: common.echosentence_color(" " + str(e)) self.__del__() raise except KeyboardInterrupt as k: common.echosentence_color(" " + str(k)) self.__del__() raise