Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def _initialize_table(self):
- def add_dict(sub_dict, length, actions):
- if length == 0:
- for key in sub_dict:
- sub_dict[key] = actions.copy()
- return sub_dict
- for key in sub_dict:
- sub_dict[key] = {True: {}, False: {}}
- add_dict(sub_dict[key], length-1, actions)
- self.qtable = {}
- for node in self.nodes:
- node_actions = self.nodes[node].get_actions()
- actions = {}
- for action in node_actions:
- # We don't want q-values for the pickup and dropoff actions, as those are always taken.
- # We only want q values for cardinal directions.
- if action not in ["Pickup", "Dropoff"]:
- actions[action] = INITIAL_Q_VALUE
- dropoff = {True: {}, False: {}}
- add_dict(dropoff, len(self.dropoffs)-1, actions)
- pickup = {True: {}, False: {}}
- add_dict(pickup, len(self.pickups)-1, actions)
- self.qtable[node] = {True: dropoff, False: pickup}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement