Advertisement
Guest User

Untitled

a guest
Jun 26th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. def _initialize_table(self):
  2. def add_dict(sub_dict, length, actions):
  3. if length == 0:
  4. for key in sub_dict:
  5. sub_dict[key] = actions.copy()
  6. return sub_dict
  7. for key in sub_dict:
  8. sub_dict[key] = {True: {}, False: {}}
  9. add_dict(sub_dict[key], length-1, actions)
  10.  
  11. self.qtable = {}
  12. for node in self.nodes:
  13. node_actions = self.nodes[node].get_actions()
  14. actions = {}
  15. for action in node_actions:
  16. # We don't want q-values for the pickup and dropoff actions, as those are always taken.
  17. # We only want q values for cardinal directions.
  18. if action not in ["Pickup", "Dropoff"]:
  19. actions[action] = INITIAL_Q_VALUE
  20. dropoff = {True: {}, False: {}}
  21. add_dict(dropoff, len(self.dropoffs)-1, actions)
  22.  
  23. pickup = {True: {}, False: {}}
  24. add_dict(pickup, len(self.pickups)-1, actions)
  25.  
  26. self.qtable[node] = {True: dropoff, False: pickup}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement