當前位置: 首頁>>代碼示例>>Python>>正文


Python Action.to_string方法代碼示例

本文整理匯總了Python中Action.Action.to_string方法的典型用法代碼示例。如果您正苦於以下問題:Python Action.to_string方法的具體用法?Python Action.to_string怎麽用?Python Action.to_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Action.Action的用法示例。


在下文中一共展示了Action.to_string方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: Schema

# 需要導入模塊: from Action import Action [as 別名]
# 或者: from Action.Action import to_string [as 別名]

#.........這裏部分代碼省略.........
		if self.generalised:
			self.set_vars_from_state(pre)
		Total_similarity = 0.0
		similarity = self.preconditions.get_similarity(s2.preconditions)
		Total_similarity += similarity
		similarity = self.postconditions.get_similarity(s2.postconditions)
		Total_similarity += similarity
		return Total_similarity/2

	def update(self, ws):
		"""Update schema postconditions from given state"""
		found_all = True; schema_changed = False
		if self.generalised:
			wsc = ws.copy(); self.mem.remove_ignored_preconditions(wsc)
			self.set_vars_from_state(wsc)
			s_post = self.postconditions.copy(); self.mem.remove_ignored_preconditions(s_post)
			for o in s_post.state:
				found = False
				for o2 in wsc.state:
					if (o.equals(o2)):
						o.occurred(True)
						found = True
				if (not found):
					o.occurred(False)
					found_all = False
		else:
			for o in self.postconditions.state:
				found = False
				for o2 in ws.state:
					if (o.equals(o2)):
						o.occurred(True)
						found = True
				if (not found):
					print "@schem_update Observation not found:", o.to_string()
					o.occurred(False)
					found_all = False

		if(len(self.postconditions.state) == 0):
			self.successes +=1; schema_changed = True; found_all = False
			for o in ws.state:
				if not(o.self_flag):
					continue
				found = False
				for o2 in self.postconditions.state:
					if (o.equals(o2)):
						found = True; break
				if (not found):
					o.occurred(True)
					self.postconditions.add_observation(o)
		if found_all:
			self.successes +=1
			print "Schema succesful:",self.id,self.successes
		return (found_all, schema_changed)

	def copy(self):
		"""Create copy of the schema"""
		new = Schema(self.mem)
		new.preconditions= self.preconditions.copy()
		new.postconditions = self.postconditions.copy()
		new.action = self.action.copy()
		new.associated_observations = self.associated_observations.copy()
		new.disappeared_observations = self.disappeared_observations.copy()
		new.associated_preconditions = self.associated_preconditions.copy()
		new.id = int(self.id)
		if self.generalised:
			new.generalised = True
開發者ID:kumar54,項目名稱:Dev-PSchema,代碼行數:70,代碼來源:Schema.py


注:本文中的Action.Action.to_string方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。