How can I create a rail network, which is just a simple circle?

Hey Guys,
I am trying to understand the basics of the flatland environment. I guess this will be the stupidest question on this forum, but I am feeling lost … I have to ask.

How can I create a rail network, which is just a simple circle ?

My Idea was to follow the “Simple Example 1 : Basic Usage”. But how would the specs look like ? There is no Tile for corners and the environment does not create them itself …

I would be glade, if there is anyone willing to answer such a simple question.


Hello @fhohnstein,

This is not a stupid question at all, actually creating such an environment wouldn’t be so easy!

So, one solution would be as you mentioned to use the rail_from_manual_specifications_generator generator, and to “draw” the environment yourself. But that would be complicated! Building such maps ny hand is not easy.

@hagrid67 had developed an editor system, I don’t know if it still works with recent Flatland releases?

In any case, you probably don’t need to create the environments by yourself. An easier way to create simple environments is to use the sparse railway generator and to play with its parameters.

If you want to run simple experiments, you can set the number of agents to 1, make the environment 25x25 and a low number of cities.

Check out this Colab notebook for a concrete example:

Download Execute In Colab

Also, I am curious, you mention the old documentation ( How did you end up on that page?

We have moved everything to the new doc, which contains the same information but more up to date (eg for that page: Is there an outdated link to the old doc somewhere?

1 Like

Hi @fhohnstein - there are a couple of notebooks in the flatland repo which might be of interest.

Scene-editor.ipynb should allow you to draw some rails by dragging the mouse. There are some buttons to load & save etc. It’s a bit broken when it comes to adding agents and targets though.

test-collision.ipynb creates a simple environment on-the-fly using which is related to the editor. It applies simulated mouse-strokes, specified by (row,column) co-ordinates, similar to how the editor works. The one used in the test case is called “concentric_loops” and is defined in ddEnvSpecs like this:

        # Concentric Loops
        "concentric_loops": {
            "llrcPaths": [
                [(1,1), (1,5), (8, 5), (8,1), (1,1), (1,3)],
                [(1,3), (1,10), (8,10), (8,3)]
            "lrcStarts": [(1,3)],
            "lrcTargs": [(2,1)],
            "liDirs":  [1]

When defining the “strokes” (llrcPaths means list of list of row,col paths to me :slight_smile:) you need to make the ends of the strokes overlap a bit, and then it can work out how to join the rails. (This applies if you’re doing it by hand in the editor too.)

Hope that helps!



I am trying to do 2 things:

  • Create a rail-network of a specific shape- not random networks that available functions seem to create.
  • Schedule multiple trains between the same pair of source (initial position) and destination (target) after regular intervals.

After exploring flatland documentation for few days, thanks to MasterScrat, I found this could be done using Scene_Editor.ipynb (see notebooks in flatland env.). However, it is a painfully slow process to even create a simple network. Moreover, I am unable to create multiple agents as pressing Ctrl+k does not create a new agent but only moves the old agent around.

Is there a more convenient way to generate customised rail networks- may be based on node and link information of underlying network structure? Moreover, how can I generate customised schedules of multiple agents (start time in addition to initial and target locations)?

For the environment edition process, @hagrid67 would know better. I don’t think there will be better than the Scene_Editor.ipynb notebook.

If you do create useful editing tools or test environments, they would be nice submissions to the Community Prize BTW :wink:

Regarding schedules, there’s no pre-defined “start time” as part of the environments. The agents can start moving whenever they want, assuming the way is clear. This is something that should be handled at the policy level, and not at the environment level. Or did I misunderstand your question?