本文整理汇总了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