flatland.core.grid.rail_env_grid module#
- class flatland.core.grid.rail_env_grid.RailEnvTransitions[source]#
Bases:
Grid4Transitions
Special case of GridTransitions over a 2D-grid, with a pre-defined set of transitions mimicking the types of real Swiss rail connections.
As no diagonal transitions are allowed in the RailEnv environment, the possible transitions for RailEnv from a cell to its neighboring ones are represented over 16 bits.
The 16 bits are organized in 4 blocks of 4 bits each, the direction that the agent is facing. E.g., the most-significant 4-bits represent the possible movements (NESW) if the agent is facing North, etc…
agent’s direction: North East South West agent’s allowed movements: [nesw] [nesw] [nesw] [nesw] example: 1000 0000 0010 0000
In the example, the agent can move from North to South and viceversa.
- is_valid(cell_transition)[source]#
Checks if a cell transition is a valid cell setup.
Parameters#
- cell_transitionint
64 bits used to encode the valid transitions for a cell.
Returns#
- Boolean
True or False
- transition_list = [0, 32800, 37408, 33825, 38433, 52275, 20994, 8192, 16386, 4608, 49186]#
- class flatland.core.grid.rail_env_grid.RailEnvTransitionsEnum(value)[source]#
Bases:
IntEnum
An enumeration.
- dead_end_from_east = 4#
- dead_end_from_north = 128#
- dead_end_from_south = 8192#
- dead_end_from_west = 256#
- diamond_crossing = 33825#
- double_slip_NE_SW = 38505#
- double_slip_NW_SE = 52275#
- empty = 0#
- horizontal_straight = 1025#
- right_turn_from_east = 72#
- right_turn_from_north = 2064#
- right_turn_from_south = 16386#
- right_turn_from_west = 4608#
- simple_switch_east_left = 3089#
- simple_switch_east_right = 5633#
- simple_switch_north_left = 37408#
- simple_switch_north_right = 49186#
- simple_switch_south_left = 32872#
- simple_switch_south_right = 34864#
- simple_switch_west_left = 17411#
- simple_switch_west_right = 1097#
- single_slip_NE = 33897#
- single_slip_NW = 35889#
- single_slip_SE = 50211#
- single_slip_SW = 38433#
- symmetric_switch_from_east = 16458#
- symmetric_switch_from_north = 2136#
- symmetric_switch_from_south = 20994#
- symmetric_switch_from_west = 6672#
- vertical_straight = 32800#