def test_state_false(self): rddl = ''' domain my_test { pvariables { p : { state-fluent, int, default = 0 }; a : { action-fluent, bool, default = false }; }; cpfs { p' = p + 1; }; reward = 0; state-action-constraints { p < 0; }; } non-fluents my_test_empty { domain = my_test; } instance my_test_inst { domain = my_test; init-state { a; }; } ''' conv = Converter(const_as_assert=True) conv.convert_str(rddl) p = conv.world.getState(WORLD, 'p', unique=True) self.assertEqual(p, 0) with self.assertRaises(AssertionError): conv.verify_constraints()
def test_const(self): rddl = ''' domain my_test { pvariables { C : { non-fluent, int, default = 1}; p : { state-fluent, int, default = 0 }; a : { action-fluent, bool, default = false }; }; cpfs { p' = p + C; }; reward = 0; state-action-constraints { C >= 0; }; } non-fluents my_test_empty { domain = my_test; } instance my_test_inst { domain = my_test; init-state { a; }; } ''' conv = Converter(const_as_assert=True) conv.convert_str(rddl) p = conv.world.getState(WORLD, 'p', unique=True) self.assertEqual(p, 0) conv.verify_constraints() conv.world.step() p = conv.world.getState(WORLD, 'p', unique=True) self.assertEqual(p, 1) conv.verify_constraints()
action_name = Msg2ActionEntry.get_action(msg) if action_name not in conv.actions[player_name]: any_none = True logging.warning(f'Msg {msg} has no associated action') else: logging.info(f'Player {player_name} does {action_name}') action = conv.actions[player_name][action_name] actions[player_name] = action if any_none: input('cont..') continue conv.world.step(actions, debug=debug, threshold=args.threshold, select=args.select) else: conv.world.step(debug=debug, threshold=args.threshold, select=args.select) conv.log_state(log_actions=args.log_actions) print('rewards') for player_name, msg in msgs.items(): print(conv.world.agents[player_name].reward()) if args.log_rewards: for ag_name in conv.actions.keys(): _log_agent_reward(ag_name) conv.verify_constraints()