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!