Rules and conditions for forming episodic memory (EM) frames

1. General episodic memory layout

EM is an array of frames in strict chronological order. Order is not shuffled; only in-place updates and deletions are allowed without breaking sequence.

Rule (episode frame):
Stimulus (FinalImage) → response action (action image, AI) → effect (Effect) → operator response stimulus (if any).

Frame contents:

Response action + response stimulus form a “teacher” rule: how the operator responds to Beast’s action.

Response waiting timeresponse_waiting_period in pulses (default 15). Timeout closure in EpisodicMemory_onPulse. Frames with unfilled effect remain for optimization.


2. Conditions for starting EM frame formation

EM frame formation starts only through the orientation reflex (OR). A frame is created when: OR fired, OR conditions hold (OR_well_known threshold, etc.), and no waiting period is active (otherwise the stimulus is treated as a response). save_episodic_memory is called from OR; the frame and progress bar are created on every such OR firing (not only in test mode).


3. Frame lifecycle

  1. Creation (on OR fire):

    • The previous open frame is closed (if any and the waiting period has not expired — the current stimulus is recorded as response; otherwise the frame closes without a response stimulus).
    • An “empty” frame is appended to EM: perceptionNodeId, stimulusImageId, diffBefore (getDiffImportance() before stimulus activation, from PrevDiffForEpisode), actionImageId = null, effect = null, responseStimulusImageId = null.
    • Pulse counter and EpisodicMemory_waitingStartedAt are set; closure by pulses in EpisodicMemory_onPulse. The progress bar is visible only when waiting is active in this session.
  2. Filling with response action:
    When Beast performs a reaction (genetic or conditioned), actionImageId is written to the last frame via EpisodicMemory_setLastFrameActionFromActionId(actionId). The stimulusImageId already stored in the frame is used (so the frame fills even with delayed reaction or cleared stimuli).

  3. Frame completion:

    • Response stimulus during waiting: OR first checks isInWaitingPeriod(). If true — the stimulus counts as the operator’s answer, closeLastFrameWithResponse(winnerId) is called. OR_well_known for the response stimulus is not checked.
    • Waiting expires without response stimulus: in EpisodicMemory_onPulse the frame closes. If actionImageId === null, the frame is removed; otherwise it remains with computed effect.

During the waiting period any stimulus is treated only as the operator’s response (samplesCount is not checked).


4. Orientation reflex (OR) and EM conditions

Check order: (1) No active stimuli — exit silently (deactivation). (2) No branch / no winner — exit. (3) Register in semantic memory. (4) First isInWaitingPeriod() — if true, close frame with answer; OR_well_known does not apply. (5) Then check samplesCount >= OR_well_known to start a new process. (6) Otherwise — save_episodic_memory; frame and progress bar are always created. Waiting only when waitingStartedAt != null (a loaded open frame does not imply “in waiting”).


5. EM formation test mode

Enabled with the “t” button in the “Active perception-tree branch” block. Flag: global.EpisodicMemory_testMode.

In test mode:

In test mode an EM frame is also created when semantic significance exists (runEpisodic = !hasSignificance || EpisodicMemory_testMode) so the process can be observed step by step.


6. Conditioned reflexes in the context of the orientation reflex

Rule: if a stimulus triggered the orientation reflex, the conditioned reflex formation process does not run for it.

Mechanism:

  1. When OR fires it blocks genetic (or conditioned) reflex execution for 2 pulses (OR_BLOCK_PULSES). The reflex does not run immediately but is queued (delayedReflexes).
  2. When enqueued and when the delayed reflex later runs, the event records flag noConditionalReflex: true.
  3. When the delayed reflex runs, startAction receives option noConditionalReflex: true. With this option synonyms_onGeneticActionFired is not called — the conditioned (synonym) reflex subsystem gets no signal to form or strengthen a conditioned reflex for that stimulus.

Thus a stimulus that attracted OR (i.e. whose reflex was delayed) does not participate in conditioned reflex formation; conditioned reflexes form only for stimuli whose reflex fired without OR blocking.


7. Summary of key constants and flags

Parameter Description Default
response_waiting_period Response waiting duration (in pulses) 15
OR_well_known Threshold to start a new OR/EM process (not for response stimulus) 10
EpisodicMemory_testMode Step-by-step messages for EM formation false
OR_BLOCK_PULSES Pulses to block reflex after OR 2

Implementation files: _10_Episodic_memory/episodic_memory.js, _8_Hippocampus/orientation_reflex.js, _5_Genetic__reflexes/genetic_reflexes_engine.js.