Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. from misio.lost_wumpus.testing import test_locally
  2. from misio.lost_wumpus.agents import RandomAgent
  3. from misio.lost_wumpus._wumpus import Action
  4. from misio.lost_wumpus._wumpus import Field
  5. import numpy as np
  6.  
  7. np.set_printoptions(precision=3, suppress=True)
  8. n = 10
  9.  
  10. class Agent():
  11. def __init__(self, map: np.ndarray, p: float, pj: float, pn: float):
  12. self.p = p
  13. self.pj = pj
  14. self.pn = pn
  15. self.h, self.w = map.shape
  16. self.map = map.astype(np.float64)
  17. self.histogram = np.ones_like(self.map)
  18.  
  19. self.init_state()
  20.  
  21. def init_state(self):
  22. self.times_moved = 0
  23. self.direction = Action.LEFT
  24.  
  25. def sense(self, sensory_input: bool):
  26. sensory_input
  27. pass
  28.  
  29. def move(self):
  30. if self.times_moved < self.w - 1:
  31. self.times_moved += 1
  32. return self.direction
  33. else:
  34. self.times_moved = 0
  35. self.direction = Action.RIGHT if self.direction == Action.LEFT else Action.LEFT
  36. return Action.DOWN
  37.  
  38. def reset(self):
  39. self.init_state()
  40.  
  41. def get_histogram(self):
  42. return self.histogram
  43.  
  44. test_locally("tests/2015.in", Agent, n=n)
  45. test_locally("tests/2016.in", Agent, n=n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement