Module moog.game_rules
Game Rules
The MOOG Environment class takes a game_rules
keyword
argument that is an iterable of game rules. These game rules implement all of
the dynamics of the environment not implemented by the physics. Intuitively,
physics should implement forces, whereas game rules should implement
higher-level transition dynamics, such as sprites appearing/disappearing,
changing color, etc.
Game rules must satisfy the API of AbstractRule
. In this
directory are a few different kinds of game rules. These can be combined in
various ways to implement a wide variety of tasks (see our example
tasks).
However, if game rules are insufficient for you to implement your task, by all
means implement a custom game rule inheriting from AbstractRule
— typically
this can be done with only a few lines of code. In the
functional_maze.py
example config we have an example of a custom game rule implemented in the
config.
Task phases
We want to draw particular attention to the rules in
task_phases.py, which are useful when your task trials have
phases. For example, your task may have a fixation phase at the beginning of
each trial. The Phase
and PhaseSequence
provide a way to compose trial
phases with conditional transitions between them.
For examples of phase rules, see the
match_to_sample
and
multi_tracking_with_feature.py
example configs.
Expand source code
""".. include:: README.md"""
from .abstract_rule import AbstractRule
from .change_layer import ChangeLayer
from .conditional import ConditionalRule
from .contact_rules import get_contact_counter
from .contact_rules import get_contact_indices
from .contact_rules import ModifyOnContact
from .create_sprites import CreateSprites
from .fixation import Fixation
from .modify_meta_state import ModifyMetaState
from .modify_meta_state import UpdateMetaStateValue
from .modify_sprites import ModifySprites
from .portal import Portal
from .re_center import KeepNearCenter
from .task_phases import Phase
from .task_phases import PhaseSequence
from .timing import DelayedRule
from .timing import TemporaryRule
from .timing import TimedRule
from .vanish import Vanish
from .vanish import VanishByFilter
from .vanish import VanishOnContact
Sub-modules
moog.game_rules.abstract_rule
-
Abstract game rule.
moog.game_rules.change_layer
-
Rules that move sprites from one layer to another.
moog.game_rules.conditional
-
Rule that is applied only when a condition is satisfied …
moog.game_rules.contact_rules
-
Rules and functions involving sprite contacts …
moog.game_rules.create_sprites
-
Rule that creates new sprites.
moog.game_rules.fixation
-
Rule that can be used to monitor fixation …
moog.game_rules.modify_meta_state
-
Rules that modify environment meta_state.
moog.game_rules.modify_sprites
-
Rules that modify sprites.
moog.game_rules.portal
-
Portal …
moog.game_rules.re_center
-
Rules that re-center a sprite periodically …
moog.game_rules.task_phases
-
Rules to facilitate tasks with phases …
moog.game_rules.timing
-
Rules that control the timing of when to apply other rules …
moog.game_rules.vanish
-
Rules that make sprites vanish.