| 19 | # TODO: rename file to parsing |
| 20 | |
| 21 | def parse_constants(domain, constant_map): |
| 22 | obj_from_constant = {} |
| 23 | for constant in domain.constants: |
| 24 | if constant.name.startswith(Object._prefix): # TODO: check other prefixes |
| 25 | raise NotImplementedError('Constants are not currently allowed to begin with {}'.format(Object._prefix)) |
| 26 | if constant.name not in constant_map: |
| 27 | raise ValueError('Undefined constant {}'.format(constant.name)) |
| 28 | value = constant_map.get(constant.name, constant.name) |
| 29 | obj_from_constant[constant.name] = Object(value, name=constant.name) # TODO: remap names |
| 30 | # TODO: add object predicate |
| 31 | |
| 32 | for name in constant_map: |
| 33 | for constant in domain.constants: |
| 34 | if constant.name == name: |
| 35 | break |
| 36 | else: |
| 37 | raise ValueError('Constant map value {} not mentioned in domain :constants'.format(name)) |
| 38 | del domain.constants[:] # So not set twice |
| 39 | return obj_from_constant |
| 40 | |
| 41 | def check_problem(domain, streams, obj_from_constant): |
| 42 | for action in (domain.actions + domain.axioms): |