Pi-Star-Lab / RESCO

Reinforcement Learning Benchmarks for Traffic Signal Control (RESCO)
116 stars 36 forks source link

TODO grab info. directly from tllogic python interface #3

Closed wansongying closed 2 years ago

wansongying commented 2 years ago

Hi! Thanks for sharing your code. It's very nice, bro. I found a comment in multi_signal.py, said "TODO grab info. directly from tllogic python interface". I figured it out, test on my project, it works! There is code. Hope it will be helpful :)

    for lightID in self.signal_ids:
        for c in self.sumo.trafficlight.getAllProgramLogics(lightID):
            for k in c.getPhases():
                cur_phase = k.state
                if not lightID in valid_phases:
                    valid_phases[lightID] = []
                has_phase = False
                for phase in valid_phases[lightID]:
                    if phase == cur_phase:
                        has_phase = True
                if not has_phase:
                    valid_phases[lightID].append(cur_phase)
    self.step_sim()
jault commented 2 years ago

Thanks a lot! I'll test it out and integrate it into the next update.