# The Window class

class `LinMaze.LinMaze.``VRWindow`(session, screen_number, mirrored=False, fullscreen=True)

  A pyglet window that can display VR on a given screen.

  Parameters: | session (Session) – The session that is played in this window. screen_number (int) – Which monitor the window should display on. mirrored (bool) – True if the contents of this window should be mirrored horizontally. False by default. fullscreen (bool) – True if the window should be fullscreen. True by default.

  `on_close`()

    The user attempted to close the window.

    This event can be triggered by clicking on the “X” control box in the window title bar, or by some other platform-dependent manner.

    The default handler sets has_exit to `True`. In pyglet 1.1, if pyglet.app.event_loop is being used, close is also called, closing the window immediately.

    Event: |

  `on_draw`()

    The window contents must be redrawn.

    The EventLoop will dispatch this event when the window should be redrawn. This will happen during idle time after any window events and after any scheduled functions were called.

    The window will already have the GL context, so there is no need to call switch_to. The window’s flip method will be called after this event, so your event handler should not.

    You should make no assumptions about the window contents when this event is triggered; a resize or expose event may have invalidated the framebuffer since the last time it was drawn.

    New in version 1.1.

    Event: |

  `on_key_press`(symbol, modifiers)

    A key on the keyboard was pressed (and held down).

    In pyglet 1.0 the default handler sets has_exit to `True` if the `ESC` key is pressed.

    In pyglet 1.1 the default handler dispatches the `on_close()` event if the `ESC` key is pressed.

    Parameters: | symbol : int The key symbol pressed. modifiers : int Bitwise combination of the key modifiers active.
    Event: |

# The Logger class

class `LinMaze.LinMaze.``VRLog`(session)

  A logger for LinMaze Sessions.

  Parameters: | session (Session) – The session that should be logged.

  `close`()

    Record the time and close the log.

  `flush`(record, fieldname)

    Writes the record list into the given field and clears it.

    Parameters: | record (list or np.ndarray) – The record that should be written to file. fieldname (str) – The name of the field in the HDF5 file this record should be written into.

  `flush_all`()

    Writes all temporary data to file.

  `make_entry`(vel, g_time, in_1, in_2, out_1, out_2, out_3, out_4)

    Makes an entry in all the session logs.

    Parameters: | vel (int) – The velocity that sould be logged for this entry. g_time (int) – The internal clock value of the Gramophone. in_1 (int) – The state of digital input 1. in_2 (int) – The state of digital input 2.

# The Session class

class `LinMaze.LinMaze.``Session`(level, vel_ratio=1, runtime_limit=None, left_monitor=1, right_monitor=None, gramophone_serial=None, fullscreen=True, offset_arrow=False, skip_save=False)

  A play/simulation session for a LinMaze Level.

  Parameters: | level (Level) – The LinMaze Level that will be played in this Session. vel_ratio (float) – The velocity read from the Gramophone is multiplied with this. 1 by default. runtime_limit (float or None) – How long should the simulation run in minutes. Set to None to run infinately. None by default left_monitor (int or None) – The number of the monitor to the right of the animal. Set to None to disable this monitor. 1 by default. right_monitor (int or None) – The number of the monitor to the right of the animal. Set to None to disable this monitor. None by default. gramophone_serial (int or None) – The serial of the Gramophone used for the simulation. Set to None to find a Gramophone automatically. None by default. fullscreen (bool) – Should the simulation run in fullscreen mode? True by default. offset_arrow (bool) – Should the zone_offset of the Level be shown as a red arrow on screen? False by default. skip_save (bool) – Should the saving of a log be skipped for this Session? False by default.

  `check_rules`(vel, in_1, in_2)

    Checks all the rules of the Level.

    Parameters: | vel (int) – The current velocity (for velocity based rules). in_1 (int) – The state of input 1 in_2 (int) – The state of input 2

  `check_zone`()

    Updates the current zone.

  `movement`(vel)

    Move on the map with given velocity.

    Parameters: | vel (int) – Distance to move in pixels.

  `pause`(position=None)

    Pauses the level at the given position.

    Parameters: | position (int or None) – Where should the simulation pause on the Level in pixels. Set to None to pause at current position. None by default.

  `random_teleport`(target_zone_types)

    Teleports to the middle of a random zone with one of the given zone types.

    Parameters: | target_zone_types ([str]) – list of possible landing zone types.

  `teleport`(target_pos)

    Teleports to the given position.

    Parameters: | target_pos – Where should the teleportation land in pixels.

  `unpause`(position=None)

    Unpauses the level at the given position.

    Parameters: | position (int or None) – Where should the simulation unpause on the Level in pixels. Set to None to unpause at current position. None by default.