File size: 585 Bytes
2130399 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
def remove_tree_from_wm(wme_table):
"""
Given a wme_table filled by SoarUtils.update_wm_from_tree, removes all wmes from working memory
Intermediate nodes are sml.Identifiers, which are removed from the table
Leaves are SoarWME's which are kept in the table but .remove_from_wm() is called on them
"""
items_to_remove = set()
for path, wme in wme_table.items():
if isinstance(wme, sml.Identifier):
items_to_remove.add(path)
else:
wme.remove_from_wm()
for path in items_to_remove:
del wme_table[path]
|