@Ashkan I saw your answer on that problem (How to write Get_state() return based in multi-agent based on agent-id?)
You gave some example codes: def get_state(self):
agent_state_dict = {}
i = 0
for intersection, edges in self.scenario.get_node_mapping():
i = i + 1
agent_id = self.agent_name_prefix + str(i) # self.agent_name_prefix is defined as string "intersection"
speeds = []
dist_to_intersec = []
traffic_light_states = []
..... code .....
# construct the state (observation) for each agent
observation = np.array(
np.concatenate([
speeds, dist_to_intersec, traffic_light_states
# each intersection is an agent, so we will make a dictionary that maps form "self.agent_name_prefix+'i'" to the state of that agent.
agent_state_dict.update({agent_id: observation})
return agent_state_dict
I have some question about your code:
- on the 'for' loop, you use intersection and edges one time, and there is no other usage of intersection and edges, what the function of intersection and edges at here?
On the dist_to_intesec[], based on green_wave_env.py, it will returns all vehicles' distance to all intersections, not return the vehicles' distance to a special/individual intersection, I do not very understand your dist_to_intersec[] at here, can you explain it?
How to check the data of get_state(), for example, I want to get the data of dist_to_intersec.
On my project: Based grid network, I want to get the number of how much vehicles is on the circle of an intersection(for example, the radius of that circle is 100m, the intersection is the center point) on a horizon time. So your reply will help me a lot. @Ashkan