Skip to content

CSV done state #33

@arugu1a

Description

@arugu1a

As discussed in yesterday’s Zoom meeting, the CSV log currently only records a train as done if an action for the train is issued after it reaches its destination. After looking into it further, I found a rather simple fix. I suggest adding the following code snippet after the main while loop to log the final status of all trains at the last time step:

for i, agent in enumerate(env.agents):
        if agent.position is not None:
            position = agent.position
        else:
            position = "off map"
        log.add(f'{i};{timestep};{position};{dir_map[agent.direction]};{dir_map[env.agents[i].direction]};{state_map[env.agents[i].state]};\n')

Here is an example on how the bottom of the CSV looks after the change:

.
.
.
7;182;(79, 56);e;moving;move_forward
0;183;(64, 78);n;moving;move_forward
7;183;(79, 57);e;moving;move_forward
0;184;off map;n;n;done;
1;184;(77, 53);n;n;stopped;
2;184;off map;s;s;done;
3;184;off map;w;w;done;
4;184;(77, 52);e;e;stopped;
5;184;off map;w;w;done;
6;184;off map;n;n;done;
7;184;off map;e;e;done;

This also confirms that no extra action is needed on the train’s end cell to reach the done state. Also note that the last recorded time step before the change in this example was 183, meaning the actual final time step was cut off causing the last done state to never be displayed, even with an extra action.
Hope this helps! : )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions