Loading pre-create env

Hi everybody,

I would like to ask you if you could clarify how to correctly use the ‘rail_from_file’ function from ‘rail_generators’ module.

I have had no problems using this function in previous version, but in the new version I am having difficulties to get it working properly. Either it does load the environment and the trains are placed randomly (probably caused by the missing schedule_generator). When I add the schedule generator I am getting some errors.

Could you please provide more information regarding how to use the function properly in the new version? It would be very helpful.

I attach a picture describing how I was using the function previously and it has worked correctly (rf is the rail from file function). However, I am struggling to get a grasp of it now, after the new release. I can tell that the number of agents now affects the new number of agents in the loaded environment, which it had previously did not.

08

Thank you very much.

Kind regards,

Filip

Hi Filip

I hope the following method does answer your question.

def load_flatland_environment_from_file(file_name):
    rail_generator = rail_from_file(file_name)
    schedule_generator = schedule_from_file(file_name)

    environment = RailEnv(width=1,
                      height=1,
                      rail_generator=rail_generator,
                      number_of_agents=1,
                      schedule_generator=schedule_generator)

    return environment

I tested this method on lastest master trunk. We found yesterday a bug in the load method. The bug is now fixed.

/Adrian