constants.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. from __future__ import annotations
  2. import numpy as np
  3. TILE_PIXELS = 32
  4. # Map of color names to RGB values
  5. COLORS = {
  6. "red": np.array([255, 0, 0]),
  7. "green": np.array([0, 255, 0]),
  8. "blue": np.array([0, 0, 255]),
  9. "purple": np.array([112, 39, 195]),
  10. "yellow": np.array([255, 255, 0]),
  11. "grey": np.array([100, 100, 100]),
  12. }
  13. COLOR_NAMES = sorted(list(COLORS.keys()))
  14. # Used to map colors to integers
  15. COLOR_TO_IDX = {"red": 0, "green": 1, "blue": 2, "purple": 3, "yellow": 4, "grey": 5}
  16. IDX_TO_COLOR = dict(zip(COLOR_TO_IDX.values(), COLOR_TO_IDX.keys()))
  17. # Map of object type to integers
  18. OBJECT_TO_IDX = {
  19. "unseen": 0,
  20. "empty": 1,
  21. "wall": 2,
  22. "floor": 3,
  23. "door": 4,
  24. "key": 5,
  25. "ball": 6,
  26. "box": 7,
  27. "goal": 8,
  28. "lava": 9,
  29. "agent": 10,
  30. }
  31. IDX_TO_OBJECT = dict(zip(OBJECT_TO_IDX.values(), OBJECT_TO_IDX.keys()))
  32. # Map of state names to integers
  33. STATE_TO_IDX = {
  34. "open": 0,
  35. "closed": 1,
  36. "locked": 2,
  37. }
  38. # Map of agent direction indices to vectors
  39. DIR_TO_VEC = [
  40. # Pointing right (positive X)
  41. np.array((1, 0)),
  42. # Down (positive Y)
  43. np.array((0, 1)),
  44. # Pointing left (negative X)
  45. np.array((-1, 0)),
  46. # Up (negative Y)
  47. np.array((0, -1)),
  48. ]