def make_world(self): world = HazardousWorld() # set scenario-specific world parameters world.collaborative = True world.systemic_rewards = True world.identical_rewards = self.identical_rewards world.dim_c = 0 # observation-based communication world.connection_reward = _CONNECTION_REWARD world.termination_reward = _TERMINATION_REWARD world.render_connections = True # add landmarks. terminals first then hazards (if any) # world.origin_terminal_landmark = RiskRewardLandmark( risk_fn=None, reward_fn=RadialReward(1.0, 0.0)) # world.destination_terminal_landmark = RiskRewardLandmark( risk_fn=None, reward_fn=RadialReward(1.0, 0.0)) world.origin_terminal_landmark = Landmark() world.destination_terminal_landmark = Landmark() world.landmarks = [ world.origin_terminal_landmark, world.destination_terminal_landmark ] world.hazard_landmarks = [] for i in range(self.num_hazards): lm = RiskRewardLandmark(risk_fn=RadialRisk(_HAZARD_SIZE, self.hazard_risk), reward_fn=RadialReward(_HAZARD_SIZE, 0.0)) lm.silent = True lm.deaf = True lm.ignore_connection_rendering = True world.hazard_landmarks.append(lm) world.landmarks.append(lm) for i, landmark in enumerate(world.landmarks): landmark.name = 'landmark_%d' % i landmark.collide = False landmark.movable = False landmark.size = _LANDMARK_SIZE # properties for landmarks if isinstance(landmark, RiskRewardLandmark) and landmark.is_hazard: #TODO: make colors heatmap of risk probability over all bounds landmark.color = np.array([ landmark.risk_fn.get_failure_probability(0, 0) + .1, 0, 0 ]) else: landmark.color = np.array([0.25, 0.25, 0.25]) # make initial conditions self.reset_world(world) return world
def make_world(self): world = HazardousWorld( collision_termination_probability=self.collision_risk, flyoff_termination_radius=10.0, flyoff_termination_speed=50.0, spontaneous_termination_probability=1.0 / (8.0 * 50.0 * self.num_agents)) # set scenario-specific world parameters world.collaborative = True world.systemic_rewards = True world.identical_rewards = self.identical_rewards world.dim_c = 0 # observation-based communication world.termination_reward = _TERMINATION_REWARD world.render_connections = True # add landmarks to world world.landmarks = [] for lm in self.scenario_landmarks: world.landmarks.append(lm) for i, landmark in enumerate(world.landmarks): landmark.name = 'landmark_%d' % i landmark.collide = False landmark.movable = False landmark.size = _LANDMARK_SIZE # properties for landmarks if isinstance(landmark, RiskRewardLandmark) and landmark.is_hazard: #TODO: make colors heatmap of risk probability over all bounds landmark.color = np.array([ landmark.risk_fn.get_failure_probability(0, 0) + .1, 0, 0 ]) else: landmark.color = np.array([0.25, 0.25, 0.25]) # make initial conditions self.reset_world(world) return world