Beispiel #1
0
	def getPic(self,pic,test = False):
		'''
		获取图片的函数,图片从此开始处理
		:param pic:游戏全图
		:return:
		'''

		assert (pic.shape == (720,1280,3))
		same = (pic == self.currentPic).all()
		print('获取图片 重复判断结果:{}'.format(same))
		if same:
			return
		self.currentPic = pic
		errorTimes = 0
		if not test:
			# try:
			params = paramExtract(self)
			action = self.determineAction(params)
			targetAction = self.operater.actionExcute(action,params)
			self.ds.storeResult(pic,params,targetAction)
			errorTimes = 0
			# except Exception as e:
			# 	print("图片处理错误,详情:{}".format(e))
			# 	errorTimes += 1
			# 	if errorTimes > 10:
			# 		raise()
			# 	return -1
		else:
			params = paramExtract(self,False)
			action = self.determineAction(params)
			self.operater.actionExcute(action, params)
Beispiel #2
0
	def param_extract(self, img, **args):
		assert (img.shape == (720, 1280, 3))
		same = (img == self.currentPic).all()
		print('获取图片 重复判断结果:{}'.format(same))
		if same:
			return
		self.currentPic = img
		return paramExtract(self, **args)
Beispiel #3
0
    def getPic(self, pic):
        '''
		获取图片的函数,图片从此开始处理
		:param pic:游戏全图
		:return:
		'''
        print(pic.shape)
        assert (pic.shape == (720, 1280, 3))
        same = (pic == self.currentPic).all()
        print('获取图片 重复判断结果:{}'.format(same))
        if same:
            return
        self.currentPic = pic
        params = paramExtract(self)
        action = self.determineAction(params)
        self.actionExcute(action, params)
Beispiel #4
0
	def obs_params_extract(self, img, igone_same_check=False):
		assert (img.shape == (720, 1280, 3))
		same = (img == self.currentPic).all()
		if same and not igone_same_check:
			print('获取图片 判断为重复 退出:{}'.format(same))
			return
		self.currentPic = img
		params = paramExtract(self, position=False,money=False,exp=False,target=False,tower=False,img=img)
		obs = params['mat'].reshape(-1)
		hp = params['HP'].reshape(-1)
		code = self.encoder(img)
		obs = np.hstack((obs, hp, code))
		print('single obs shape:',obs.shape)
		new_obs = np.hstack((obs,self.oldobs))
		self.oldobs = obs
		obs = new_obs
		print('obs.shape:', obs.shape)
		return params, obs
Beispiel #5
0
	def action_params_augment(self, action, params):
		if action in [1, 2, 5, 4]:
			params = paramExtract(self, params=params, money=False, exp=False, target_mat=False, tower=False)
		return params
Beispiel #6
0
	def paramExtract(self,img,gameRuning = True):
		#the method is used by training
		self.currentPic = img
		return paramExtract(self,gameRuning)