def set_dest(self): exits = self._tunnel.exits[:] dest = None while dest is None and len(exits) > 0: nearest_exit = utils.find_nearest_segment(self._position, exits) exit_dest = nearest_exit.start \ + utils.vmiddle(nearest_exit.end - nearest_exit.start) if self._check_exit_blockage(exit_dest): exits.remove(nearest_exit) else: dest = exit_dest if len(exits) == 0 and dest is None: nearest_exit = utils.find_nearest_segment(self._position, self._tunnel.exits) dest = nearest_exit.start + utils.vmiddle(nearest_exit.end - nearest_exit.start) dest_vec = utils.vnormalize(dest - self._position) self._dest = dest + dest_vec * self.DEST_GAP self._find_nearest_end() self._find_checkpoint()
def _calculate_reaction_time(self, reaction_time): nearest_src = utils.find_nearest_segment(self._position, self._tunnel.fire_sources) src_mid = nearest_src.start + utils.vmiddle(nearest_src.end - nearest_src.start) dist = utils.vlen(src_mid - self._position) self._reaction_time = self.FS_DIST_COEFF * dist + reaction_time