def crossroads_map(): cross={} #dictionary of crossroads for xx in x: for yy in y: lab=str(xx)+str(yy) cross_=crossing(car_nums=np.array([0,0,0,0]),light_state=0,q_states=q_states[xx][yy]) cross[lab]=cross_ return cross
def crossroads_map(x,y): cross={} #dictionary of crossroads for xx in x: for yy in y: lab=str(xx)+str(yy) #string lab for addressing each crossroad, xx ~ [1,grid_x] #Initialization cross_=crossing(car_nums=np.array([0,0,0,0]),light_state=0,q_states=q_states[xx][yy]) cross[lab]=cross_ return cross
def road_map(): cross1=crossing(light_state=0,q_states=[0,0,0,1]) cross2=crossing(light_state=0,q_states=[0,0,1,0])
# def hit_me(): # global on_hit # global next_step # if on_hit == False: # on_hit = True # next_step=0 # else: # on_hit = False # next_step=1 # b = tk.Button(window, text='Next Step', width=15, # height=2, command=hit_me) # b.pack() visual=Visual() cross1=crossing(light_state=0,q_states=[0,0,0,1]) cross2=crossing(light_state=0,q_states=[0,0,1,0]) obs=np.concatenate((cross1.car_nums, cross1.light_state, cross2.car_nums, cross2.light_state),axis=None) for steps in range(200000): visual.visual_before(cross1, cross2) action=RL.choose_action(obs) if action == 0: action1 =0 action2 =0 elif action ==1: action1 =1 action2 =0 elif action ==2: action1 =0