Browse Source

more debugging

refactoring
sp 9 months ago
parent
commit
f589b10692
  1. 3
      examples/shields/rl/utils.py

3
examples/shields/rl/utils.py

@ -127,11 +127,14 @@ class MiniGridShieldHandler(ShieldHandler):
ints = dict(re.findall(r'([a-zA-Z][_a-zA-Z0-9]+)=(-?[a-zA-Z0-9]+)', state_valuation))
booleans = re.findall(r'(\!?)([a-zA-Z][_a-zA-Z0-9]+)[\s\t]+', state_valuation)
booleans = {b[1]: False if b[0] == "!" else True for b in booleans}
print(ints, booleans)
if int(ints.get("previousActionAgent", 3)) != 3:
continue
if int(ints.get("clock", 0)) != 0:
continue
state = to_state(ints, booleans)
print(f"{state} got added with actions:")
print(get_allowed_actions_mask([choice_labeling.get_labels_of_choice(model.get_choice_index(stateID, choice[1])) for choice in choices]))
action_dictionary[state] = get_allowed_actions_mask([choice_labeling.get_labels_of_choice(model.get_choice_index(stateID, choice[1])) for choice in choices])
toc()

Loading…
Cancel
Save