def initialize(self): no_observers_arr=[2,6,10,14,18] no_targets_arr=[3,9,15,21,27] target_speed=[0.2,0.5,0.8,1.0,1.2,1.5] observer_speed=1.0 sensor_range=[5,10,15,20,25] observer_target_dict={} obstacle_len=[2,5,8,10,12,20] targets=[] a=[-1 ,1] observers=[] obstacles=[] no_targets=no_targets_arr[RI(0,4)] no_observers=no_observers_arr[RI(0,4)] no_obstacles=int(ceil(no_targets/3)) for i in range(no_targets): targets.append(T(R()*150*a[RI(0,1)],R()*150*a[RI(0,1)],target_speed[RI(0,5)],R()*360,sensor_range[RI(0,4)])) for i in range(no_observers): observers.append(O(R()*150*a[RI(0,1)],R()*150*a[RI(0,1)],observer_speed,sensor_range[RI(0,4)])) for i in range(no_obstacles): obs_len=obstacle_len[RI(0,5)] angle=R()*360 pos_x=R()*150*a[RI(0,1)] pos_y=R()*150*a[RI(0,1)] temp_obs=[] for j in range(obs_len): temp_obs.append(Ob(pos_x+j*sin(angle),pos_y+j*cos(angle),angle,i)) obstacles.append((obs_len,temp_obs)) return (no_targets,no_observers,no_obstacles,targets,observers,obstacles)
def initialize(): targets = [] a = [-1, 1] observers = [] obstacles = [] no_targets = no_targets_arr[RI(0, 4)] no_observers = no_observers_arr[RI(0, 4)] no_obstacles = int(ceil(no_targets / 3)) for i in range(no_targets): targets.append( T(R() * 150 * a[RI(0, 1)], R() * 150 * a[RI(0, 1)], target_speed[RI(0, 5)], R() * 360, sensor_range[RI(0, 4)])) for i in range(no_observers): observers.append( O(R() * 150 * a[RI(0, 1)], R() * 150 * a[RI(0, 1)], observer_speed, sensor_range[RI(0, 4)])) for i in range(no_obstacles): obs_len = obstacle_len[RI(0, 5)] angle = R() * 360 pos_x = R() * 150 * a[RI(0, 1)] pos_y = R() * 150 * a[RI(0, 1)] temp_obs = [] for j in range(obs_len): temp_obs.append( Ob(pos_x + j * sin(angle), pos_y + j * cos(angle), angle, i)) obstacles.append((obs_len, temp_obs)) return (no_targets, no_observers, no_obstacles, targets, observers, obstacles)
def initialize(self): no_observers_arr = [2, 6, 10, 14, 18] no_targets_arr = [3, 9, 15, 21, 27] self.x_limit = 150 self.y_limit = 150 target_speed = [0.2, 0.5, 0.8, 1.0, 1.2, 1.5] observer_speed = 1.0 sensor_range = [5, 10, 15, 20, 25] self.total_steps = 1500 self.update_steps = 10 observer_target_dict = {} obstacle_len = [2, 5, 8, 10, 12, 20] self.template_probability_distribution = [ 0.001953125, 0.001953125, 0.00390625, 0.0078125, 0.015625, 0.03125, 0.0625, 0.125, 0.25, 0.5 ] targets = [] a = [-1, 1] observers = [] obstacles = [] observer_strategy = [] no_targets = no_targets_arr[RI(0, 4)] no_observers = no_observers_arr[RI(0, 4)] no_obstacles = int(ceil(no_targets / 3)) for i in range(no_targets): targets.append( T(R() * 150 * a[RI(0, 1)], R() * 150 * a[RI(0, 1)], target_speed[RI(0, 5)], R() * 360, sensor_range[RI(0, 4)])) for i in range(no_observers): observers.append( O(R() * 150 * a[RI(0, 1)], R() * 150 * a[RI(0, 1)], observer_speed, sensor_range[RI(0, 4)])) observer_strategy.append(RI(1, 4)) for i in range(no_obstacles): obs_len = obstacle_len[RI(0, 5)] angle = R() * 360 pos_x = R() * 150 * a[RI(0, 1)] pos_y = R() * 150 * a[RI(0, 1)] temp_obs = [] for j in range(obs_len): temp_obs.append( Ob(pos_x + j * sin(angle), pos_y + j * cos(angle), angle, i)) obstacles.append((obs_len, temp_obs)) return (no_targets, no_observers, no_obstacles, targets, observers, obstacles, observer_strategy)