def valid_moves_feature(mp: Map) -> torch.Tensor: neighbours: Set[Point] = set(mp.get_neighbours(mp.agent.position)) res: torch.Tensor = torch.zeros(8) for idx, mv in enumerate(mp.EIGHT_POINTS_MOVE_VECTOR): next_point: Point = Map.apply_move(mv, mp.agent.position) if next_point in neighbours: res[idx] = 1 return res
def __get_hit_point_along_dir(mp: Map, move: Point) -> Point: pos: Point = mp.agent.position pos = mp.apply_move(pos, move) while mp.is_agent_valid_pos(pos): pos = mp.apply_move(pos, move) return pos