Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from misio.lost_wumpus.testing import test_locally
- from misio.lost_wumpus.agents import RandomAgent
- from misio.lost_wumpus._wumpus import Action
- from misio.lost_wumpus._wumpus import Field
- import numpy as np
- np.set_printoptions(precision=3, suppress=True)
- n = 10
- class Agent():
- def __init__(self, map: np.ndarray, p: float, pj: float, pn: float):
- self.p = p
- self.pj = pj
- self.pn = pn
- self.h, self.w = map.shape
- self.map = map.astype(np.float64)
- self.histogram = np.ones_like(self.map)
- self.init_state()
- def init_state(self):
- self.times_moved = 0
- self.direction = Action.LEFT
- def sense(self, sensory_input: bool):
- sensory_input
- pass
- def move(self):
- if self.times_moved < self.w - 1:
- self.times_moved += 1
- return self.direction
- else:
- self.times_moved = 0
- self.direction = Action.RIGHT if self.direction == Action.LEFT else Action.LEFT
- return Action.DOWN
- def reset(self):
- self.init_state()
- def get_histogram(self):
- return self.histogram
- test_locally("tests/2015.in", Agent, n=n)
- test_locally("tests/2016.in", Agent, n=n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement